Run a deep, adversarial audit of the current codebase. This is not the
mechanical verify/drift check — those confirm paths exist. This hunts for
defects those checks categorically cannot catch: places where the code's
actual behavior no longer matches what the code, comments, or docs say it
does, or where a change elsewhere in the repo silently broke an assumption
made here.
Read-only. Do not edit any file other than the report this command writes.
Full-repo scope every run — do not sample or skip areas because they seem
stable; staleness hides exactly where nobody looked recently.
What to hunt for
- Stale cross-references — comments, docstrings, or user-facing strings
describing behavior a later change invalidated. Search for "never",
"always", "not yet available", "no writes unless X", "once available",
TODO, and version/feature gates — then verify the referenced behavior
against the current code, not what was true when the comment was written.
- Unquoted/unescaped interpolation — any generated shell command, CLI
suggestion, file path, or subprocess argument built by string concatenation
or a template literal without quoting/escaping. Check every subprocess
spawn/exec call and every "here's the command to run" string for inputs
that could contain spaces or shell metacharacters.
- Platform-specific gaps — subprocess calls or path handling that assume
POSIX (missing a shell flag for
.cmd-shimmed binaries on Windows,
hardcoded path separators, case-sensitivity assumptions). Flag anything
that has never actually been exercised cross-platform.
- Ownership conflicts on generated files — any file written by more than
one code path (scaffolded once, then continuously regenerated by a live
process). Check whether "protect user edits" / backup / diffing logic
correctly distinguishes "changed because it's supposed to" from "changed
because a human edited it."
- Mechanical vs. semantic validation gaps — places where an automated
check only confirms a path or reference exists, not that the prose
describing it is still accurate. List every place documentation makes a
factual claim about code behavior and check it against the current
implementation.
- Cross-module consistency after incremental changes — for every
function or module that references another component's state, existence,
or capabilities, confirm that reference is re-validated, not assumed from
when it was first written.
Method
- Locate code via
ai/guide/MODULE_MAP.md first; don't crawl the whole tree
blind.
- For any suspicious claim, reproduce it — run the command, exercise the code
path, or trace the call — rather than reasoning from the source alone.
Findings that were actually reproduced should say so explicitly.
- Prefer depth over coverage: a handful of concrete, reproducible defects
beats a long list of speculative ones.
- Before opening a finding, check
ai/analysis/audit-reports/DEFECT_TRACEABILITY.md
for a prior audit row at the same location — don't re-report something
already FIXED or tracked OPEN.
Output
Append a new dated audit section to
ai/analysis/audit-reports/DEFECT_TRACEABILITY.md (create it, following its
existing row format, if this is the first audit) with one row per finding —
ID, severity, status (OPEN until fixed), location, defect, root cause,
trace — and write the full evidence/repro for each finding to
ai/analysis/audit-reports/ADVERSARIAL_AUDIT_<YYYY-MM-DD>.md, tagged
[inferred] until a human reviews them. One line per finding in the summary:
path:line — issue — concrete failure scenario — suggested fix
Order most-severe first. No architecture summary, no restating what the code
does — only defects and risks with evidence.
Then report the finding count and the top 3 by severity directly to the user.
What this does NOT do
- Does not fix anything — that is a separate, explicit follow-up task the
user asks for after reviewing the report (typically via
/fix-bug).
- Does not replace
verify/drift (mechanical path checks) or
review-agent-config (CLAUDE.md/AGENTS.md structure) — this is
deliberately the one check in the kit that requires judgement instead of a
deterministic script.
- Not a CI gate: it is non-deterministic and costly. Run it periodically
(before a release, after a large refactor), not on every push.
1---2name: adversarial-audit3description: Deep, judgement-based adversarial code audit — hunts for stale cross-references, unescaped interpolation, platform gaps, generated-file ownership conflicts, and cross-module consistency rot that no mechanical check can catch. Read-only; writes a dated findings report.4---5<!-- Copyright (c) 2026 Kunal Suri (CEA LIST). All rights reserved. -->67Run a deep, adversarial audit of the current codebase. This is not the8mechanical `verify`/`drift` check — those confirm paths exist. This hunts for9defects those checks categorically cannot catch: places where the code's10actual behavior no longer matches what the code, comments, or docs *say* it11does, or where a change elsewhere in the repo silently broke an assumption12made here.1314Read-only. Do not edit any file other than the report this command writes.15Full-repo scope every run — do not sample or skip areas because they seem16stable; staleness hides exactly where nobody looked recently.1718## What to hunt for19201. **Stale cross-references** — comments, docstrings, or user-facing strings21 describing behavior a *later* change invalidated. Search for "never",22 "always", "not yet available", "no writes unless X", "once available",23 `TODO`, and version/feature gates — then verify the referenced behavior24 against the *current* code, not what was true when the comment was written.252. **Unquoted/unescaped interpolation** — any generated shell command, CLI26 suggestion, file path, or subprocess argument built by string concatenation27 or a template literal without quoting/escaping. Check every subprocess28 spawn/exec call and every "here's the command to run" string for inputs29 that could contain spaces or shell metacharacters.303. **Platform-specific gaps** — subprocess calls or path handling that assume31 POSIX (missing a shell flag for `.cmd`-shimmed binaries on Windows,32 hardcoded path separators, case-sensitivity assumptions). Flag anything33 that has never actually been exercised cross-platform.344. **Ownership conflicts on generated files** — any file written by more than35 one code path (scaffolded once, then continuously regenerated by a live36 process). Check whether "protect user edits" / backup / diffing logic37 correctly distinguishes "changed because it's supposed to" from "changed38 because a human edited it."395. **Mechanical vs. semantic validation gaps** — places where an automated40 check only confirms a path or reference *exists*, not that the prose41 describing it is still accurate. List every place documentation makes a42 factual claim about code behavior and check it against the current43 implementation.446. **Cross-module consistency after incremental changes** — for every45 function or module that references another component's state, existence,46 or capabilities, confirm that reference is re-validated, not assumed from47 when it was first written.4849## Method50- Locate code via `ai/guide/MODULE_MAP.md` first; don't crawl the whole tree51 blind.52- For any suspicious claim, reproduce it — run the command, exercise the code53 path, or trace the call — rather than reasoning from the source alone.54 Findings that were actually reproduced should say so explicitly.55- Prefer depth over coverage: a handful of concrete, reproducible defects56 beats a long list of speculative ones.57- Before opening a finding, check `ai/analysis/audit-reports/DEFECT_TRACEABILITY.md`58 for a prior audit row at the same location — don't re-report something59 already `FIXED` or tracked `OPEN`.6061## Output62Append a new dated audit section to63`ai/analysis/audit-reports/DEFECT_TRACEABILITY.md` (create it, following its64existing row format, if this is the first audit) with one row per finding —65ID, severity, status (`OPEN` until fixed), location, defect, root cause,66trace — and write the full evidence/repro for each finding to67`ai/analysis/audit-reports/ADVERSARIAL_AUDIT_<YYYY-MM-DD>.md`, tagged68`[inferred]` until a human reviews them. One line per finding in the summary:6970`path:line — issue — concrete failure scenario — suggested fix`7172Order most-severe first. No architecture summary, no restating what the code73does — only defects and risks with evidence.7475Then report the finding count and the top 3 by severity directly to the user.7677## What this does NOT do78- Does not fix anything — that is a separate, explicit follow-up task the79 user asks for after reviewing the report (typically via `/fix-bug`).80- Does not replace `verify`/`drift` (mechanical path checks) or81 `review-agent-config` (`CLAUDE.md`/`AGENTS.md` structure) — this is82 deliberately the one check in the kit that requires judgement instead of a83 deterministic script.84- Not a CI gate: it is non-deterministic and costly. Run it periodically85 (before a release, after a large refactor), not on every push.