agentleFS
woyoruswoyorus/agent-skills/skills/doc-review/SKILL.md

doc-review

Skill0 starsChanged 8 months agoCC0-1.0View on GitHub

Automated Codex review loop for design proposals and implementation plans. Warms a single Codex session across iterations, applies edits directly to the doc without touching git, and converges on `VERDICT NO_MAJOR_ISSUES`. Git is only touched if the user opts in (pre-flight warning + optional single post-loop commit). Invoke as `/doc-review <doc-path> [focus]`.

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

26 rules. 0 are common, 14 are distinctive, and 12 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If a doc doesn't fit cleanly into either bucket, pass --type explicitly to pick the lens you want.

    line 35
  2. Very specific:

    All state and reports land in .codex-review/<doc-slug>/ in the working directory where Claude Code is running (not in the plugin/skill …

    line 37
  3. Distinctive:

    The sidecar NEVER touches git: No stage, no commit, no diff, no show.

    line 41
  4. Very specific:

    Pre-flight (Step 0): if <doc-path> has uncommitted changes going into the review, warn the user and offer to commit them first — so the …

    line 43
  5. Distinctive:

    Post-loop (Step 4): after the loop exits, ask the user whether to stage and commit the accumulated doc edits as a single commit.

    line 44
  6. Distinctive:

    If the user declines either prompt, the skill proceeds without touching git.

    line 45
  7. Distinctive:

    If the working directory is not a git repo, both prompts are skipped silently.

    line 46
  8. Distinctive:

    Before invoking the sidecar for iteration 1 (skip entirely on resume — pre-flight was handled on the original run):

    line 66
  9. Distinctive:

    If not inside a git repo (git rev-parse --is-inside-work-tree fails), skip this step silently.

    line 68
  10. Distinctive:

    If the doc is dirty (staged or unstaged changes), tell the user:

    line 70
  11. Very specific:

    If other unrelated paths are dirty in the working tree, ignore them — this step cares only about <doc-path>.

    line 76
  12. Very specific:

    If invoked with --status, run node ...

    line 80
  13. Very specific:

    If invoked with --reset, run node ...

    line 81
  14. Very specific:

    If state.json already exists for this doc and --reset was not used, announce "Resuming from iteration <last-completed + 1>." Skip Step 0.

    line 83
  15. Distinctive:

    Read only the affected sections of the doc itself to confirm the finding makes sense.

    line 117
  16. Distinctive:

    If a finding is clearly wrong (e.g., names a function that doesn't exist and the recommendation depends on it existing), reject it and …

    line 121
  17. Distinctive:

    Do not expand scope, refactor unrelated sections, or rewrite the doc from scratch.

    line 126
  18. Very specific:

    If you made no edits this round (every finding was a nit or rejected), pass --no-changes (and optionally a --note="..." describing why).

    line 137
  19. Distinctive:

    Keep notes tight and user-facing — they get printed verbatim in the final report.

    line 139
  20. Very specific:

    If the sidecar reported converged: true → go to Step 3 with reason converged.

    line 149
  21. Very specific:

    If iter >= max → go to Step 3 with reason cap-hit.

    line 150
  22. Distinctive:

    Keep each line to one sentence.

    line 182
  23. Distinctive:

    If not a git repo, or the doc has no unstaged edits (e.g., the loop made zero changes), skip the commit prompt.

    line 191
  24. Distinctive:

    Never begin implementation: after the loop. The output is an improved doc.

    line 207
  25. Very specific:

    If codex is not available or returns auth errors, tell the user to run codex login or /codex:setup and stop.

    line 210
  26. Very specific:

    Pre-flight commit conflicts: if Step 0's commit fails (e.g., a pre-commit hook rejects it), surface the error and stop — let the user …

    line 217

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Doc Review Loop

FOR CLAUDE CODE ONLY. Automate the iterative review workflow for markdown design docs and implementation plans. A sidecar CLI owns the Codex session lifecycle and state; this skill drives the loop, classifies findings, edits the doc, and handles the two optional git touch-points (pre-flight warn, post-loop single commit). The sidecar itself never runs git commands that mutate state.

Invocation

/doc-review <doc-path> [focus phrase...]
/doc-review --type=plan|design <doc-path>
/doc-review --max=N <doc-path>
/doc-review --timeout=<minutes> <doc-path>
/doc-review --resume <doc-path>       # default behavior when state already exists
/doc-review --reset <doc-path>        # archive prior loop and start fresh
/doc-review --status <doc-path>       # print state.json and exit, no iteration
  • <doc-path> (required): path to the markdown file. If missing, stop immediately and ask the user to provide it — never guess.
  • --type=<plan|design> (optional): selects the review lens. Auto-detects from path when omitted — common conventions like /plans/ are treated as plan; /design-docs/, /design/, /proposals/ as design; fallback is plan. Pass explicitly when the project uses different conventions or when the heuristic is likely wrong for this doc.
  • --max=N (optional): hard iteration cap. Default 6. Maximum 10. Sidecar refuses further iterations past the cap.
  • --timeout=<minutes> (optional): per-iteration Codex timeout. Default 20. Max 60. Bump when reviewing dense plans; xhigh review of a big plan can take longer.
  • Remaining text (optional): focus comment passed to every iteration (e.g., "pay attention to error handling around retries").

Review lens: design doc vs. implementation plan

The two doc types get meaningfully different prompts:

  • Design doc (principles, UX, architecture): review lens is coherence and cross-doc referential integrity. Codex verifies citations against the docs they point at, checks that illustrated flows map cleanly to the named decisions, and flags unacknowledged trade-offs, blurry scope boundaries, and over-specification that leaks code-level detail belonging in a plan.
  • Implementation plan (concrete work for a coding agent): review lens is claim accuracy against the actual code. Codex opens the source files the plan names and verifies every function / type / column / config reference; checks step ordering and commit boundaries; validates the testing strategy against whatever testing conventions the project encodes; and flags ambiguities a fresh coding agent would resolve wrong.

If a doc doesn't fit cleanly into either bucket, pass --type explicitly to pick the lens you want.

All state and reports land in .codex-review/<doc-slug>/ in the working directory where Claude Code is running (not in the plugin/skill directory). The sidecar adds .codex-review/ to .gitignore on first run if not present.

Git discipline

  • The sidecar NEVER touches git. No stage, no commit, no diff, no show. The review loop is a pure sequence of doc edits.
  • Git is touched only at two optional user-consented points, both driven by this skill via plain Bash git calls:
    1. Pre-flight (Step 0): if <doc-path> has uncommitted changes going into the review, warn the user and offer to commit them first — so the review's edits can be cleanly reviewed as a separate diff at the end.
    2. Post-loop (Step 4): after the loop exits, ask the user whether to stage and commit the accumulated doc edits as a single commit.
  • If the user declines either prompt, the skill proceeds without touching git. The doc ends the loop with whatever uncommitted edits the review applied — the user reviews and commits on their own time.
  • If the working directory is not a git repo, both prompts are skipped silently.

Sidecar CLI

The sidecar lives at ${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs — invoke it via node. It is pure plumbing: it owns the Codex process lifecycle, session-id capture, prompt substitution, and state persistence. It does not reason about findings — that's this skill's job — and it does not touch git.

node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" status            <doc-path>
node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" next              <doc-path> [--max=N] [--timeout=<minutes>] [--effort=xhigh] [--model=gpt-5.4] [--focus="..."]
node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" record-iteration  <doc-path> --note="<one-line summary>" [--no-changes]
node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" finish            <doc-path> --reason=converged|cap-hit|aborted
node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" reset             <doc-path>

next prints a single JSON line on stdout with the fields {iter, report_path, status_path, converged, blocking_count, total_count, verdict}. Parse it and act on verdict / converged. Exit code is non-zero if Codex errored — read the printed hint (e.g., "run codex login") and stop.

Execution contract

Step 0 — Pre-flight git check

Before invoking the sidecar for iteration 1 (skip entirely on resume — pre-flight was handled on the original run):

  1. If not inside a git repo (git rev-parse --is-inside-work-tree fails), skip this step silently.
  2. Otherwise, run git status --porcelain -- <doc-path>. If the output is empty, skip.
  3. If the doc is dirty (staged or unstaged changes), tell the user:

    <doc-path> has uncommitted changes. Committing them first keeps the review's edits reviewable as a separate diff. Options: yes (I commit them now), no (proceed with them included — review edits will mix with your existing changes), abort.

  4. On yes: stage only <doc-path>, commit with message pre-doc-review: save existing edits to <doc-slug> + Claude co-author footer. Confirm the SHA to the user, then proceed.
  5. On no: proceed.
  6. On abort: stop; do not initialize the loop.

If other unrelated paths are dirty in the working tree, ignore them — this step cares only about <doc-path>.

Step 1 — Initialize

  1. If invoked with --status, run node ... status <doc-path>, print the JSON, stop.
  2. If invoked with --reset, run node ... reset <doc-path> first, then proceed with a fresh loop (re-run Step 0).
  3. Announce to the user: "Starting /doc-review on <doc-path> — max=N iterations, focus=<focus or 'none'>. State and reports: .codex-review/<doc-slug>/."
  4. If state.json already exists for this doc and --reset was not used, announce "Resuming from iteration <last-completed + 1>." Skip Step 0.

Step 2 — Review loop

Repeat until a stop condition fires. For each iteration:

2a. Call the sidecar to run Codex

node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" next <doc-path> [--max=N] [--focus="..."]
  • Iteration 1: the sidecar runs codex exec --json --output-last-message iter-1-report.md -m gpt-5.4 -c model_reasoning_effort=xhigh "<initial-prompt>" and captures the session id from the JSONL event stream.
  • Iteration N>1: the sidecar runs codex exec resume <session-id> --json --output-last-message iter-N-report.md -m gpt-5.4 -c model_reasoning_effort=xhigh "<followup-prompt>", reusing the same Codex thread (warm context). The followup prompt tells Codex the doc was revised and to re-read it with fresh eyes — Codex uses its warm-context memory of the prior version to spot what changed. No diffs or snapshots are fed in.

Tell the user: "Iteration N — Codex running (warm context, session <id-prefix>)…"

Timeout per iteration is 20 minutes (override with --timeout=<minutes>, hard cap 60). On timeout the sidecar leaves pending_iter set and the session resumable — re-run next to retry.

2b. Read the report

Open .codex-review/<slug>/iter-N-report.md. It contains Codex's full review followed by a single VERDICT: line (NO_MAJOR_ISSUES or ISSUES_REMAIN). The sidecar already parsed the verdict and reported it in the JSON stdout — trust that for loop control, but read the report for the findings.

2c. Classify findings

For each finding in the report:

  • Blocking: critical or high severity — logical errors, incorrect file/API references, missing steps, architectural issues, dangerous ambiguity.
  • Nit: medium or low severity — wording tweaks, style preferences, optional enhancements. Default to skip; note them in the per-iteration report for the user.

2d. Validation discipline (lightweight)

For each blocking finding:

  • Read only the affected sections of the doc itself to confirm the finding makes sense.
  • Spot-check one or two source-code references only if a finding looks self-contradictory, names a surprising path/function, or contradicts your prior knowledge of the code.
  • Trust the rest — Codex was run with xhigh effort and the rigorous prompt. Exhaustively re-verifying every finding is the credit-burning anti-pattern this skill is meant to avoid.

If a finding is clearly wrong (e.g., names a function that doesn't exist and the recommendation depends on it existing), reject it and record the one-line reason.

2e. Apply fixes

  • One Edit per finding, scoped to the flagged section.
  • Do not expand scope, refactor unrelated sections, or rewrite the doc from scratch.
  • Preserve the doc's existing format and structure.

2f. Record the iteration

node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" record-iteration <doc-path> --note="<2-line summary of what changed this round>"

The sidecar writes iter-N-applied.md with the note and appends the note to state.iter_notes. No staging, no commit, no git interaction.

If you made no edits this round (every finding was a nit or rejected), pass --no-changes (and optionally a --note="..." describing why). The sidecar records that no edits happened — the next iteration's prompt will reflect this.

Keep notes tight and user-facing — they get printed verbatim in the final report.

2g. Report inline to the user

One compact line:

Iteration N: M findings → A applied, S skipped (nits), R rejected (reason). Verdict: NO_MAJOR_ISSUES | ISSUES_REMAIN.

2h. Iterate or stop

  • If the sidecar reported converged: true → go to Step 3 with reason converged.
  • If iter >= max → go to Step 3 with reason cap-hit.
  • Else → back to 2a.

Step 3 — Finalize sidecar state

node "${CLAUDE_PLUGIN_ROOT}/scripts/doc-review.mjs" finish <doc-path> --reason=converged|cap-hit|aborted

The sidecar writes .codex-review/<slug>/final-summary.md aggregating: doc path, iterations run, terminal reason, per-iteration applied notes, last Codex verdict, any remaining medium/low findings worth considering.

Step 4 — Report to the user and offer commit

Print a compact report to chat in this shape (adapt to actual findings; keep it tight):

Doc review on <doc-path>: <status> after N/M iterations.

Per-iteration findings:
- iter 1: <one-line summary of blocking findings>.
- iter 2: <one-line summary>.
- ...
- iter N: <one-line summary OR "clean — VERDICT: NO_MAJOR_ISSUES">.

Edits applied:
- iter 1: <note from record-iteration>.
- iter 2: <note>.
- ...

Full reports: <final-summary-path>

Keep each line to one sentence. The user reads this to quickly sanity-check whether anything went off the rails — do not include raw severity counts, Codex quotes, or long excerpts.

Then, if inside a git repo and the doc has unstaged edits (git status --porcelain -- <doc-path> non-empty), ask:

Doc review made edits across N iterations, currently uncommitted. Commit as a single commit? Options: yes (stage and commit <doc-path> only, message: doc-review: <terminal-reason> after N iterations (<doc-slug>)), no (leave uncommitted for you to review/stage manually).

  • On yes: git add -- <doc-path>, git commit -m "<message with Claude co-author footer>", confirm SHA to user.
  • On no: print the exact command the user can run themselves and stop.

If not a git repo, or the doc has no unstaged edits (e.g., the loop made zero changes), skip the commit prompt.

Do NOT begin implementation. The terminal state is "doc is ready for your review."

Stop conditions (any one triggers terminal state)

  • Codex returns VERDICT: NO_MAJOR_ISSUES.
  • iter == max (default 6).
  • Sidecar reports an unrecoverable error after one retry (e.g., codex auth dead, disk full).
  • User Ctrl-C — state survives, next /doc-review <same-path> resumes from the last completed iteration without re-running it.

Important constraints

  • Codex never edits the doc. The sidecar does not pass --write or --dangerously-bypass-approvals-and-sandbox. All edits happen via Claude Code's Edit tool — the human-in-the-loop safety net against Codex hallucination.
  • Sidecar never touches git. Git is only touched via explicit Bash calls in Step 0 and Step 4, with user consent each time.
  • Never rewrite the doc from scratch. Each iteration makes targeted, validated fixes to flagged sections only.
  • Never begin implementation after the loop. The output is an improved doc.
  • Always verify a blocking finding before applying it if the recommendation names a surprising path/function or contradicts your prior knowledge — but do not exhaustively second-guess every finding.
  • State lives in the CWD, not the skill. .codex-review/<slug>/ is written relative to the working directory Claude Code was launched in. The sidecar refuses to write outside CWD.
  • If codex is not available or returns auth errors, tell the user to run codex login or /codex:setup and stop.

Troubleshooting

  • "state dir locked": another doc-review next is running on the same doc. Wait or inspect .codex-review/<slug>/.lock.
  • Resume after crash: just re-run /doc-review <same-doc-path>. The sidecar detects dirty state, re-runs the incomplete iteration cleanly using the stored session id (no fresh thread, no re-exploration).
  • Session id missing: rare; sidecar falls back to scanning ~/.codex/sessions/ for the newest file written during the run. If still missing, reset and start a fresh session.
  • Pre-flight commit conflicts: if Step 0's commit fails (e.g., a pre-commit hook rejects it), surface the error and stop — let the user resolve before re-running /doc-review. Don't bypass hooks.
  • Post-loop commit conflicts: same — if the final commit fails, tell the user and leave the doc edits in place. Don't retry destructively.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.