| name | necessity-audit |
| description | Necessity audit for over-designed spec elements. Use when: auditing lifecycle spec (1-requirements / 2-tech-spec / 3-architecture) for YAGNI/KISS violations, challenging necessity of FRs/NFRs/abstractions/configs via Codex adversarial debate. Not for: FP reasoning validity (use /codex-review-spec), completeness check (use /feature-completeness), detail review (use /codex-review-doc), or code-level simplification (use /simplify). |
| allowed-tools | Read, Grep, Glob, Write, Bash(node:*), Bash(mktemp:*), mcp__codex__codex-reply, Skill |
Necessity Audit
3-phase necessity audit with Codex adversarial debate. Identifies over-designed elements in lifecycle specs via 6-dimension YAGNI rubric.
Non-Negotiable Rules
SKILL.md is the normative source. Reference files elaborate but do not override.
| # | Rule | Violation = |
|---|
| 1 | Phase A classification output must NOT appear in Phase B debate topic | Audit invalid |
| 2 | Phase B must invoke /codex-brainstorm via Skill tool โ raw mcp__codex__codex for debate is invalid | Audit invalid |
| 3 | Phase C report must include non-empty debate.threadId | Report rejected |
| 4 | Phase C report must include Debate Conclusion referencing specific rounds (not blank / placeholder) | Report rejected |
| 5 | Output must start with ## Necessity Audit header and end with โ
Audit Clear OR โ Audit Revise sentinel | Auto-loop cannot parse |
Trigger
- Keywords: necessity audit, over-design, YAGNI audit, spec necessity, ้ๅบฆ่จญ่จ, over-engineered
When NOT to Use
Alternatives by intent
| Intent | Use | Not this skill |
|---|
| ใ้ๆฎตๆจ็็ซๅพไฝๅ๏ผใ | /codex-review-spec (planned) / /review-spec | โ |
| ใ้ๅ spec ๅฎๆไบๅ๏ผใ | /feature-completeness (planned) | โ |
| ใ้ๅ code ๆฏๅฆ้ๅบฆๆฝ่ฑก๏ผใ | /simplify / /refactor | โ |
| ใ้ๅๅฏฆไฝ็ฌฆๅ็ขๆฅญๆจๆบๅ๏ผใ | /best-practices | โ |
| ใ้ๅ spec ๆฏๅฆ้ๅบฆ่จญ่จ๏ผ้่ฆ็ ๅ๏ผใ | /necessity-audit โ this skill | โ |
Chain recommendation
/codex-review-doc (detail) โ /codex-review-spec (reasoning, planned) โ /necessity-audit (necessity, this skill) โ /feature-completeness (completeness, planned) โ /review-spec (synthesis)
Arguments
| Arg | Required | Default | Purpose |
|---|
<path> | Yes | โ | Target lifecycle spec (repo-relative) |
--depth brief|normal|deep | No | normal | Dimension coverage + equilibrium strictness |
--continue <threadId> | No | โ | Resume Phase C via mcp__codex__codex-reply |
--skip-preflight | No | false | Skip state-read advisory; emits [PREFLIGHT SKIPPED] banner |
--include-feasibility | No | false | Accept 0-feasibility-study.md (emits override banner) |
--override <id>:<rationale> | No (repeatable, ;-separated) | โ | Mark Cut element as kept with justification |
--output markdown|json | No | markdown | Output format |
Workflow
Phase 0 preflight โ Phase A classify โ Phase B Codex debate โ Phase C consolidate โ Redact โ Emit
Phase 0: Preflight (executable)
Scratch directory โ read this before running any step. Each Bash invocation is a fresh
shell: a variable assigned in one step does not exist in the next. Do not write
TMPDIR=$(mktemp -d) and then reference $TMPDIR later โ on macOS TMPDIR is an ambient
variable already pointing at the shared temp root (/var/folders/โฆ/T/), so later steps silently
read and write there, and the final rm -rf $TMPDIR would target that shared root.
Instead: run mktemp -d once, read the path it prints, and substitute that literal
absolute path into every later command. The placeholder <AUDIT_TMP_DIR> below marks each
substitution site. Never name the variable TMPDIR.
mktemp -d
Immediately claim it. The claim mints a one-time capability token and stores it in a marker
inside the directory; the cleanup step requires that exact token back. This is what binds the
delete to this run's directory rather than to any directory that merely looks like one โ or to
another concurrent audit's directory, which also carries a valid marker:
node scripts/skills/necessity-audit/cleanup.js --claim "<AUDIT_TMP_DIR>"
Read the token= line it prints and carry that literal value to the cleanup step, the same way you
carry the directory path. Like <AUDIT_TMP_DIR>, it cannot be held in a shell variable โ each Bash
invocation is a fresh shell.
node scripts/skills/necessity-audit/preflight.js \
--path <path> --depth <depth> \
[--skip-preflight] [--include-feasibility] \
--output "<AUDIT_TMP_DIR>/preflight.json"
Non-zero exit = hard block. Read <AUDIT_TMP_DIR>/preflight.json to continue.
Phase A: Claude classify (LLM)
Read target file with Read tool. Apply references/phase-a-classify.md template substituting ${TARGET_PATH}, ${DOC_KIND}, ${ACTIVE_DIMENSIONS}, ${GREENFIELD} from preflight.
Extract elements (FR / NFR / Component / Abstraction / Extensibility / Config), score each against active dimensions only (depth=brief โ dims 1-3; normal/deep โ dims 1-6), assign initial Keep/Review/Cut.
Write result: Write tool โ <AUDIT_TMP_DIR>/phase-a.json with schema { elements: ClassifiedElement[] } (only claude.* fields populated).
Phase B: Codex debate (Skill invocation)
node scripts/skills/necessity-audit/debate-topic.js build \
--preflight "<AUDIT_TMP_DIR>/preflight.json" \
--output "<AUDIT_TMP_DIR>/topic.txt"
Read topic, invoke:
Skill("codex-brainstorm", <contents of <AUDIT_TMP_DIR>/topic.txt>)
Write raw response: Write tool โ <AUDIT_TMP_DIR>/debate.txt.
node scripts/skills/necessity-audit/debate-topic.js parse \
--input "<AUDIT_TMP_DIR>/debate.txt" \
--output "<AUDIT_TMP_DIR>/debate.json"
Phase C: Consolidate (executable)
node scripts/skills/necessity-audit/consolidate.js \
--phase-a "<AUDIT_TMP_DIR>/phase-a.json" \
--debate "<AUDIT_TMP_DIR>/debate.json" \
--preflight "<AUDIT_TMP_DIR>/preflight.json" \
--overrides "<id>:<rationale>[;...]" \
--depth <depth> \
--output "<AUDIT_TMP_DIR>/report.json"
Applies 6 deterministic checks, under-coverage check, --override handling, gate selection.
Assemble + Redact + Emit
node scripts/skills/necessity-audit/report.js \
--input "<AUDIT_TMP_DIR>/report.json" \
--format markdown \
--output "<AUDIT_TMP_DIR>/report.md"
node scripts/skills/necessity-audit/redact.js \
--input "<AUDIT_TMP_DIR>/report.md" \
--output "<AUDIT_TMP_DIR>/report.final.md"
Read <AUDIT_TMP_DIR>/report.final.md and emit as final user-visible message.
Cleanup. The path condition is enforced by the script, not by this paragraph. It refuses
(exit 1, deleting nothing) on an unsubstituted placeholder, a relative path, a symlink, a
non-directory, the filesystem root, anything that is not a direct child of this process's temp root
โ in particular the shared temp root itself, the path an ambient-TMPDIR mistake produces โ any
directory carrying no --claim marker, and, decisively, any directory whose marker was minted
with a different token. That last check is what rules out a substitution naming a different,
equally valid-looking scratch directory: shape is common to all of them and so is the marker, since
every concurrent audit claims its own โ only the token is unique to this run. Removal is idempotent,
so re-running after a partial failure is safe:
node scripts/skills/necessity-audit/cleanup.js --dir "<AUDIT_TMP_DIR>" --token "<AUDIT_TOKEN>"
Before running it, re-read the path you are substituting and confirm it is the exact absolute
path Phase 0 printed. The guard refuses a wrong one, but a refusal is a stalled cleanup โ getting
the substitution right is still your job. If the guard does refuse, do not work around it with a
manual rm: fix the substitution.
Output Format + Gate Selection
Output header, sections, sentinel: see references/output-template.md (normative).
Gate-selection decision table + narrative rules: see references/phase-c-consolidate.md.
Invariant: โ ๏ธ Need Human NEVER appears as the final gate โ only as a narrative line above the โ
Audit Clear / โ Audit Revise sentinel.
Review Loop (--continue)
After user revises the spec, re-run with --continue <threadId> to reuse the Codex debate context via mcp__codex__codex-reply. See references/review-loop.md.
References
references/dimensions.md โ 6-dimension ร 4-tier rubric (authoritative)
references/phase-a-classify.md โ Phase A prompt template
references/phase-b-debate-topic.md โ Phase B topic builder documentation
references/phase-c-consolidate.md โ Phase C logic
references/output-template.md โ Markdown report layout
references/review-loop.md โ --continue flow
references/redaction-rules.md โ Secret / PII patterns applied by redact.js
Verification
Examples
Input: /necessity-audit docs/features/foo/2-tech-spec.md
Action: Phase 0 preflight โ Phase A classify โ Phase B debate โ Phase C consolidate โ report + redact โ emit with sentinel
Input: /necessity-audit docs/features/foo/2-tech-spec.md --continue 019dab42-xxxx
Action: Resume via codex-reply; re-run Phase C with updated spec; emit diff-focused report
Input: /necessity-audit docs/features/foo/1-requirements.md --depth brief --skip-preflight
Action: Only challenge dims 1-3; skip state advisory; emit [PREFLIGHT SKIPPED] banner
Input: /necessity-audit docs/features/foo/2-tech-spec.md --override FR-12:"needed for Q3 rollout"
Action: FR-12 kept with justification; final gate โ
Audit Clear if no other Cut items remain