sanitize

sanitize is a command for Claude Code from Redtropig/harness-anchor. It costs 72 tokens per session (1,499 once invoked), scanned A, original, MIT.

A command that builds a C or C++ project with runtime bug checks and runs its tests. It reports the build, tests, findings, verdict, and recommendation in a fixed format.

In plain words
What is it for?
Use it after C or C++ changes, before merging, or while investigating crashes, leaks, use-after-free errors, undefined behavior, and data races.
Why use it?
It gives one repeatable way to look for memory errors, undefined behavior, and data races before changes are merged. The process can take minutes, so it is run on demand.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md; names the AskUserQuestion tool.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

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

Good fit Use it after C or C++ changes, before merging, or while investigating crashes, leaks, use-after-free errors, undefined behavior, and data races.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add Redtropig/harness-anchor
Claude Code
/plugin install harness-anchor

Made for: Claude Code.

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 sanitize

README.md
[![agentmods](https://agentmods.dev/badge/commands/redtropig/harness-anchor/sanitize/github.svg)](https://agentmods.dev/commands/redtropig/harness-anchor/sanitize)
Your own site
<a href="https://agentmods.dev/commands/redtropig/harness-anchor/sanitize"><img src="https://agentmods.dev/badge/commands/redtropig/harness-anchor/sanitize/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sanitize

Your own site · 80×15
<a href="https://agentmods.dev/commands/redtropig/harness-anchor/sanitize"><img src="https://agentmods.dev/badge/commands/redtropig/harness-anchor/sanitize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 72 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,499 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00072 $0.01499
Opus 5 $0.00036 $0.00749
Sonnet 5 $0.00014 $0.00300
Haiku 4.5 $0.00007 $0.00150

Measured 8d ago against content hash 0ee20ee74493, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

sanitize 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 8d 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.

commands/sanitize.md · 109 lines

How it starts

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

/sanitize

Build the project under runtime sanitizers, run its tests, and report findings in a fixed structure — so the result is parseable and honest about what was actually run.

Why a command, not a hook: a sanitizer build+test cycle takes minutes, far beyond the ≤5s warn-only hook budget (CLAUDE.md invariants #4 and #7). PostToolUse may suggest /sanitize after a C/C++ source change, but it must never run sanitizers inline.

Steps

  1. Detect C/C++ and the build system:

    bash ${CLAUDE_PLUGIN_ROOT}/scripts/cpp-detect.sh
    

    Parse the JSON. If is_cpp_project is false, refuse — /sanitize is C/C++ only. Record build_system (cmake / meson / make / bazel).

  2. Locate (or materialize) the sanitizer build script:

    • If scripts/sanitizer-build.sh already exists (dropped by /cpp-init), use it.
    • Else if build_system == cmake, AskUserQuestion to materialize it from ${CLAUDE_PLUGIN_ROOT}/templates/cpp/sanitizer-build.sh.tplscripts/sanitizer-build.sh, then chmod +x. Never overwrite a non-empty existing file without asking (same overwrite policy as /anchor and /cpp-init).
    • Else (meson / make / bazel): there is no canned script — use the build-system recipe from the cpp-sanitizers skill, or ask the user for the exact command.
  3. Pick the configuration (ASan+UBSan and TSan are mutually exclusive — never one build):

    • Default: ASan + UBSan — combinable, covers the most ground (memory errors + UB).
    • For a hang, an intermittent failure, or a suspected data race, run TSan in a separate build dir instead. If the symptom is ambiguous, AskUserQuestion which to run.
    • Windows: TSan is unavailable on Windows toolchains — if TSan is requested or indicated, report Verdict INFRA-FAIL with: "TSan is unavailable on Windows; run the TSan arm under WSL2 or Linux CI, or use Intel Inspector for native race detection" (see cpp-sanitizersplatform/windows.md). ASan+UBSan proceed normally with clang/MinGW; under pure MSVC only ASan is available (UBSan flags will fail at configure — that too is INFRA-FAIL, not CLEAN).

Read the full file on GitHub · 109 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. 8d ago First seen · 109 lines · 72 tokens per session scan A 0ee20ee74493

Subscribe to this mod's changes

sanitize is a command published in the GitHub repository Redtropig/harness-anchor (13 stars, last pushed 1mo ago), licensed MIT. It adds 72 tokens to every session and 1,499 once invoked, about $0.0004 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.