shell
Google Shell Style Guide
Official Google Shell scripting standards for consistent, maintainable Bash scripts.
Quick Reference
Golden Rules
- Use
#!/bin/bash— specify interpreter - Quote variables —
"$var"not$var - Check exit codes —
set -eor explicit checks - Use functions — organize code logically
- Avoid parsing
ls— use globs or find - Use
[[over[— more features, fewer gotchas - ShellCheck for linting — catch common mistakes
Naming Conventions (Preview)
| Element | Convention | Example |
|---|---|---|
| Functions | lowercase_with_underscores | get_user_count |
| Variables | lowercase_with_underscores | user_count |
| Constants | UPPER_SNAKE_CASE | MAX_RETRIES |
| Environment vars | UPPER_SNAKE_CASE | PATH |
Basic Patterns (Preview)
#!/bin/bash
# ✓ CORRECT
set -euo pipefail # Exit on error, undefined vars, pipe failures
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function main() {
local user_count="$1"
if [[ -z "${user_count}" ]]; then
echo "Error: user_count required" >&2
return 1
fi
echo "Processing ${user_count} users"
}
main "$@"
When to Use This Guide
- Writing new shell scripts
- Refactoring existing scripts
- Code reviews
- Setting up ShellCheck
- Onboarding new team members
Install
npx skills add testdino-hq/google-styleguides-skills/shell
Full Guide
See shell.md for complete details, examples, and edge cases.
More from testdino-hq/google-styleguides-skills
python
Google's official Python style guide extending PEP 8. Covers type annotations, Google-style docstrings, imports, naming conventions, f-strings, comprehensions, and exception handling. Enforces 80-char line length and 4-space indentation.
3java
Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.
2google-styleguides-skills
Complete collection of Google's official style guides for 17 languages. Includes TypeScript, JavaScript, Python, Java, Go, C++, C#, Swift, Objective-C, HTML/CSS, AngularJS, Shell, R, Common Lisp, Vim Script, JSON, and Markdown. Production-ready coding standards used across Google's engineering organization, formatted for AI agent consumption.
2cpp
Google's official C++ style guide. Covers headers, naming conventions, formatting, classes, memory management, RAII, smart pointers, and modern C++ features.
1