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

clang-format

$ clang-format Foundation Low Risk
LLVM Project · Code & DevOps · Apache-2.0 WITH LLVM-exception · macos / linux / windows

Official LLVM code formatting CLI supporting C, C++, Objective-C, Java, JavaScript, and Protocol Buffers via .clang-format rules. Offers non-destructive --dry-run and -Werror checks before applying -i in-place edits.

FCRS-1.0 Score
87 /100
Good
Medium Confidence
Zero-Friction Install
brew install clang-format
CLI vs MCP Decision CLI Only

Formats C/C++/Protobuf AST tokens locally in milliseconds; no MCP server is needed.

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 19 / 25

Provides --dry-run, -Werror, and --output-replacements-xml, though it lacks native --json output.

  • --dry-run -Werror gives deterministic pass/fail exit codes
  • --output-replacements-xml emits machine-parseable XML hunks instead of JSON
Trust & Safety 23 / 25

Read-only by default; writes to disk only when -i is explicitly supplied.

  • Non-destructive default stdout mode and explicit --dry-run flag
Setup & Portability 14 / 15

Widely distributed standalone binary via Homebrew, Linux packages, PyPI wheel, and LLVM releases.

  • Cross-platform native C++ binary on macOS, Linux, and Windows
Utility & Efficiency 13 / 15

Industry-standard formatter across C/C++/Protobuf with deterministic .clang-format config resolution.

  • Supports multiple C-family and IDL languages from one binary
Maintenance & Lineage 10 / 10

Official LLVM Foundation tool maintained continuously in llvm/llvm-project.

  • Part of official llvm/llvm-project toolchain
Docs & Verifiability 8 / 10

Thorough option reference and .clang-format style docs on clang.llvm.org.

  • Official documentation at clang.llvm.org/docs/ClangFormat.html

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

Purely local source formatting; no credentials stored or required.

Side Effects
Read-Only Local Write
Cost & Quotas

Apache-2.0 with LLVM Exception open-source binary; completely free.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# clang-format Agent Rules
- Always verify with `clang-format --dry-run -Werror` before running `clang-format -i`.
- Scope `-i` to edited files rather than globbing the entire repo unless requested.

Agent-Ready Command Recipes

Safe Read-Only Queries

Dry-run formatting check with non-zero exit
clang-format --dry-run -Werror src/*.cpp include/*.h

Reports unformatted locations to stderr and exits non-zero without modifying any files.

Emit XML formatting replacements
clang-format --output-replacements-xml src/main.cpp

Outputs structured XML byte-offset replacement hunks without rewriting disk files.

Controlled Writes & Previews

Format targeted files in place
clang-format -i src/main.cpp

Reformats only the specified file in place using the repository .clang-format config.

Strengths for Agents

  • + --dry-run -Werror catches formatting drift cleanly without modifying files.
  • + Deterministic .clang-format style inheritance across C, C++, Objective-C, Java, and Protobuf.

Caveats & Pitfalls

  • ! No --json output; machine parsing requires --output-replacements-xml or diff inspection.
  • ! Version mismatches across LLVM releases can change formatting edge cases.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI