/harness-anchor:cpp-formattingfrom harness-anchor
Formats C/C++ code with clang-format on changed lines only to keep diffs clean. Configures .clang-format from project root or LLVM baseline.
Ships in harness-anchor. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
clang-format is the de-facto C/C++ formatter. Like Prettier or rustfmt, it's deterministic and removes formatting debates.
clang-format reachable — see "Is clang-format actually here?" below before concluding
it's missing; only then brew install clang-format / apt install clang-format..clang-format config at project root (use templates/cpp/.clang-format.tpl if not present — /cpp-init drops it for you)git diff -U0 --no-color HEAD | clang-format-diff -p1 -i
Or, for staged changes:
git clang-format
This formats only changed lines — does not touch unrelated code. Critical for keeping diffs clean.
Before concluding clang-format is unavailable, resolve it properly:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-tool-discovery.sh clang-format
A FOUND line gives you an absolute path — invoke it directly; the binary does
not need to be on PATH. Only NOT_FOUND licenses "unavailable", and then the
honest phrasing is "searched PATH + <listed locations>, not found (as of <YYYY-MM-DD>)",
never "not installed" / "on this machine" (an empty command -v only tells you about PATH —
the VS-bundled LLVM on Windows and keg-only Homebrew llvm on macOS both sit off it).
The date matters as much as the scope: a scope-less negative is wrong about where
you looked, a date-less one is wrong about when.
clang-format -i path/to/file.cpp
Only use this on files you OWN this session, or when starting fresh. Reformatting an unchanged file in the middle of a feature pollutes the diff and obscures review.
clang-format --dry-run --Werror path/to/file.cpp
Returns non-zero if anything would change. Useful in pre-commit / CI.
The template uses LLVM as the base with a few popular tweaks:
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
AllowShortIfStatementsOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
SortIncludes: true
Project teams should agree on BasedOnStyle (LLVM / Google / Mozilla / WebKit) early and stick with it. Don't tweak per-PR.
.pb.cc from protobuf) — exclude via .clang-format-ignoreThe harness-anchor Stop hook (Phase 3+) is currently advisory; it doesn't auto-format. Format manually with git clang-format before /session-end to keep the diff clean.
git diff --stat # should show only changed lines' format
If clang-format touched files you didn't change, your .clang-format may have drifted between machines (different versions produce different output). Pin clang-format major version in CI.
For an unfamiliar .clang-format key (e.g. PenaltyExcessCharacter, BreakInheritanceList) — invoke the docs-lookup skill. It encodes the Context7 → WebSearch fallback and the "Context7 unavailable" detection rules.
Typical entry query: clang-format <option-name> or clang-format style options.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
14 skills in this plugin
/anti-hallucination-gatesUse before claiming done/fixed/passing — or before asserting something is absent: not installed, not available, no such function, couldn't find it. Default-FAIL runs both ways — every claim needs an evidence path. A negative claim must carry its search scope and observation date; state calibrated uncertainty when evidence is missing./capturing-golden-rulesUse when the same mistake or bad pattern recurs, when a code-review comment is really a convention worth enforcing, or when you catch AI-generated drift/slop and want it to never happen again. Encodes the lesson as a durable rule in golden-rules.md — the feedback-flywheel / harness-layer-learning ratchet — instead of a one-off fix. Generic (language-agnostic)./npx claudepluginhub redtropig/harness-anchor --plugin harness-anchorOther plugins' skills for the same job