From harness-anchor
Use in C/C++ projects for clang-format. Changed-lines-only; never reformat unchanged code mid-feature. .clang-format from root or LLVM baseline.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-anchor:cpp-formattingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
`clang-format` is the de-facto C/C++ formatter. Like Prettier or rustfmt, it's deterministic and removes formatting debates.
clang-format is the de-facto C/C++ formatter. Like Prettier or rustfmt, it's deterministic and removes formatting debates.
clang-format installed (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.
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.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub redtropig/harness-anchor --plugin harness-anchor