Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

shfmt

$ shfmt Community Low Risk
Daniel Marti · Code & DevOps · BSD-3-Clause · macos / linux / windows

Fast single-binary Go parser and canonical formatter for POSIX shell, Bash, mksh, and Bats scripts. Supports read-only diff previews (-d), file listing (-l), AST JSON export (-tojson), and in-place formatting (-w).

FCRS-1.0 Score
91 /100
Excellent
Medium Confidence
Zero-Friction Install
brew install shfmt
CLI vs MCP Decision CLI Only

Sub-10ms local shell formatting and diff verification directly on workspace files.

Agent-Readiness Checklist

✓ JSON Output
— Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Deterministic non-TTY execution with -d diff preview, -l file list, -tojson AST export, and .editorconfig support.

  • -d / --diff previews exact formatting changes non-destructively
  • -tojson dumps parsed AST as JSON
Trust & Safety 24 / 25

Read-only by default (outputs to stdout or diff); mutates files only when -w (--write) is explicitly passed.

  • Requires -w to write files in place
Setup & Portability 15 / 15

Single static Go binary available across macOS, Linux, and Windows via Homebrew, go install, and GitHub Releases.

  • Zero-dependency static Go binary
Utility & Efficiency 13 / 15

Instant syntax validation and canonical formatting for shell scripts with .editorconfig auto-detection.

  • Fast formatting + syntax error checking in one pass
Maintenance & Lineage 9 / 10

Mature, widely used Go project (mvdan/sh) under BSD-3-Clause.

  • Standard Go ecosystem shell parser (mvdan/sh)
Docs & Verifiability 9 / 10

Clear man page (shfmt.1.scd) and concise --help reference.

  • Complete flag and .editorconfig documentation

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

Purely local parser/formatter; no credentials stored or required.

Side Effects
Read-Only Local Write
Cost & Quotas

BSD-3-Clause open-source Go binary; free to use.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# shfmt Agent Rules
- Run `shfmt -d` (or `shfmt -l`) first to verify formatting in read-only mode.
- Only pass `-w` when intending to format scripts in place, and match existing `.editorconfig` indentation settings.

Agent-Ready Command Recipes

Safe Read-Only Queries

Check formatting differences without writing files
shfmt -d -i 2 -ci scripts/

Prints a unified diff and exits non-zero if any script needs formatting, acting as a clean dry-run check.

Parse a shell script into a typed JSON AST
shfmt -tojson scripts/deploy.sh

Outputs the parsed shell syntax tree as JSON for programmatic inspection.

Controlled Writes & Previews

Format shell scripts in place
shfmt -w -i 2 -ci scripts/

Rewrites files with consistent 2-space indentation and indented switch cases.

Strengths for Agents

  • + Strictly read-only unless -w is passed; -d gives exact diff previews and exit codes.
  • + Fast single static Go binary with -tojson AST export and .editorconfig support.

Caveats & Pitfalls

  • ! -tojson exports the full syntax AST rather than a summary lint report; -l / -d emit plain text.
  • ! Formatting style flags (-i, -ci, -bn) should align with repo .editorconfig to avoid noisy diffs.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI