claudemd-sampling-audit

claudemd-sampling-audit is a command for coding agents from sdsrss/claudemd. It costs 111 tokens per session (1,480 once invoked), scanned A, original, MIT.

A command that scans past Claude Code transcripts for violations of eight specified self-enforced rules. A transcript is the recorded conversation between the developer and the coding agent.

In plain words
What is it for?
Use it to scan a chosen time window or sample, inspect violations by rule, output JSON or Markdown reports and compare the current project with all Claude Code projects.
Why use it?
It provides historical evidence about rule compliance instead of relying on a single recent interaction, while reporting the number of opportunities and violations.

Command

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 claudemd plugin — 16 commands, 6 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 commands/sdsrss/claudemd/claudemd-sampling-audit
Clone the repo
git clone --depth 1 https://github.com/sdsrss/claudemd

Or install claudemd, the plugin that ships this one along with the rest of its 16 commands, 6 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 claudemd-sampling-audit

README.md
[![agentmods](https://agentmods.dev/badge/commands/sdsrss/claudemd/claudemd-sampling-audit.svg)](https://agentmods.dev/commands/sdsrss/claudemd/claudemd-sampling-audit)
Your own site
<a href="https://agentmods.dev/commands/sdsrss/claudemd/claudemd-sampling-audit"><img src="https://agentmods.dev/badge/commands/sdsrss/claudemd/claudemd-sampling-audit.svg" alt="Measured on agentmods" height="20"></a>
Per session 111 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,480 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.1 $0.00111 $0.01480
Opus 5 $0.00056 $0.00740
Sonnet 5 $0.00022 $0.00296
Haiku 4.5 $0.00011 $0.00148

Measured today against content hash e72fac56f5e4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

claudemd-sampling-audit 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 today.

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/claudemd-sampling-audit.md · 46 lines

How it starts

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

Default window is 30 days, current project only. If the user passes a number (e.g. /claudemd-sampling-audit 60), set CLAUDEMD_SAMPLING_DAYS=$ARGS before invocation.

Run: CLAUDEMD_SAMPLING_DAYS=${ARGS:-30} node ${CLAUDE_PLUGIN_ROOT}/scripts/sampling-audit.js

Flags (append after the number when needed):

Flag Effect
--days=N Window in days (positive integer, default 30; overrides env).
--sample=N Random subset of N transcripts within the window (per project dir).
--global Scan all CC project dirs (~/.claude/projects/*) — not just cwd; adds byClass self-repo vs external stratification.
--json Emit machine-readable JSON to stdout instead of a markdown report.

The JSON / markdown contains:

Field Meaning
windowDays Window in days actually used.
metricContract The A2 pre-registered constraint: compliance = 1 − violations/opportunities; a rate without its denominator is not evidence.
scannedTranscripts Transcripts within the window that contained ≥1 assistant text turn.
totalTurns Total assistant text turns scanned (sum across transcripts).
unreadableTranscripts Transcripts the reader could not open, with the reason ([] is the healthy case). Non-empty means every denominator below describes a SMALLER population than the file count implies — say so when reporting rates, do not quote them as if the sample were complete.
byRule[<§rule>].violations Per-rule violation count (for §10-V: turns with ≥1 match; hits keeps the raw per-pattern match count).
byRule[<§rule>].opportunities Denominator: detected trigger contexts for that rule (Done lines examined / substantive Uncertain lines / typed-after-tool-turn messages / compaction events / hard-class ops / …).
byRule[<§rule>].precision / .status A4 calibration state. precision stays null until ~50 flagged + ~50 unflagged samples are hand-labeled; status is collecting until precision ≥ 0.8, then calibrated. Uncalibrated ratios are collection data, NOT compliance evidence.
byRule[<§rule>].transcriptsAffected Distinct transcripts with ≥1 violation for that rule.
byClass --global only: {self, external, unknown} split of violations/opportunities per rule (self = project dir ends in -claudemd). Self-repo dogfood and external signal must never be pooled.
overCeremony C1 measure (v0.29.0): totalSegments (typed-user task segments; bare 继续/next continuations extend the current segment) / l0l1Segments (segments that edited ≥1 file, ≤2 distinct files, <80 estimated LOC) / overCeremonySegments (L0/L1-shaped segments containing ≥1 model-initiated ceremony Skill call: sp brainstorming / test-driven-development / systematic-debugging / writing-plans / executing-plans) / ceremonyInvocations (per-skill counts, all segments). C2 pre-registered threshold: after 30d, rate < 5% → keep superpowers, close P3; ≥ 5% → evaluate uninstall (§EXT §12 fallback) / fork / hook-disable. Q&A segments (0 edits) are not opportunities — ceremony there can be correct §2.1 routing.
perTranscript Array of {file, hits: [{rule, turn?, ...}]} — limited to transcripts with ≥1 violation.

Default output (no --json): writes tasks/sampling-audit-<YYYY-MM-DD>.md in the current project (LOCAL calendar day since v0.73.0 — it was UTC, so east of Greenwich a morning run wrote yesterday's filename) and prints a one-line-per-rule violations/opportunities summary to stdout. A same-day re-run refuses to overwrite that file and says so (v0.57.0, after one silently replaced a 216-line hand-annotated calibration record with a 16-line fresh scan); pass --force to replace it anyway, or --json to print without writing. The report also carries a Reader integrity: line stating how many transcripts were unreadable and how many lines failed to parse — printed in both states, so a clean run is distinguishable from a line that stopped appearing.

Read the full file on GitHub · 46 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. today Changed · +1 lines e72fac56f5e4
  2. 5d ago First seen · 45 lines · 111 tokens per session scan A 361c29b8ac78

Subscribe to this mod's changes

claudemd-sampling-audit is a command published in the GitHub repository sdsrss/claudemd (2 stars, last pushed yesterday), licensed MIT. It adds 111 tokens to every session and 1,480 once invoked, about $0.0006 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-31.