shell-google-style
Skill0 starsChanged 9 days agoMITView on GitHub
Audit shell scripts (.sh, .bash, files with a bash/sh shebang) against the Google Shell Style Guide (https://google.github.io/styleguide/shellguide.html) and report violations - quoting, [[ ]], $(...), error handling, function comments, main, naming. Use when asked to check/review/lint/audit Bash or shell scripts against Google style. Also apply these rules when writing or editing shell scripts.
In this repository28 other files it gives its agents.
- accessibility-auditSkill
- api-design-reviewSkill
- architecture-reviewSkill
- complexity-checkSkill
- concurrency-reviewSkill
- config-reviewSkill
- cpp-google-styleSkill
- csharp-google-styleSkill
- dead-code-finderSkill
- dependency-auditSkill
- doc-comment-auditSkill
- error-handling-reviewSkill
- full-reviewSkill
- java-google-styleSkill
- logging-reviewSkill
- markdown-readme-google-styleSkill
- naming-reviewSkill
- owasp-security-reviewSkill
- performance-reviewSkill
- privacy-reviewSkill
- python-google-styleSkill
- regex-reviewSkill
- repo-hygieneSkill
- review-without-fixingSkill
- secrets-scanSkill
- sql-reviewSkill
- test-coverage-reviewSkill
- todo-auditSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Check the files/directories the user names, otherwise the whole repo: *.sh, *.bash and extensionless files with a sh/bash shebang.
- Very specific: line 16
Run (no pipe; output is capped): bash <skill-dir>/scripts/check.sh <project-root> [hitsPerRule=8]
- Distinctive: line 18
No shellcheck installed: the script says so.
- Distinctive: line 24
When to use shell
- Distinctive: line 71
Every finding has a concrete location.
- Distinctive: line 74
Do not change code. Apply fixes only when the user explicitly asks for it.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Google Shell Style Guide
Source: https://google.github.io/styleguide/shellguide.html
Audit: script first, read code only where needed. Review only: report findings, don't edit unless the user explicitly asks. If a project has its own shell conventions (.editorconfig, .shellcheckrc), report deviations from Google style once, then follow the project.
Scope
Check the files/directories the user names, otherwise the whole repo: *.sh, *.bash and extensionless files with a sh/bash shebang. Skip .git/, node_modules/, vendor/, build/, dist/, .venv/ and generated scripts (e.g. configure, gradlew, mvnw).
Audit steps
- Run (no pipe; output is capped):
bash <skill-dir>/scripts/check.sh <project-root> [hitsPerRule=8]- Uses
shellcheckif installed (rule statistics + samples), then grep/awk heuristics## ID count SEV | desc+ samplesfile:line:code. - No shellcheck installed: the script says so. Tell the user that shellcheck (https://www.shellcheck.net) makes quoting and logic checks much more precise, then continue with heuristics and manual review. Never install anything yourself.
- Uses
- Spot-check samples, drop false positives (list below).
- Review ★ rules manually in ≤5 representative scripts (longest, most used).
- Report (format below). Fix order: correctness (quoting, error handling, eval) → structure → formatting.
Rules (ID → script; ★ manual)
When to use shell
- ★ shell only for small utilities and wrappers; >100 lines or complex logic/data structures → recommend a structured language
- S16 executables start with
#!/bin/bash(or#!/usr/bin/env bash) · ★ libraries end in.shand are not executable; executables have.shor no extension · ★ no SUID/SGID
Environment and errors
- S13 error messages go to STDERR (
echo "..." >&2or anerr()helper) - S14 recommended (project rule, not in the Guide):
set -euo pipefailor explicit error checks, so failures don't go unnoticed - ★ check return values:
if ! mv "${a}" "${b}"; then ...; checkPIPESTATUSfor pipelines when needed
Comments
- ★ file header comment describing the contents
- S17 every function except trivial ones has a comment with Description,
Globals:,Arguments:,Outputs:,Returns:(all library functions, no exceptions) - ★ TODO format:
# TODO(user): text
Formatting
- S1 indent 2 spaces, no tabs (tabs only in
<<-heredocs) · S2 ≤80 columns (except URLs, long string literals) - ★ long pipelines: one segment per line,
|at the start of the continuation line, indented 2 - S5
; thenand; doon the same line asif/for/while - ★
case: patterns indented 2, one-line actions ok,;;on its own line for multi-line actions - ★ prefer
"${var}"over"$var"(except single-char specials and positional parameters like$1,$?)
Features and bugs
- ★ quote everything that contains variables, command substitutions, spaces or metacharacters; use arrays for lists of arguments;
"$@", never$*(S8) - S3
$(command), never backticks · S4[[ ... ]]instead of[ ... ]/test - ★ string tests with
-z/-n;==for equality inside[[ ]];(( ))for numbers - ★ wildcard expansion with explicit path:
rm -v ./*, notrm -v * - S7 no
eval· S6 arithmetic with(( ))/$(( )), notlet,expr,$[ ] - ★ no
cmd | while read; use process substitution< <(cmd)orreadarray(variables in a pipe subshell are lost) - S9 don't parse
lsoutput (use globs orfind -print0) · ★ no aliases in scripts, use functions - ★ prefer builtins over external commands (
${var//a/b}oversedfor simple cases)
Naming and structure
- ★ functions
lower_snake_case,::for package separation; braces on the function line;functionkeyword optional but consistent - ★ variables
lower_snake_case; constants and exported variablesUPPER_SNAKE_CASE, declared at the top withreadonly/declare -r - ★
localfor function variables · S10 declare and assign separately when using command substitution (local x; x="$(cmd)"), otherwiselocalhides the exit code - ★ all functions together after constants, no executable code between functions
- S12 scripts with at least one function have
mainand end withmain "$@"
False positives to drop
S1 tabs inside <<- heredocs · S2 long URLs or string literals · S3 backticks inside strings or comments · S4 single brackets in POSIX #!/bin/sh scripts that must stay portable (then report the shebang decision instead) · S12/S17 in sourced library files without executable code · S13 messages that are intentionally user output.
Report
In the user's language, grouped by file:
path/to/script.sh:line - error|warning|info - <ID> <rule> - <why it is a problem> (https://google.github.io/styleguide/shellguide.html#<section>)- Correctness rules (quoting, eval, errors) = error, structure/naming = warning, formatting = info, unless the script says otherwise.
- Every finding has a concrete location; mark uncertain ones as "possible".
- Bulk hits with one root cause: report once with count and 2-3 sample locations.
- End with a summary: findings per severity, then the 3 most important things to fix first.
- Do not change code. Apply fixes only when the user explicitly asks for it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

