/benedictking-skills:codex-reviewfrom benedictking-skills
Automates code review using Codex CLI: checks working directory, updates CHANGELOG, runs linting, and invokes codex review on uncommitted changes or latest commit.
Ships in benedictking-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Triggered when user input contains:
Running codex review --uncommitted alone only shows AI "what was done (Implementation)".
Recording intention first tells AI "what you wanted to do (Intention)".
"Code changes + intention description" as combined input is the most effective way to improve AI code review quality.
This skill operates in two phases:
git diff --name-only && git status --short
Decide review mode based on output:
HEAD with the same difficulty criteria, then invoke codex review --commit HEAD with the matching model configurationBefore any review, must check if CHANGELOG.md contains description of current changes.
# Check if CHANGELOG.md is in uncommitted changes
git diff --name-only | grep -E "(CHANGELOG|changelog)"
If CHANGELOG is not updated, you must automatically perform the following (don't ask user to do it manually):
git diff --stat and git diff to get complete changes[Unreleased] sectionAuto-generated CHANGELOG entry format:
## [Unreleased]
### Added / Changed / Fixed
- Feature description: what problem was solved or what functionality was implemented
- Affected files: main modified files/modules
Example - Auto-generation Flow:
1. Detected CHANGELOG not updated
2. Run git diff --stat, found handlers/responses.go modified (+88 lines)
3. Run git diff to analyze details: added CompactHandler function
4. Auto-generate entry:
### Added
- Added `/v1/responses/compact` endpoint for conversation context compression
- Supports multi-channel failover and request body size limits
5. Use Edit tool to write to CHANGELOG.md
6. Continue with lint and codex review
Before invoking codex review, must add all new files (untracked files) to git staging area, otherwise codex will report P1 error.
# Check for new files
git status --short | grep "^??"
If there are new files, automatically execute:
# Safely stage all new files (handles empty list and special filenames)
git ls-files --others --exclude-standard -z | while IFS= read -r -d '' f; do git add -- "$f"; done
Explanation:
-z uses null character to separate filenames, correctly handles filenames with spaces/newlineswhile IFS= read -r -d '' reads filenames one by onegit add -- "$f" uses -- separator, correctly handles filenames starting with -Count change scale:
# Get summary line for ALL changes (staged + unstaged)
# IMPORTANT: Must use 'HEAD' as base to include both staged and unstaged changes
git diff --stat HEAD | tail -1
For a clean working directory, assess the latest commit instead:
git show --stat --format= HEAD | tail -1
Why use git diff --stat HEAD:
git diff --stat only shows unstaged changesgit diff --cached --stat only shows staged changesgit diff --stat HEAD shows BOTH staged and unstaged changes combinedtail -1) is the summary line with total file count and line changesDifficulty Assessment Criteria:
Model + Reasoning Effort Combinations:
选型由 scripts/select-review-model.mjs 根据实时 codexradar 智商/成本/耗时数据驱动决定:
脚本指标与 codexradar 站点「综合成本 × 智力」图表同量纲:
iq = p / n * 150(0-150 刻度)price = mean(actual_cost_usd);minutes = mean(duration_sec) / 60选型主约束是实测平均耗时(时间预算),每档一个目标函数,在全部 model × effort 组合上全局比较:
两条规则合起来天然落在成本-智力 Pareto 前沿上:
sol max 比 sol xhigh 贵还弱)不会中选。超时不再写死:timeout = ceil(实测平均分钟 × 2),随选中档位走,由脚本输出的 timeoutMinutes / timeoutMs 给出。fallback 候选也各带自己的 timeout,重试时用它自己的时限。
脚本内置 1 小时 TTL 缓存(~/.cache/codex-review/radar.json),网络与缓存都不可用时回退到保守默认值:
| Difficulty | Built-in Default | 推导 Timeout |
|---|---|---|
| Normal | model=gpt-5.6-luna effort=xhigh | 47 min |
| Difficult | model=gpt-5.6-sol effort=xhigh | 53 min |
| Critical | model=gpt-5.6-sol effort=xhigh | 53 min |
时间预算与 IQ 下限可用 --max-minutes / --iq-floor 覆盖(分钟 / 0-150 刻度)。若时间预算内无组合达标,脚本退化为取全局最高 IQ,不会无解。
Model Fallback Policy:
codex review result. Do not use codex debug models as a preflight gate.fallback array returned by select-review-model.mjs, ordered by descending IQ. Each entry is from a different model family than the primary, because a same-family effort swap cannot work around a model-unavailable failure. Retry each candidate in order after an explicit availability failure.timeoutMs (derived from that candidate's measured minutes). Use it when retrying, not the primary's timeout.codex review with the next candidate. Stop after exhausting the fallback chain and report the error.Critical Tasks (meets any condition, use data-driven selection):
node <skill-dir>/scripts/select-review-model.mjs --difficulty critical; use the returned primary model/effort and the returned timeoutMs as the Task timeoutmodel=gpt-5.6-sol effort=xhigh, timeout 53 minutesDifficult Tasks (meets any condition):
node <skill-dir>/scripts/select-review-model.mjs --difficulty difficult; use the returned primary model/effort and timeoutMsmodel=gpt-5.6-sol effort=xhigh, timeout 53 minutesNormal Tasks (other cases):
node <skill-dir>/scripts/select-review-model.mjs --difficulty normal; use the returned primary model/effort and timeoutMsmodel=gpt-5.6-luna effort=xhigh, timeout 47 minutesEvaluation Method:
You MUST parse the git diff --stat HEAD output correctly to determine difficulty:
# Get the summary line (last line of git diff --stat HEAD)
git diff --stat HEAD | tail -1
# Example outputs:
# "20 files changed, 342 insertions(+), 985 deletions(-)"
# "1 file changed, 50 insertions(+)" # No deletions
# "3 files changed, 120 deletions(-)" # No insertions
Critical: Why the summary line matters:
file.go | 171 ++++++++++++++++++++-6 files changed, 1341 insertions(+), 18 deletions(-)tail -1 to get accurate totalsParsing Rules:
Important Edge Cases:
"1 file changed" (singular form)"insertions(+)" entirely → treat as 0"deletions(-)" entirely → treat as 0"0 insertions(+), 0 deletions(-)" or omit bothDecision Logic (check in order, first match wins):
--difficulty critical)--difficulty difficult)--difficulty difficult)--difficulty difficult)--difficulty normal)Example Cases:
--difficulty critical → use returned primary (currently gpt-5.6-sol effort=xhigh), use returned timeoutMs--difficulty difficult → use returned primary (currently gpt-5.6-sol effort=xhigh), use returned timeoutMs--difficulty difficult → use returned primary (currently gpt-5.6-sol effort=xhigh), use returned timeoutMs--difficulty normal → use returned primary (currently gpt-5.6-luna effort=xhigh), use returned timeoutMs--difficulty normal → use returned primary (currently gpt-5.6-luna effort=xhigh), use returned timeoutMs普通任务落在 gpt-5.6-luna effort=xhigh 是符合预期的:它是"耗时 ≤ 25min 且 IQ ≥ 80"里最便宜的(约 $0.31 / 23.5min / IQ 87.1)。在 Pareto 前沿上再往上,terra max 仅多 2.7 IQ 却要近 8 倍成本,sol max 比 sol xhigh 贵还弱——这类坏拐点都被选型规则跳过。困难/关键档当前都落在 sol xhigh:它是高价区性价比拐点(IQ 103.6 / $6.26 / 26min),比顶点 sol ultra(106.7 / $20.95 / 54min)只低 3 IQ,成本却只有 1/3。
Dynamic Model Selection Flow:
After determining the difficulty level, obtain the recommended model and effort dynamically:
# Resolve the skill directory path (adjust if your skill installation path differs)
SKILL_DIR="$(cd "$(dirname "$0")" && pwd)/scripts" 2>/dev/null || SKILL_DIR="$HOME/.claude/skills/codex-review/scripts"
MODEL_JSON=$(node "$SKILL_DIR/select-review-model.mjs" --difficulty <normal|difficult|critical>)
PRIMARY_MODEL=$(echo "$MODEL_JSON" | jq -r '.primary.model')
PRIMARY_EFFORT=$(echo "$MODEL_JSON" | jq -r '.primary.effort')
PRIMARY_TIMEOUT_MS=$(echo "$MODEL_JSON" | jq -r '.primary.timeoutMs') # timeout derived from measured minutes
Use the extracted PRIMARY_MODEL and PRIMARY_EFFORT to build the review command, and PRIMARY_TIMEOUT_MS as the Task timeout.
Invoke codex-runner Subtask:
Use Task tool to invoke codex-runner, passing complete command (including Lint + codex review):
Task parameters:
- subagent_type: Bash
- description: "Execute Lint and codex review"
- timeout: <timeoutMs from the selection script> (derived from the chosen model's measured minutes)
- prompt: Choose corresponding command based on project type and difficulty
Build the prompt as:
<lint command> && codex review <mode> --config model=<primary-model> --config model_reasoning_effort=<primary-effort>
Pass exactly these flags and nothing else. Do not add --full-auto, -s/--sandbox, or any
--dangerously-* flag: `codex review` does not accept them (see "CLI Compatibility and Flag
Discipline"), and adding one is an unrequested safety-gate bypass.
After lint succeeds, apply the dynamic fallback policy. Retry only `codex review <mode>` with the next candidate from the fallback array after an explicit model or reasoning-effort availability failure. Use that candidate's own timeoutMs for the retry.
Lint command (by project type):
Go: go fmt ./... && go vet ./...
Node: npm run lint:fix
Python: black . && ruff check --fix .
Model + timeout (by difficulty, both from the selection script):
Critical: run script --difficulty critical → use returned primary model/effort/timeoutMs
Difficult: run script --difficulty difficult → use returned primary model/effort/timeoutMs
Normal: run script --difficulty normal → use returned primary model/effort/timeoutMs
Example (Go, Normal, after script returns luna+xhigh):
go fmt ./... && go vet ./... && codex review --uncommitted --config model=gpt-5.6-luna --config model_reasoning_effort=xhigh
Clean working directory (review last commit, no lint):
codex review --commit HEAD --config model=<primary-model> --config model_reasoning_effort=<primary-effort>
(model/effort/timeout obtained from select-review-model.mjs)
If Codex finds Changelog description inconsistent with code logic:
If Codex reports P0 / P1 / P2 issues, you must proactively fix them immediately instead of stopping at reporting.
Required behavior:
Review loop rule:
Final pass reporting rule:
⏺ Final review complete. Passed.
Result:
- Codex final conclusion: No defects were found that would cause functional errors, obvious regressions, or block merge
- Tests passed: <actual test command(s) executed>
- Lint / validation passed: <actual lint, fmt, vet, or other validation command(s) executed>
Fix priority:
Constraints:
codex review [OPTIONS] [PROMPT]
Note: [PROMPT] parameter cannot be used with --uncommitted, --base, or --commit.
| Option | Description | Example |
|---|---|---|
--uncommitted | Review all uncommitted changes in working directory (staged + unstaged + untracked) | codex review --uncommitted |
--base <BRANCH> | Review changes relative to specified base branch | codex review --base main |
--commit <SHA> | Review changes introduced by specified commit | codex review --commit HEAD |
--title <TITLE> | Optional commit title, displayed in review summary | codex review --uncommitted --title "feat: add JSON parser" |
-c, --config <key=value> | Override configuration values | codex review --uncommitted -c model="gpt-5.6-terra" |
# 1. Review all uncommitted changes (most common)
codex review --uncommitted
# 2. Review latest commit
codex review --commit HEAD
# 3. Review specific commit
codex review --commit abc1234
# 4. Review all changes in current branch relative to main
codex review --base main
# 5. Review changes in current branch relative to develop
codex review --base develop
# 6. Review with title (title shown in review summary)
codex review --uncommitted --title "fix: resolve JSON parsing errors"
# 7. Review using dynamically selected model and effort (as determined by select-review-model.mjs)
codex review --uncommitted -c model="<primary-model>" -c model_reasoning_effort="<primary-effort>"
--uncommitted, --base, --commit are mutually exclusive, cannot be used together[PROMPT] parameter is mutually exclusive with the above three optionsCheck the CLI version first when a flag is rejected:
codex --version # e.g. codex-cli 0.145.0
codex review -h # authoritative list of accepted flags for THIS version
codex review accepts only these options (verified on codex-cli 0.145.0):
-c/--config, --strict-config, --enable, --disable, --uncommitted, --base, --commit, --title, -h/--help
Never add approval or sandbox flags to codex review. The following belong to codex exec, not codex review, and passing them makes the command fail with error: unexpected argument:
--full-auto-s / --sandbox <read-only|workspace-write|danger-full-access>--dangerously-bypass-approvals-and-sandbox--dangerously-bypass-hook-trustcodex review is already non-interactive and read-only; it needs no approval bypass. Beyond breaking the command, adding such a flag is an unrequested safety-gate bypass that a host permission layer (for example the Claude Code auto mode classifier) will deny.
Rules when a codex invocation fails:
error: unexpected argument '--x' → the flag does not exist on this subcommand. Run codex review -h, remove the flag, retry. Do not substitute a different bypass flag.-c/--config, never through invented CLI flags.codex --version and codex review -h. Only the flags that -h lists are valid on this version. Never add --full-auto, -s/--sandbox, or --dangerously-* to codex review.timeoutMs = ceil(measuredMinutes × 2) per candidate (roughly 47 / 53 min under current data). Use the selected candidate's timeoutMs as the Task timeout, not a fixed per-difficulty constant.Why separate contexts?
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (benedictking/benedictking-skills) — no native marketplace selected
npx claudepluginhub p/benedictking-benedictking-skills6 skills in this plugin
/context7-auto-researchUse this skill when users need current documentation, setup steps, API references, or code examples for a named library, framework, SDK, or API. It fetches up-to-date Context7 docs./exa-searchUse this skill when users need semantic web search, similar-page discovery, result content retrieval, research-paper lookup, GitHub discovery, or structured Exa-powered research./firecrawl-scraperUse this skill when users need to scrape web pages, extract structured page data, take website screenshots, parse PDFs, batch-scrape URLs, or crawl a site with Firecrawl.Other plugins' skills for the same job