prompt-audit
Audits every fleet instruction file (CLAUDE.md, AGENTS.md, rules, SKILL.md) against the vendors' current prompting guides — first checking whether those guides changed, then linting and judging each f
Files24
View on GitHubSKILL.md.claude/skills/prompt-audit/SKILL.md
GitHubprompt-audit
Capability preflight: read workflow-capabilities and bind dispatch, results, waits, cancellation, model tiers and questions to this session’s actual tools before proceeding. Tool names below are conditional examples; the contract governs adaptation. Keep this skill’s worktree, independent-review, human-review and shipping gates.
Goal: keep the fleet's instruction files in step with what the vendors' current prompting guidance says — and notice when that guidance itself moves. Three phases, in order: a freshness gate (did any guide change since sources.toml's baselines? — a change files the rule-set update issue, and the scan still runs), a scan (deterministic lint + a per-repo judgment pass against rules.md), and outputs (one digest comment on the kind=prompt-audit ledger, plus one audit: prompt-drift findings issue per repo with violations). A fourth lens on the same files /context-audit sizes and /context-purge compresses: prompt-engineering quality, not token budget or layering.
The deliverables are the digest and the prompt-drift issues. This skill reports; it never edits an instruction file, never commits, and never opens a PR. Fixes are /cleanup-fleet prompt-drift's job, under that skill's tier rule and preservation gate (fleet-config#833).
Files in this directory:
rules.md— the rule-set (R-NNblocks: tags, detect, why, fix shape, source). Read it before judging anything; its sha is the ledger'srubric-sha.leads.toml— hand-fed outside claims (videos, posts, talks), each traced to a vendor section or left for the run to trace (step 2c).eval_rotation.py— runs theevals/<case>/suites that skills carry (fleet-config's tiers) through the CLI's plugin-eval command on each model tier, and writes an aggregate to~/.claude/prompt-audit/evals/(fleet-config#1130). Its own weekly job (evals/run-weekly.bat,--rotate: three skills plus up to three whoseSKILL.mdchanged) runs before this skill's; step 2d reads the result.sources.toml— one block per vendor page with its baseline sha + marker, plus the audience vocabulary that decides which rules are primary for a file.audit.py— every exact step:sources,diff-source,inventory,lint,dedup,state,ledger,digest,drift,ping.
<py> below is E:/automation/fleet-config/.venv/Scripts/python.exe; <audit> is .claude/skills/prompt-audit/audit.py.
Arguments
--dry-run— run every phase and print the manifest, lint hits, judgments, the digest and theprompt-driftissue bodies, but write nothing: no state marks, no ledger body, no comment, no update issue, noprompt-driftissue or label. Reading the ledger and the existing issues is allowed.--only <repo>— scan one fleet repo (itshooks/projects.tomlname). The freshness gate still runs in full; the ledger keeps every other repo's entries.--rescan-all— ignore skip-unchanged (scan every file) and source cadence (fetch every source). Also the way to seed theprompt-driftissues: they are filed only from files judged in the run, so a run that skips everything files nothing new.
No argument → the full run.
Execution rules (read first)
- Run from the
fleet-configrepo root. Put fetched pages and run files in a freshly created, uniquely named scratch directory outside the repo (e.g.<session temp>/prompt-audit-<date>-<time>). Never delete through a variable-built path — a harness prompts onrmagainst a variable that could be empty, which blocks an unattended run; a new directory per run needs no cleanup. - Writes are exactly these:
~/.claude/prompt-audit/state.jsonand the page cache beside it (pages/<id>.md, step 2); the ledger issue body and one digest comment (throughaudit.py ledger, which goes throughskills/_lib/audit_issue.py— nevergh issue createa ledger by hand); onekind=prompt-driftissue per repo with something to say plus itsprompt-driftlabel (throughaudit.py drift, same helper); when a guide changed, one rule-set update issue; when the coverage check finds new uncovered sections or a lead gets a new trace result, one comment on that issue each (creating it if none is open, steps 2b and 2c); lead trace results instate.json(step 2c); and, on a delivered run only, one activity-log chat ping (step 10, throughhooks/notify_send.py). Nothing else, and none of it under--dry-run. - Unknown is never a pass. A page that could not be fetched is
not-checked, neverunchanged. A file whose judgment did not come back isunmeasured, nevercompliant. A skipped file is listed as skipped, so "not in the findings" cannot read as "not looked at". - Degrade one item, never the run. A failed fetch degrades that source; a failed judgment agent degrades that repo's files; the run still posts its digest (
status=partialwhen any planned file ended unmeasured). - Poll to completion in this turn (fleet-config#314). Any background agent or command is collected before moving on; never end the turn expecting to be resumed.
- Numbers come from
audit.py. Counts, verdicts, plan actions and the digest's tallies are its output — copy them, never estimate them. - Unattended runs (the weekly
run-weekly.batjob, fleet-config#834) follow the same steps plus two gates: the rate gate before step 6's fan-out, and step 9's delivery assertion. Nobody can answer a question, so never ask one.
Steps
1. Cadence state and sources
<py> <audit> state show
<py> <audit> sources
SOURCE_STATE=<id>|due=yes|no|… per source. A source is fresh only when it was checked within check_every_days and last seen unchanged; for each fresh source state show also prints a ready VERDICT=unchanged|…|sha=cached|… line — keep those lines for the digest. With --rescan-all, treat every source as due.
2. Freshness gate — fetch and diff each due source
Fetch the page's verbatim bytes with the session's shell HTTP client, following redirects, into the scratch dir:
curl -sSL --max-time 60 -o <scratch>/<id>.part -w "%{http_code} %{url_effective}" "<url>"
Only when curl exits 0 and the status is 200, promote it: mv <scratch>/<id>.part <scratch>/<id>.md. A failed or truncated download stays a .part file that diff-source never reads, so it reports not-checked instead of hashing partial bytes into a false changed. A web tool that summarises or converts pages cannot establish a hash; if verbatim fetching is unavailable, skip the fetch and let diff-source report not-checked (the digest says so, and the scan still runs against the current rules.md). Independent fetches may run in parallel. Then, per due source:
<py> <audit> diff-source --id <id> --file <scratch>/<id>.md --final-url <url_effective> --cache
--cache keeps the fetched bytes in ~/.claude/prompt-audit/pages/<id>.md (PAGE_CACHED=) for the coverage check; leave it off under --dry-run. One VERDICT=unchanged|changed|new-guide|not-checked|id=…|sha=…|marker=…|reason=… line each; keep them all. Unless --dry-run, record every verdict except not-checked (which was never checked):
<py> <audit> state mark --source <id> --verdict <verdict>
Any changed or new-guide → step 3, then steps 2b, 2c, 2d and 4. Otherwise → steps 2b, 2c, 2d, then 4.
2b. Coverage check — tracked sections no rule cites
The freshness gate only sees a page that moved. This step diffs every tracked page's leaf sections against the Source: lines in rules.md (rules, appendix, rejected and Covered elsewhere), so guidance that was never encoded keeps surfacing (fleet-config#1128). It is deterministic and costs no tokens most weeks.
<py> <audit> coverage --scratch <scratch> > <scratch>/coverage.json
One object per source: id, status (checked / not-checked / not-applicable), uncovered, new (uncovered and not yet on the update issue), unsectioned_sources. A fresh source reads its cached page; a page with neither a fetched nor a cached copy is not-checked, never 0 uncovered. Carry the whole list into run.json as "coverage" (step 7).
Any new entry → draft, then post:
<py> <audit> coverage --scratch <scratch> --extract > <scratch>/uncovered.mdprints only the new sections' text.- Dispatch one easy-tier worker (same capability contract and rate gate as step 6), briefed read-only to read
rules.mdand<scratch>/uncovered.md(never the whole pages) and write, for each section, anR-NNblock or an appendix / rejected / Covered-elsewhere entry inrules.md's format, with aSource:line citing that section, into<scratch>/drafts.md. A failed worker posts without drafts. - Unless
--dry-run:<py> <audit> coverage --scratch <scratch> --post --drafts <scratch>/drafts.md. It re-reads the update issue, so a section already posted is never posted twice (COVERAGE_POST=none). Under--dry-run, add--dry-runto print the comment.
Uncovered sections never stop the scan, set update_issue, or mark a finding provisional: the rule-set is incomplete, not stale. The skill reports; it never edits rules.md.
2c. Leads — trace outside claims to a vendor sentence
<py> <audit> leads > <scratch>/leads.json
The JSON lists each lead's claims with a status (traced, untracked-vendor, unverified, open) and an open id list. Exit 3 means leads.toml is malformed: report it and carry "leads": null (the digest prints not-checked); never read it as "no leads". A claim with a trace is never re-traced, and neither is one already resolved in state.json.
Any open claim → one easy-tier worker per claim (rate gate as step 6), briefed read-only: find the vendor sentence that says the same thing, searching the cached pages in ~/.claude/prompt-audit/pages/ first, then the vendor docs indexes (llms.txt). It returns one of traced <source id>#<section>, untracked-vendor <url> (a vendor page sources.toml does not track) or unverified. Record each unless --dry-run:
<py> <audit> leads mark --claim <id> --result traced|untracked-vendor|unverified --where "<source id>#<section> or <url>"
Then re-run <py> <audit> leads > <scratch>/leads.json and carry it into run.json as "leads". A traced result is owned by the coverage check from then on; an untracked-vendor page is handled like a new-guide. Unless --dry-run, <py> <audit> leads --post comments the suggested trace = values and proposed [sources.*] blocks on the update issue (once per claim). An unverified claim is listed in the digest for a human; it never becomes a rule or a prompt-drift item, and the skill never edits leads.toml.
2d. Skill evals — fold in the eval job's result
<py> <audit> evals > <scratch>/evals.json
It reads the newest two aggregates the weekly eval job wrote and prints status, a pass count and delta per skill and model, and the R-44 findings: a case that passed last time and fails now is a violation on a scored tier and a consider on the advisory one. A missing, unreadable or stale aggregate is status: not-checked, and the digest says evals: not-checked, never a pass. The object also carries skills (each skill file's key → cases or no-cases), which decides R-44 per scanned skill file, overriding any worker answer: no-cases is a consider ("no evals for this skill"), cases with no usable aggregate is unmeasured (the digest is partial and the file is rescanned next run). Carry the object into run.json as "evals". Step 8.3's drift files the R-44 violations into the repo's prompt-drift issue like any judged finding. A red eval job never fails delivery; an unusable aggregate leaves the digest partial only when a scanned skill has cases, and a skill with no cases is a definite finding.
3. Rule-set update issue — a guide moved
File the rule-set delta for a human, then scan anyway against the current rules.md (Notes, #1132).
- Read each changed guide's fetched file in full, alongside
rules.mdandsources.toml. - Draft the delta: the exact new, changed or retired
R-NNblocks (same format,Why:quoting the new text,Source:with the section name), any "Recorded as rejected" entry, and the newsources.tomlbaseline values for every changed source (baseline_sha,baseline_marker,baseline_final_urlfrom itsVERDICTline, today'sbaseline_date). Anew-guideadds a[sources.*]block for the new page. Say plainly when the change is cosmetic and the rules need no edit — the new baselines alone are then the delta. - Dedupe by exact title against open issues:
An open issue titled exactlygh issue list --repo ferraroroberto/fleet-config --state open --search "prompt-audit: vendor guidance changed in:title" --json number,title,urlprompt-audit: vendor guidance changed — update rule-set→ add the draft as a comment there. None → create it (--label enhancement --assignee @me --body-file <draft>). Never both; under--dry-run, print the draft and file nothing. - Continue at step 4, carrying
update_issue: "#<N>"intorun.json(step 7). You mark nothing by hand:audit.py digest,driftandpingread theVERDICT=lines and mark each finding whose rule'sSource:cites a changed guide as provisional. Once a human merges the rule-set PR,rules.md's hash changes and the next run rescans everything.
4. Plan the scan
<py> <audit> ledger plan [--only <repo>] [--rescan-all]
PLAN=<path>|action=scan|skip|unmeasured|reason=…|sha=… per file, then LEDGER=#<n>|rubric=…|ledger_rubric=…|scan=…|skip=…|unmeasured=…. A file is skipped only when its sha matches the ledger under the same rubric; a rules.md edit (new rubric) or a missing ledger plans every file. Keep every PLAN= line.
Nothing to scan (scan=0) → skip steps 5–6; the digest still posts and lists the skipped files.
5. Lint the planned files
<py> <audit> lint --all --changed-only --detail [--only <repo>] [--rescan-all]
<py> <audit> inventory [--only <repo>]
HIT=<path>:<line>|rule=…|cap=violation|consider|count=…|text=… per candidate and HITS=<path>|audience=…|kind=…|lines=…|size=…|hits=…|neg=…|desc_words=… per file; inventory adds each file's audience and any SECTION= scoped to one vendor's agent. kind=skill-ref is a .md file a SKILL.md references (its skill-structure rules live in rules.md's ## Skill structure); only rules scoped skill-ref apply to it. GATE=<repo>|state=adopted|unknown|not_adopted|enforced=R-NN,…|baselined=N once per repo: the lint rules that repo's enabled [instruction_ratchet] fails at ship time (read from origin/<default> by skills/_lib/gate_coverage/enforced.py). For each file inside that ratchet's scope, GATE_ENFORCED=<path>|ratchet=instruction_ratchet|rules=… precedes its HITS= line and those rules' hits are already dropped; they are the gate's, not this audit's. A repo whose gate cannot be read is unknown and every rule is linted there. Judgment-tier rules are never gate-enforced. A hit is a candidate — the judgment pass confirms or rejects it. cap is the strongest verdict the rule can reach for that reader (from the rule's tag and the file's audience); a judgment never exceeds it.
6. Judgment pass
Rate gate first (every run that dispatches workers):
<py> C:/Users/rober/.claude/skills/_lib/rate_gate.py check
DECISION=OK or UNKNOWN (interactive-only: a scheduled run with no fresh signal reads PAUSE, fleet-config#825) → dispatch. PAUSE → dispatch nothing yet; wait in place against the printed WAIT_SECONDS (never RESETS_AT: only WAIT_SECONDS fits the stall watchdog, fleet-config#891) with a foreground, bounded wait (Monitor's until-loop, never a backgrounded sleep), then re-check. Cap: 3 pause cycles. Still PAUSE after the third → judge nothing: every planned file is null in judgments (unmeasured, so the digest still posts as status=partial and names them), and step 9 prints the failure marker. Record the DECISION= / REASON= / MODE= lines for the report.
Group the planned files by repo. Split fleet-config into three groups (the global file and its always-on files, skills/, .claude/skills/); repos with at most two small files may share one worker, up to eight repos per worker. Dispatch one easy-tier worker per group through the capability contract (tier intent: docs/model-tiers.md; stay within host slots and that doc's concurrency caps). No reliable spawn-and-collect → judge the groups serially in this session and say so in the report. Collect every worker's terminal result before step 7.
Brief each worker with exactly this, filled in:
Read-only task: do not edit, create, move or delete any file, and do not run git, gh or any command that changes state. Read
<absolute path of this checkout>/.claude/skills/prompt-audit/rules.mdfirst, then each file below in full. Files, with audience/kind and scoped sections:<inventory FILE= / SECTION= lines>. Lint candidates:<HIT=, HITS= and GATE_ENFORCED= lines for these files>. For every file, assess every rule whosefile:scope covers the file's kind, except the rules itsGATE_ENFORCED=line lists (the repo's gate enforces those; give them no verdict) and R-44 (the eval fold-in decides it; give it no verdict), and whose tag applies to its reader (a single-vendor rule does not apply inside a section scoped to the other vendor; a[conflict]rule applies only to neutral readers). Every lint candidate gets a verdict:violationorconsider(never stronger than itscap) when the rule'sWhy:genuinely applies,compliantwith a one-clause note when it is a false positive. Judgment rules getviolation,considerorcompliantfrom your reading; a rule you could not establish isunmeasured, nevercompliant.textis the offending line copied verbatim. Return only one fencedjsonblock: a list of{"path": "<path>", "findings": [{"rule": "R-NN", "verdict": "…", "line": <n or null>, "text": "<verbatim line or empty>", "note": "<one clause>"}]}— one object per file, every file present. List onlyviolation,considerandunmeasuredverdicts; a rule you assessed and found compliant is left out, and a file with nothing to report has"findings": [].
Validate each result: valid JSON, every briefed path present, verdicts from the allowed values. Keeping compliant verdicts out of the payload is what makes a fleet-wide result small enough to carry into run.json intact; a file's presence is what marks it judged. A missing, malformed or failed result → each of that worker's files is null (unmeasured). Never re-spawn a worker to fill a gap in an unattended run; report it.
7. Render the digest
Write <scratch>/run.json:
{
"date": "<YYYY-MM-DD>",
"dry_run": false,
"sources": ["<every VERDICT= line from steps 1-2>"],
"update_issue": null,
"coverage": ["<the coverage.json list from step 2b>"],
"leads": "<the leads.json object from step 2c, or null>",
"evals": "<the evals.json object from step 2d>",
"gate": ["<every GATE= line from step 5>"],
"scan_ran": true,
"plan": ["<every PLAN= line from step 4>"],
"judgments": {"<path>": [<findings>] }
}
update_issue is the "#<N>" from step 3 when a guide changed, else null. judgments holds each judged file's findings list, or null for an unmeasured one; a planned file left out of judgments is treated as unmeasured. Then:
<py> <audit> digest --run <scratch>/run.json > <scratch>/digest.md
The helper prints DIGEST=status=complete|partial on stderr. The digest carries status, guides, the rubric, per-source outliers, one coverage: <id> uncovered N (new M) line per tracked page (coverage: not-checked when step 2b did not run), a leads section (**Leads:** not-checked when step 2c did not run), an evals section (evals: not-checked when there is no fresh aggregate), a gate-enforced section (the repos whose instruction ratchet owns lint rules, with their baselined hits, and every unknown repo; not-checked when gate is absent), the update issue and the provisional rules when a guide changed, scanned/skipped/unmeasured counts, findings by rule, findings shared with the scaffolding master collapsed to one entry with a propagate to: list (audit.py dedup logic), repo-local findings, the unmeasured list, and the skipped list.
--dry-run → print digest.md, then <py> <audit> drift --run <scratch>/run.json --dry-run (the issue bodies that would be filed), and stop here.
8. Record and post
- Write the ledger body (creates the
prompt-audit ledgerissue, labelaudit-meta, on the first run). It records, fromrun.jsonitself, each file judged with nounmeasuredrule at itsPLAN=sha (the bytes that were actually judged); an unmeasured file or rule is left out so it is rescanned next run. Nothing is recorded when nothing was scanned. Files judged while a guide changed are recorded too: merging the rule-set PR changes the rubric, which rescans them.<py> <audit> ledger write --run <scratch>/run.json - Post the digest:
<py> <audit> ledger comment --body-file <scratch>/digest.md - File the cleanup issues:
One<py> <audit> drift --run <scratch>/run.jsonDRIFT=<repo>|issue=<url>|tier=easy|hard|none|open=N|new=…|matched=…|kept=…|not_resurfaced=…|rule_changed=…line per repo touched. Onlyviolationverdicts are filed;considerstays advisory in the digest. A violation on a rule citing a changed guide carries aProvisional:note. A line shared with the scaffolding master is filed once, onproject-scaffolding, withPropagate to:naming every sister carrying it, and is left off the sisters' issues;global-CLAUDE.mdandskills/findings file onfleet-config. Each item is tagged· easy/· hardby/cleanup-fleet's prompt-drift tier rule and the body states the issue's tier. Re-runs merge (the living-backlog rules of/codebase-auditstep 8): a ticked box is never touched, a re-matched item refreshes its line, an item for a file this run did not rescan is kept as-is, and an item gone from a rescanned file is taggednot re-surfaced, never ticked or deleted — unless it was filed under a different rubric and its file bytes have not changed (each item stampsrubric=andsha=; a legacy item falls back to the run log), when it readsrule changed(a rule change, not a fix; never invites a tick, not counted open). A repo this run had nothing new to say about is left untouched. ADRIFT=<repo>|error=…line is that repo's failure (exit 1), reported, never folded into success. <py> <audit> state mark --scan.
A failed write is reported with its error; the run does not claim delivery without the LEDGER_COMMENT= URL.
9. Delivery assertion and report
Before the report, check what this run actually delivered. Delivered means all of: a LEDGER_COMMENT= URL from step 8.2; DIGEST=status=complete; a scan (step 8.3 ran with no DRIFT=…|error= line — zero findings is still a delivery); and, when a guide changed, the rule-set update issue filed or commented (update_issue is #N). Anything else — no comment URL, a partial digest, a drift error, a changed guide with no update issue, the rate gate's pause cap — prints this literal line in the report, one reason, ASCII after the dash:
SCHEDULED-RUN-FAILED — <what was not delivered, one line>
The scheduled adapter maps that marker to exit 123; the scheduled job's delivery_check.py independently re-reads the ledger for the same facts from the digest's <!-- prompt-audit-digest … --> stamp. Never print the marker on a run that delivered, and never on --dry-run (it writes nothing by design; the job's post-condition still fails it, which is correct).
A few lines: status, guides, sources checked/not-checked, files scanned/skipped/unmeasured, violation/consider totals, the update issue (if any), the ledger comment URL, each DRIFT= line (repo, issue, tier), and step 10's PING= line.
10. Chat ping — delivered runs only
A run that step 9 found delivered posts one line to the activity-log chat. The helper renders it from run.json, so its counts match the digest, and pipes it to the fleet's one notifier. --category log resolves the chat from hooks/projects.toml; never pick a chat yourself.
<py> <audit> ping --run <scratch>/run.json --comment-url <LEDGER_COMMENT URL> | <py> hooks/notify_send.py --category log
The line is pure ASCII (fleet-config#507). Read the notifier's exit code and put exactly one of these in the report:
PING=sentwhen it exits 0.PING=not-delivered - notify_send exit <code>when it exits non-zero. The notifier never raises, so a missing token or a network failure shows up only here.PING=not-sent - run not deliveredwhen step 9 printed the failure marker, and on--dry-run(the helper refuses a dry run with exit 2).
The ping is a notice about the delivery, not part of it. A failed ping never counts as sent, and it never prints SCHEDULED-RUN-FAILED: the digest was delivered, and delivery_check.py confirms that separately from the ledger.
Notes
- Where fixes go. Violations become
prompt-driftissues, the ninth/cleanup-fleetbucket (fleet-config#833): easy-tier issues ship through/issue-yolo, hard-tier ones stop for review, and every lane must pass/context-purge's preservation harness (check.py --base). Considers are advisory and stay in the digest — the first fleet run put 152 of 255 of them on a single rule, far too noisy to become lanes. It runs weekly unattended (run-weekly.bat, an app-launcher Job slotted beforecleanup-fleet-all, #834) so the bucket is fresh when cleanup starts. - A guide change and the scan (#1132). The update issue is
enhancement, never a cleanup bucket, so a human always reviews the rule-set change. The scan always runs against the currentrules.md; the update issue is filed alongside; findings on a rule whoseSource:cites a changed guide are marked provisional in the digest and theprompt-driftbody. Delivered = a posted scan, plus the update issue when a guide changed. - Why audience, not host. The same
rules.mdruns on any agent; which vendor's rules are primary is decided by who reads the file (sources.toml[audiences.*]), so a neutral file read by several agents gets single-vendor advice asconsider, neverviolation. - Shared text is filed once. A finding whose line also sits in
project-scaffolding/CLAUDE.mdbelongs to the master, with the repos that inherited it listed — never N copies for N divergent fixes. Same forglobal-CLAUDE.mdtext that also lives in the lite port's global instructions. - Neighbouring lenses.
/context-auditmeasures size and single-home altitude;/context-purgecompresses losslessly;/sota-watchwatches adopted tooling choices. None of them reads vendor prompting guidance.