

























@@ -0,0 +1,128 @@
1+---
2+name: autoreview
3+description: "Autoreview closeout: local dirty changes, PR branch vs main, parallel tests."
4+---
5+6+# Autoreview
7+8+Run Codex's built-in code review as a closeout check. This is code review (`codex review`), not Guardian `auto_review` approval routing.
9+10+Use when:
11+- user asks for Codex review / autoreview / second-model review
12+- after non-trivial code edits, before final/commit/ship
13+- reviewing a local branch or PR branch after fixes
14+15+## Contract
16+17+- Treat review output as advisory. Never blindly apply it.
18+- Verify every finding by reading the real code path and adjacent files.
19+- Read dependency docs/source/types when the finding depends on external behavior.
20+- Reject unrealistic edge cases, speculative risks, broad rewrites, and fixes that over-complicate the codebase.
21+- Prefer small fixes at the right ownership boundary; no refactor unless it clearly improves the bug class.
22+- Keep going until the selected review path returns no accepted/actionable findings.
23+- If a review-triggered fix changes code, rerun focused tests and rerun the review helper.
24+- Default to Codex review. If Codex is unavailable or exits with an error, the helper may fall back to `claude -p`; `pi -p` and `opencode run` are explicit reviewer/fallback options. The helper runs nested Codex review in yolo/full-access mode by default; use `--no-yolo` only when intentionally testing sandbox behavior.
25+- Stop as soon as the review command/helper exits 0 with no accepted/actionable findings. Do not run an extra direct `codex review` just to get a nicer "clean" line, a second opinion, or clearer closeout wording.
26+- Treat the helper's successful exit plus absence of actionable findings as the clean review result, even if the underlying Codex CLI output is terse.
27+- If rejecting a finding as intentional/not worth fixing, add a brief inline code comment only when it explains a real invariant or ownership decision that future reviewers should know.
28+- Do not push just to review. Push only when the user requested push/ship/PR update.
29+30+## Pick Target
31+32+Dirty local work:
33+34+```bash
35+codex review --uncommitted
36+```
37+38+Use this only when the patch is actually unstaged/staged/untracked in the
39+current checkout. For committed, pushed, or PR work, point Codex at the commit
40+or branch diff instead; do not force `--mode local` / `--uncommitted` just
41+because the helper docs mention dirty work first. A clean `--uncommitted` review
42+only proves there is no local patch.
43+44+Branch/PR work:
45+46+```bash
47+git fetch origin
48+codex review --base origin/main
49+```
50+51+Do not pass an inline prompt with `--base`; current CLI rejects `--base` + `[PROMPT]` even though help text is ambiguous. If custom instructions are needed, run the plain base review first, then do a local/manual follow-up pass.
52+53+If an open PR exists, use its actual base:
54+55+```bash
56+base=$(gh pr view --json baseRefName --jq .baseRefName)
57+codex review --base "origin/$base"
58+```
59+60+Committed single change:
61+62+```bash
63+codex review --commit HEAD
64+```
65+66+or with the helper:
67+68+```bash
69+.agents/skills/autoreview/scripts/autoreview --mode commit --commit HEAD
70+```
71+72+Use commit review for already-landed or already-pushed work on `main`. Reviewing
73+clean `main` against `origin/main` is usually an empty diff after push. For a
74+small stack, review each commit explicitly or review the branch before merging
75+with `--base`.
76+77+## Parallel Closeout
78+79+Format first if formatting can change line locations. Then it is OK to run tests and review in parallel:
80+81+```bash
82+.agents/skills/autoreview/scripts/autoreview --parallel-tests "<focused test command>"
83+```
84+85+Tradeoff: tests may force code changes that stale the review. If tests or review lead to code edits, rerun the affected tests and rerun review until no accepted/actionable findings remain. Once that rerun exits cleanly, stop; do not spend another long review cycle on redundant confirmation.
86+87+## Context Efficiency
88+89+Codex review is usually noisy. Default to a subagent filter when subagents are available. Ask it to run the review and return only:
90+- actionable findings it accepts
91+- findings it rejects, with one-line reason
92+- exact files/tests to rerun
93+94+Run inline only for tiny changes or when subagents are unavailable.
95+96+## Helper
97+98+Bundled helper:
99+100+```bash
101+.agents/skills/autoreview/scripts/autoreview --help
102+```
103+104+The helper:
105+- chooses dirty `--uncommitted` first
106+- otherwise uses current PR base if `gh pr view` works
107+- otherwise uses `origin/main` for non-main branches
108+- use `--mode commit --commit <ref>` for already-committed work, especially clean `main` after landing
109+- should be left in `--mode auto` or forced to `--mode branch` for PR/branch work; do not force `--mode local` after committing
110+- supports `--reviewer codex|claude|pi|opencode|auto`; `auto` runs Codex first
111+- supports `--fallback-reviewer claude|pi|opencode|none`; default is `claude`
112+- falls back only when Codex is unavailable or exits nonzero, not when Codex reports findings
113+- writes only to stdout unless `--output` or `AUTOREVIEW_OUTPUT` is set
114+- supports `--dry-run`, `--parallel-tests`, and commit refs
115+- runs nested review with `--dangerously-bypass-approvals-and-sandbox` by default
116+- keeps accepting `--full-access`; use `--no-yolo` or `AUTOREVIEW_YOLO=0` to opt out
117+- still accepts legacy `CODEX_REVIEW_*` env vars when the matching `AUTOREVIEW_*` var is unset
118+- prints `autoreview clean: no accepted/actionable findings reported` when the selected review command exits 0
119+120+## Final Report
121+122+Include:
123+- review command used
124+- tests/proof run
125+- findings accepted/rejected, briefly why
126+- the clean review result from the final helper/review run, or why a remaining finding was consciously rejected
127+128+Do not run another Codex review solely to improve the final report wording. If the final helper run exited 0 and produced no accepted/actionable findings, report that exact run as clean.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。