Skip to content

自用/精选的 Claude Code / Codex 技能:内容创作、客服、市场调研、SEO、Agent 工作流循环、Grok X 实时抓取与评审工具

Python

Add claude-review skill: Codex-driven headless Claude review

yangliu20602a3ecf0f8f33
diff --git a/README.md b/README.md
index 445a5de..66e9c09 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@
| Skill | 描述 |
|-------|------|
| [skill_auditor](./skill_auditor/) | Claude Skills 安全审计工具 |
+| [claude-review](./claude-review/) | Codex 驱动 Claude 做 headless 评审(plan / 架构 / 文档 / work-log),自动链式调用 `plan-eng-review`。安装到 `~/.codex/skills/` |
## 安装方法
diff --git a/claude-review/SKILL.md b/claude-review/SKILL.md
new file mode 100644
index 0000000..8cbfe93
--- /dev/null
+++ b/claude-review/SKILL.md
@@ -0,0 +1,126 @@
+---
+name: claude-review
+description: "Delegate review tasks to Claude Code in headless mode — for plans, architecture docs, user docs, or work logs. Use this skill whenever you have a plan.md / design doc / README / STATUS.md that would benefit from an outside perspective before implementation or at a phase boundary. The skill calls Claude once in `--print` mode (one-shot, no interactive session), automatically chains Claude's `plan-eng-review` skill for plan/architecture targets, and returns a structured Markdown report. Built for Codex-driven workflows where Claude quota is precious and GPT quota is abundant — prefer this over spinning up a full Claude conversation."
+argument-hint: "<plan|architecture|docs|work-log> <file_or_dir> [--deep]"
+---
+
+# claude-review — Headless Claude Review
+
+Get an independent review from Claude without burning tokens on a full Claude session. One `claude --print` call produces a structured report.
+
+## When To Invoke
+
+| Situation | Type |
+|---|---|
+| Detailed implementation plan, about to start coding | `plan` |
+| Module boundaries / system diagram drafted | `architecture` |
+| README / API docs / user-facing docs before shipping | `docs` |
+| STATUS.md / errors.md after a work session — verify honesty | `work-log` |
+
+## Usage
+
+```bash
+~/.codex/skills/claude-review/scripts/claude-review <type> <file_or_dir> [--deep]
+```
+
+**Examples:**
+
+```bash
+# Review plan before implementation (auto-chains plan-eng-review)
+~/.codex/skills/claude-review/scripts/claude-review plan ./docs/plan.md
+
+# Architecture review with deep consultation (also chains office-hours)
+~/.codex/skills/claude-review/scripts/claude-review architecture ./docs/design.md --deep
+
+# Quality-check docs before shipping (single pass, no chain)
+~/.codex/skills/claude-review/scripts/claude-review docs ./README.md
+
+# Audit a work directory for buried failures
+~/.codex/skills/claude-review/scripts/claude-review work-log ./.codexfree/
+```
+
+## What Happens
+
+1. Script validates inputs and resolves absolute path
+2. Assembles a headless-mode prompt (no AskUserQuestion, single final report)
+3. Calls `claude --print --permission-mode bypassPermissions` once
+4. For `plan` / `architecture`: Claude auto-invokes its `plan-eng-review` skill in the same session and consolidates
+5. For `--deep` (plan / architecture only): Claude additionally chains the `office-hours` skill
+6. Report streamed to stdout AND saved to `.claude-review/<timestamp>-<type>.md` in the current working directory
+
+All skill chaining happens inside ONE Claude session — you pay for one `--print` invocation regardless of how many sub-skills are chained.
+
+## Output Format
+
+The report is always Markdown with this structure:
+
+```
+# Review Report — <type>
+**Target:** <absolute path>
+**Timestamp:** <UTC ISO>
+
+## Executive Summary
+...
+
+## Critical Issues (must fix before proceeding)
+...
+
+## High-Priority Findings (should fix soon)
+...
+
+## Suggestions (nice to have)
+...
+
+## Chained: plan-eng-review (only for plan/architecture)
+...
+
+## Chained: office-hours (only with --deep)
+...
+
+## Decision
+approve | revise | block
+<1-2 sentence rationale>
+```
+
+Codex should read the report, treat `revise` findings as required fixes, then re-invoke the skill on the updated artifact. `block` means the artifact has fundamental problems and needs a rewrite, not a patch.
+
+## Decision Taxonomy
+
+| Decision | Meaning | Codex action |
+|---|---|---|
+| `approve` | Artifact is ready to proceed | Continue to next phase |
+| `revise` | Issues found, fixable in place | Fix issues, re-invoke skill |
+| `block` | Fundamental problem, not patchable | Halt; escalate to user |
+
+## Why Headless?
+
+Calling Claude interactively burns tokens on greetings, clarification, and tool overhead. `--print` mode:
+- Single request → single response → exit
+- All tool use happens inside one session
+- No context carried across invocations
+- Much lower token cost than a conversation
+
+The tradeoff: Claude cannot ask follow-up questions. The script's prompt assumes sensible defaults and instructs Claude to produce a complete report in one pass.
+
+## Skill Chain Reference
+
+| Type | Initial review | Chains `plan-eng-review` | Chains `office-hours` |
+|---|---|---|---|
+| `plan` | ✅ | ✅ | only with `--deep` |
+| `architecture` | ✅ | ✅ | only with `--deep` |
+| `docs` | ✅ | ❌ | ❌ |
+| `work-log` | ✅ | ❌ | ❌ |
+
+`docs` and `work-log` don't chain because `plan-eng-review` is an architecture-review skill, not a copy-editing or audit skill.
+
+## Prerequisites
+
+- `claude` CLI installed (`npm install -g @anthropic-ai/claude-code`)
+- User is logged into Claude Code (`claude --version` works)
+- For `plan` / `architecture`: the `plan-eng-review` skill must be installed in the user's Claude skill directory (part of the gstack plugin)
+- For `--deep`: the `office-hours` skill must be installed
+
+## Files
+
+- `scripts/claude-review` — main bash wrapper
+- `references/review-prompts.md` — lens definitions for each review type (Claude reads these via the bash-assembled prompt)
diff --git a/claude-review/references/review-prompts.md b/claude-review/references/review-prompts.md
new file mode 100644
index 0000000..2c072a2
--- /dev/null
+++ b/claude-review/references/review-prompts.md
@@ -0,0 +1,67 @@
+# Review Prompts Per Type
+
+Claude reads this file as part of its headless prompt and applies the lens matching the requested type. Each lens focuses the review on issues that matter most for that artifact class.
+
+## Type: plan
+
+You are reviewing an implementation plan that a developer or agent is about to execute. Your job is to catch problems BEFORE code is written, when fixes are cheap.
+
+Apply this lens:
+
+- **Completeness** — Are there gaps where steps are assumed to "just work"? Missing error handling paths? Missing tests? Missing rollback?
+- **Sequencing** — Is the order correct? Are there hidden dependencies between tasks that aren't represented?
+- **Scope drift** — Does the plan include work that doesn't serve the goal? Apply YAGNI.
+- **Ambiguity** — Would two different engineers read this the same way? Flag anything that could be interpreted multiple ways.
+- **Risk surface** — For each major step, what breaks if it fails? What's the blast radius? Is there a rollback?
+- **Testability** — Is success verifiable? Are acceptance criteria concrete and checkable, or vague ("works correctly")?
+- **Verification gates** — Where does the plan pause to verify before moving on? If nowhere, flag it.
+
+Be concrete. Cite specific sections or line numbers. Don't hand-wave.
+
+## Type: architecture
+
+You are reviewing an architecture or design document. Your job is to surface structural problems before they calcify into code.
+
+Apply this lens:
+
+- **Coupling** — Where are the hidden dependencies between components? What knows about what?
+- **Single responsibility** — Does each component have one clear reason to exist? Or is it a bag of loosely related features?
+- **Interface clarity** — Are module boundaries crisp? Are contracts (inputs, outputs, failure modes) well-defined?
+- **Failure modes** — What happens when each component fails? Where are retries, timeouts, circuit breakers, fallbacks?
+- **Observability** — Can you tell from outside what the system is doing right now? Logs, metrics, traces — is the story complete?
+- **Evolution** — When requirements change (they will), where will this design hurt? What's hard to undo?
+- **Data flow** — Trace one realistic request end-to-end. Does every step make sense? Where does data transform, and why?
+
+Be concrete. Reference specific components or diagrams. If a diagram is missing, say so.
+
+## Type: docs
+
+You are reviewing user-facing or API documentation for shipping readiness. Your job is to prevent users from being confused, misled, or stuck.
+
+Apply this lens:
+
+- **Accuracy** — Does the doc match the actual behavior of the code? Cite specific mismatches.
+- **Completeness** — For each public API or feature: parameters, return values, side effects, error conditions. Anything missing?
+- **Ambiguity** — Could any passage be read two ways? Flag each case with a concrete alternative interpretation.
+- **Examples** — Is there at least one canonical example per concept? Do the examples actually work (read the code — don't assume)?
+- **Onboarding** — Can a new user follow the doc end-to-end without outside context? Where do they get stuck?
+- **Deprecation / versioning** — Are version constraints clear? Are breaking changes explicitly marked?
+- **Jargon** — Is terminology defined before first use? Are there unnecessary internal names leaking?
+
+Be concrete. Cite section headings and paragraph starts.
+
+## Type: work-log
+
+You are auditing a work log (STATUS.md, errors.md, notes.md, or similar). Your job is to find failures that have been soft-pedaled, misreported, or silently dropped. Assume nothing — verify against evidence in the log itself and in the surrounding code if possible.
+
+Apply this lens:
+
+- **Buried failures** — Is there an "unresolved" item dressed up as "deferred" or "out of scope"?
+- **Silent retries** — Are there loops where the same error appears multiple times with no root-cause fix, just "tried again"?
+- **Acceptance criteria drift** — Did the original plan's success criteria quietly get watered down between phases?
+- **Missing errors** — Based on what was built and tested, are there failures the log doesn't mention? Look for suspicious absence.
+- **State claims vs. reality** — Does STATUS.md say "COMPLETED" for phases whose acceptance criteria you can't verify from the log?
+- **Handoff readiness** — If someone had to pick up tomorrow with only these files, would they know what's done, what's broken, and what's next?
+- **Red flags** — "Works on my machine", "should be fine", "will fix later", "good enough" — each of these is a potential hidden failure.
+
+Be specific: cite file:line, phase numbers, and exact error messages from the log. Call out what's suspicious AND what's verified clean.
diff --git a/claude-review/scripts/claude-review b/claude-review/scripts/claude-review
new file mode 100755
index 0000000..e710f8a
--- /dev/null
+++ b/claude-review/scripts/claude-review
@@ -0,0 +1,242 @@
+#!/usr/bin/env bash
+# claude-review: Call Claude Code in headless mode to review an artifact.
+# Chains plan-eng-review for plan/architecture reviews.
+# Chains office-hours with --deep.
+#
+# Usage: claude-review <type> <file_or_dir> [--deep]
+# type: plan | architecture | docs | work-log
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+SKILL_DIR="$(dirname "$SCRIPT_DIR")"
+PROMPTS_FILE="$SKILL_DIR/references/review-prompts.md"
+
+usage() {
+ cat >&2 <<'EOF'
+Usage: claude-review <type> <file_or_dir> [--deep]
+
+Types:
+ plan Review implementation plan (auto-chains plan-eng-review)
+ architecture Review architecture/design doc (auto-chains plan-eng-review)
+ docs Review user/API documentation (single pass)
+ work-log Audit STATUS.md / errors.md for hidden failures (single pass)
+
+Flags:
+ --deep Also chain office-hours skill (plan/architecture only)
+
+Output:
+ - Streamed to stdout
+ - Saved to .claude-review/<timestamp>-<type>.md in current working directory
+
+Examples:
+ claude-review plan ./docs/plan.md
+ claude-review architecture ./design.md --deep
+ claude-review docs ./README.md
+ claude-review work-log ./.codexfree/
+EOF
+}
+
+# --- Input validation ---
+
+if [ $# -lt 2 ]; then
+ usage
+ exit 1
+fi
+
+TYPE="$1"
+TARGET="$2"
+DEEP_FLAG="${3:-}"
+
+case "$TYPE" in
+ plan|architecture|docs|work-log) ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Error: invalid type '$TYPE'" >&2
+ usage
+ exit 1
+ ;;
+esac
+
+if [ ! -e "$TARGET" ]; then
+ echo "Error: target not found: $TARGET" >&2
+ exit 1
+fi
+
+if [ -n "$DEEP_FLAG" ] && [ "$DEEP_FLAG" != "--deep" ]; then
+ echo "Error: unknown flag '$DEEP_FLAG' (only --deep is supported)" >&2
+ exit 1
+fi
+
+if ! command -v claude >/dev/null 2>&1; then
+ echo "Error: 'claude' CLI not found. Install with: npm install -g @anthropic-ai/claude-code" >&2
+ exit 1
+fi
+
+if [ ! -f "$PROMPTS_FILE" ]; then
+ echo "Error: prompt file missing: $PROMPTS_FILE" >&2
+ exit 1
+fi
+
+# --- Resolve absolute target path (portable, no realpath dependency) ---
+
+if [ -d "$TARGET" ]; then
+ TARGET_ABS="$(cd "$TARGET" && pwd)"
+else
+ TARGET_DIR="$(cd "$(dirname "$TARGET")" && pwd)"
+ TARGET_ABS="$TARGET_DIR/$(basename "$TARGET")"
+fi
+
+# --- Decide skill chain ---
+
+CHAIN_PLAN_ENG="no"
+CHAIN_OFFICE_HOURS="no"
+case "$TYPE" in
+ plan|architecture)
+ CHAIN_PLAN_ENG="yes"
+ if [ "$DEEP_FLAG" = "--deep" ]; then
+ CHAIN_OFFICE_HOURS="yes"
+ fi
+ ;;
+ *)
+ if [ "$DEEP_FLAG" = "--deep" ]; then
+ echo "Warning: --deep has no effect for type '$TYPE' (only applies to plan/architecture)" >&2
+ fi
+ ;;
+esac
+
+# --- Output path ---
+
+TS="$(date -u +"%Y%m%dT%H%M%SZ")"
+OUT_DIR=".claude-review"
+mkdir -p "$OUT_DIR"
+OUT_FILE="$OUT_DIR/${TS}-${TYPE}.md"
+
+# --- Build chain instructions block (conditional) ---
+
+CHAIN_BLOCK=""
+if [ "$CHAIN_PLAN_ENG" = "yes" ]; then
+ CHAIN_BLOCK="${CHAIN_BLOCK}
+- MANDATORY: After your initial review, invoke the 'plan-eng-review' skill on the same target file. Pass through the headless-mode rule: plan-eng-review must NOT call AskUserQuestion; it must produce its final findings directly. Extract the essential findings and include them in your report under the heading '## Chained: plan-eng-review'. Do not copy the entire plan-eng-review preamble output — just the substantive findings."
+fi
+if [ "$CHAIN_OFFICE_HOURS" = "yes" ]; then
+ CHAIN_BLOCK="${CHAIN_BLOCK}
+- MANDATORY: After plan-eng-review completes, also invoke the 'office-hours' skill for extended architectural consultation on the same target. Same headless-mode rule — no interactive questions, produce final output. Include under '## Chained: office-hours'."
+fi
+if [ -z "$CHAIN_BLOCK" ]; then
+ CHAIN_BLOCK="
+- No skill chaining for this review type. Your initial review IS the final review."
+fi
+
+# --- Build output-format sections (conditional) ---
+
+CHAINED_SECTIONS=""
+if [ "$CHAIN_PLAN_ENG" = "yes" ]; then
+ CHAINED_SECTIONS="${CHAINED_SECTIONS}
+
+## Chained: plan-eng-review
+<condensed substantive findings from the plan-eng-review skill>"
+fi
+if [ "$CHAIN_OFFICE_HOURS" = "yes" ]; then
+ CHAINED_SECTIONS="${CHAINED_SECTIONS}
+
+## Chained: office-hours
+<condensed consultation output>"
+fi
+
+# --- Assemble prompt ---
+# Note: heredoc is unquoted so that $VAR expansion happens for the variables
+# we want. The only dynamic content in the review-prompts file is plain prose;
+# no unescaped $ or backticks in that file, so $(cat ...) is safe.
+
+CWD="$(pwd)"
+
+PROMPT=$(cat <<PROMPT_EOF
+You are Claude Code, invoked in HEADLESS MODE by Codex CLI to perform an artifact review.
+
+# Headless-mode rules (strict — violations break the pipeline)
+
+- DO NOT invoke AskUserQuestion. There is no interactive user.
+- Assume sensible defaults for every decision you would otherwise clarify.
+- Produce one complete final report in one pass. Your stdout IS the review.
+- Do not emit progress chatter, status updates, or meta-commentary outside the report. Just the report.
+
+# Review task
+
+- Type: $TYPE
+- Target: $TARGET_ABS
+- Current working directory: $CWD
+
+# Step 1 — Initial review
+
+Read the target. If it is a directory, list its contents and read the files that match this review type (e.g., for work-log: STATUS.md, errors.md, notes.md, CODEX_TASK.md; for architecture: design docs, diagrams; for plan: plan.md, tasks files; for docs: README.md, API docs).
+
+Apply the lens for type "$TYPE" from the reference below:
+
+---
+$(cat "$PROMPTS_FILE")
+---
+
+# Step 2 — Skill chaining
+$CHAIN_BLOCK
+
+# Step 3 — Produce final report
+
+Emit exactly this Markdown structure to stdout. Do not prepend or append anything outside it.
+
+# Review Report — $TYPE
+
+**Target:** $TARGET_ABS
+**Timestamp:** $TS
+**Deep mode:** $([ "$CHAIN_OFFICE_HOURS" = "yes" ] && echo "yes" || echo "no")
+
+## Executive Summary
+<one paragraph: overall verdict and headline issues>
+
+## Critical Issues (must fix before proceeding)
+<numbered list; write "None" if none>
+
+## High-Priority Findings (should fix soon)
+<numbered list; write "None" if none>
+
+## Suggestions (nice to have)
+<numbered list; write "None" if none>$CHAINED_SECTIONS
+
+## Decision
+<one line: approve | revise | block>
+<1-2 sentence rationale>
+
+# Decision taxonomy
+
+- approve — artifact is ready to proceed as-is
+- revise — issues found, fixable in place; Codex should fix and re-invoke
+- block — fundamental problem, not patchable; escalate to human
+
+Be specific. Cite file paths, line numbers, section headings, and exact quotes where relevant. Avoid vague findings like "consider improving error handling" — name the specific location and the specific fix.
+PROMPT_EOF
+)
+
+# --- Invoke Claude ---
+
+echo "→ claude-review: type=$TYPE target=$TARGET_ABS" >&2
+echo "→ Report will be saved to: $OUT_FILE" >&2
+[ "$CHAIN_PLAN_ENG" = "yes" ] && echo "→ Chaining: plan-eng-review" >&2
+[ "$CHAIN_OFFICE_HOURS" = "yes" ] && echo "→ Chaining: office-hours (--deep)" >&2
+echo "" >&2
+
+# Stream to stdout AND save to file. Preserve exit code of claude.
+set +e
+claude --print --permission-mode bypassPermissions "$PROMPT" | tee "$OUT_FILE"
+CLAUDE_EXIT=${PIPESTATUS[0]}
+set -e
+
+echo "" >&2
+if [ "$CLAUDE_EXIT" -eq 0 ]; then
+ echo "✓ Review complete. Report: $OUT_FILE" >&2
+else
+ echo "✗ Claude exited with code $CLAUDE_EXIT. Partial report (if any) at: $OUT_FILE" >&2
+fi
+exit "$CLAUDE_EXIT"