agentleFS
abdullahkhawerabdullahkhawer/devops-skills/skills/bash-linting/SKILL.md

bash-linting

Skill8 starsChanged 7 months agoApache-2.0View on GitHub

Lint and format Bash/shell scripts using shellcheck and shfmt according to standard conventions. Use when asked to lint, format, or check style issues in shell scripts.

  • Installs packages

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run this skill when asked to lint, format, or check style for Bash/shell scripts.

    line 8
  2. Distinctive:

    If neither tool is installed, inform the user and ask before installing:

    line 16
  3. Very specific:

    Always quote variable expansions: "$var", not $var (SC2086).

    line 70
  4. Very specific:

    Use [[ ... ]] over [ ... ] for conditionals in Bash scripts.

    line 71
  5. Very specific:

    Use set -euo pipefail at the top of scripts to fail fast on errors, unset variables, and pipeline failures.

    line 72
  6. Very specific:

    Use $(...) command substitution, not backticks.

    line 73
  7. Very specific:

    NEVER install shellcheck/shfmt without asking the user first.

    line 79
  8. Distinctive:

    Always run in check/diff mode first — only apply auto-fixes after the user confirms.

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Bash Linting Skill

Run this skill when asked to lint, format, or check style for Bash/shell scripts.

Step 1 — Detect available tooling

which shellcheck shfmt 2>/dev/null

If neither tool is installed, inform the user and ask before installing:

brew install shellcheck shfmt

Step 2 — Find shell scripts

find . -type f \( -name "*.sh" -o -name "*.bash" \) -not -path "*/node_modules/*" -not -path "*/.git/*"

Also lint any file with a #!/usr/bin/env bash or #!/bin/bash shebang but no .sh extension:

grep -rl '^#!.*\(bash\|sh\)' . --include="*" -l 2>/dev/null | grep -v -E '\.(sh|bash)$'

Step 3 — Run linting (read-only check)

shellcheck <file>

Report all findings grouped by file, with line numbers and SC rule codes (e.g. SC2086).


Step 4 — Run formatting check

shfmt -d -i 2 -ci <file>

Show the proposed diff to the user before applying any formatting changes. -i 2 sets 2-space indentation and -ci indents switch-case bodies — adjust to match the project's existing style if it differs.


Step 5 — Apply formatting (only with user confirmation)

shfmt -w -i 2 -ci <file>

shellcheck findings almost always require a manual code change (not a safe auto-fix) — present each finding with its suggested fix and apply only after user confirmation.


Standard conventions enforced

  • Always quote variable expansions: "$var", not $var (SC2086).
  • Use [[ ... ]] over [ ... ] for conditionals in Bash scripts.
  • Use set -euo pipefail at the top of scripts to fail fast on errors, unset variables, and pipeline failures.
  • Use $(...) command substitution, not backticks.
  • Declare function-local variables with local.
  • Indentation: 2 spaces, no tabs (unless the project's .editorconfig specifies otherwise).

Rules

  • NEVER install shellcheck/shfmt without asking the user first.
  • Always run in check/diff mode first — only apply auto-fixes after the user confirms.
  • Respect the project's existing .shellcheckrc or .editorconfig if present — do not override its settings.
  • Report the exact command run and its full output — do not summarize away findings.
  • Flag any eval, unquoted glob expansion, or command injection risk (e.g. unsanitized input passed to a shell command) as a security finding, even if shellcheck does not flag it directly.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.