cpp-formatting

cpp-formatting is a skill for Claude Code, Codex from Redtropig/harness-anchor. It costs 35 tokens per session (855 once invoked), scanned A, original, MIT.

A guide for using clang-format, a tool that automatically applies consistent formatting to C and C++ code. It focuses on formatting only the lines changed in a feature.

In plain words
What is it for?
Use it to discover the formatter, apply the project’s .clang-format settings, and format changed lines in working or staged code.
Why use it?
It keeps code style consistent without rewriting unrelated parts of a file and making the review harder to follow.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the harness-anchor plugin — 14 skills, 9 commands, 5 agents, 5 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/redtropig/harness-anchor/cpp-formatting
Any agent
npx skills add Redtropig/harness-anchor --skill cpp-formatting
Clone the repo
git clone --depth 1 https://github.com/Redtropig/harness-anchor

Made for: Claude Code, Codex.

Or install harness-anchor, the plugin that ships this one along with the rest of its 14 skills, 9 commands, 5 agents, 5 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cpp-formatting

README.md
[![agentmods](https://agentmods.dev/badge/skills/redtropig/harness-anchor/cpp-formatting.svg)](https://agentmods.dev/skills/redtropig/harness-anchor/cpp-formatting)
Your own site
<a href="https://agentmods.dev/skills/redtropig/harness-anchor/cpp-formatting"><img src="https://agentmods.dev/badge/skills/redtropig/harness-anchor/cpp-formatting.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 855 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00035 $0.00855
Opus 5 $0.00017 $0.00428
Sonnet 5 $0.00007 $0.00171
Haiku 4.5 $0.00003 $0.00085

Measured 3d ago against content hash bf4b2e33c86c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cpp-formatting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cpp-formatting/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

C/C++ Formatting (clang-format)

clang-format is the de-facto C/C++ formatter. Like Prettier or rustfmt, it's deterministic and removes formatting debates.

Prerequisites

  • 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)

Format changed lines only (preferred)

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.

Is clang-format actually here?

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.

Format a whole file

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.

Verify (CI-friendly)

clang-format --dry-run --Werror path/to/file.cpp

Returns non-zero if anything would change. Useful in pre-commit / CI.

Common .clang-format settings

The template uses LLVM as the base with a few popular tweaks:

BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
AllowShortIfStatementsOnASingleLine: Never
AllowShortFunctionsOnASingleLine: Empty
SortIncludes: true

Read the full file on GitHub · 100 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 100 lines · 35 tokens per session scan A bf4b2e33c86c

Subscribe to this mod's changes

cpp-formatting is a skill published in the GitHub repository Redtropig/harness-anchor (13 stars, last pushed 1mo ago), licensed MIT. It adds 35 tokens to every session and 855 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

cpp-systems

Modern C++ patterns: RAII and ownership, rule of zero/five, exceptions and error handling, API and ABI boundaries, templates, and CMake tooling. Use when writing, reviewing, refactoring, or debugging C++, working with smart pointers, move semantics, memory leaks, template errors, or gtest. For plain C, see…

iliaal/ai-skills · 78 tokens

arduino-code-generator

Generate Arduino and embedded C++ snippets for sensors, actuators, buses, state machines, timing, data logging, and hardware abstraction. Use when a user requests implementation code and provide the exact board, framework, toolchain, pins, voltage, memory, and library versions first. Bundled templates target UNO…

wedsamuel1230/arduino-skills · 86 tokens

library-selection

Use when selecting, replacing, pinning, or auditing an Arduino, ESP32, RP2040, C++, or vendor-framework library. Compare architecture support, framework and version compatibility, API behavior, footprint, maintenance, provenance, security, and hardware assumptions before installation.

wedsamuel1230/arduino-skills · 57 tokens

zephyr-json

JSON serialization and deserialization in Zephyr RTOS using the descriptor-based JSON library. Use when encoding C structs to JSON strings, parsing JSON into C structs, working with nested objects or arrays, handling cloud/IoT protocols (MQTT, HTTP, CoAP payloads), or implementing REST APIs on embedded devices.

ksachdeva/zephyr-rtos-ai · 68 tokens

unreal-cpp

写 Unreal C++/蓝图时使用。UObject/GC、反射宏、Tick 性能、蓝图边界。.

Wade-DevCode/awesome-coding-skills-cn · 33 tokens

gdb

Debug and trace C/C++/Rust programs with the GNU Debugger (GDB) without blocking the agent. Use when you need to set tracepoints, inspect variables, or monitor a running process while staying responsive to the user.

betab0t/skills · 50 tokens