create-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Review
生成AI代码审查提示
Bootstrap the review pipeline and generate a paste-ready review prompt for any AI reviewer.
搭建审查流水线,并为任意AI审查工具生成可直接粘贴使用的审查提示词。
Step 1: Determine the reviewer and session
步骤1:确定审查工具与会话
Reviewer: If the user provided , sanitize it to a safe kebab-case string (lowercase, strip any characters that aren't alphanumeric or hyphens, collapse multiple hyphens) and use that as the reviewer name (e.g. , , , ). If no argument, use .
$ARGUMENTScodexgeminigpt4claudegenericSession: Detect from context:
- If exists, check for the most recent session directory
.chalk/reviews/ - Otherwise, infer from the current branch name (kebab-case)
- If on /
main, ask the usermaster
Store as and .
{reviewer}{session}审查工具: 如果用户提供了,将其处理为安全的短横线分隔字符串(小写,移除所有非字母数字或短横线的字符,合并多个短横线),并将其作为审查工具名称(例如、、、)。如果没有提供参数,则使用。
$ARGUMENTScodexgeminigpt4claudegeneric会话: 从上下文检测:
- 如果存在目录,检查最新的会话目录
.chalk/reviews/ - 否则,从当前分支名称推断(转换为短横线分隔格式)
- 如果当前分支是/
main,询问用户master
将结果存储为和。
{reviewer}{session}Step 2: Bootstrap the review pipeline
步骤2:搭建审查流水线
Check if exists. If not, bootstrap the full pipeline:
.chalk/reviews/scripts/pack.shsh
mkdir -p .chalk/reviews/scripts .chalk/reviews/templates .chalk/reviews/sessions检查是否存在。如果不存在,则搭建完整流水线:
.chalk/reviews/scripts/pack.shsh
mkdir -p .chalk/reviews/scripts .chalk/reviews/templates .chalk/reviews/sessionsCreate .chalk/reviews/scripts/pack.sh
.chalk/reviews/scripts/pack.sh创建.chalk/reviews/scripts/pack.sh
脚本
.chalk/reviews/scripts/pack.shThis script generates a review context pack from git state:
sh
#!/usr/bin/env bash
set -euo pipefail
BASE_REF="${1:-origin/main}"
SESSION="${2:-adhoc}"
OUTPUT_PATH="${3:-.chalk/reviews/sessions/${SESSION}/pack.md}"该脚本从Git状态生成审查上下文包:
sh
#!/usr/bin/env bash
set -euo pipefail
BASE_REF="${1:-origin/main}"
SESSION="${2:-adhoc}"
OUTPUT_PATH="${3:-.chalk/reviews/sessions/${SESSION}/pack.md}"Resolve base ref
Resolve base ref
if ! git rev-parse --verify "$BASE_REF" >/dev/null 2>&1; then
for candidate in main origin/main master origin/master; do
if git rev-parse --verify "$candidate" >/dev/null 2>&1; then
BASE_REF="$candidate"
break
fi
done
fi
MERGE_BASE="$(git merge-base HEAD "$BASE_REF" 2>/dev/null || echo "")"
if [ -z "$MERGE_BASE" ]; then
MERGE_BASE="$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
{
echo "# Review Pack"
echo
echo "- Session: `$SESSION`"
echo "- Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
echo "- Base ref: `$BASE_REF`"
echo "- Merge base: `${MERGE_BASE:0:12}`"
echo "- Head: `$(git rev-parse --short HEAD)`"
echo
echo "## Diff Stat"
echo ''
echo
echo "## Changed Files"
CHANGED="$(git diff --name-only "$MERGE_BASE"..HEAD 2>/dev/null || true)"
if [ -n "$CHANGED" ]; then
echo "$CHANGED" | while IFS= read -r f; do [ -n "$f" ] && echo "- $f"; done
else
echo "- (none)"
fi
echo
echo "## Commit Log"
echo ''
echo
echo "## Working Tree Status"
echo ''
} > "$OUTPUT_PATH"
' git diff --stat "$MERGE_BASE"..HEAD 2>/dev/null || echo "(no committed diff)" echo '' git log --oneline "$MERGE_BASE"..HEAD 2>/dev/null || echo "(no commits ahead of base)" echo '' git status --short echo 'echo "PACK_PATH=$OUTPUT_PATH"
undefinedif ! git rev-parse --verify "$BASE_REF" >/dev/null 2>&1; then
for candidate in main origin/main master origin/master; do
if git rev-parse --verify "$candidate" >/dev/null 2>&1; then
BASE_REF="$candidate"
break
fi
done
fi
MERGE_BASE="$(git merge-base HEAD "$BASE_REF" 2>/dev/null || echo "")"
if [ -z "$MERGE_BASE" ]; then
MERGE_BASE="$(git rev-list --max-parents=0 HEAD | tail -n 1)"
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
{
echo "# Review Pack"
echo
echo "- Session: `$SESSION`"
echo "- Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
echo "- Base ref: `$BASE_REF`"
echo "- Merge base: `${MERGE_BASE:0:12}`"
echo "- Head: `$(git rev-parse --short HEAD)`"
echo
echo "## Diff Stat"
echo ''
echo
echo "## Changed Files"
CHANGED="$(git diff --name-only "$MERGE_BASE"..HEAD 2>/dev/null || true)"
if [ -n "$CHANGED" ]; then
echo "$CHANGED" | while IFS= read -r f; do [ -n "$f" ] && echo "- $f"; done
else
echo "- (none)"
fi
echo
echo "## Commit Log"
echo ''
echo
echo "## Working Tree Status"
echo ''
} > "$OUTPUT_PATH"
' git diff --stat "$MERGE_BASE"..HEAD 2>/dev/null || echo "(no committed diff)" echo '' git log --oneline "$MERGE_BASE"..HEAD 2>/dev/null || echo "(no commits ahead of base)" echo '' git status --short echo 'echo "PACK_PATH=$OUTPUT_PATH"
undefinedCreate .chalk/reviews/scripts/render-prompt.sh
.chalk/reviews/scripts/render-prompt.sh创建.chalk/reviews/scripts/render-prompt.sh
脚本
.chalk/reviews/scripts/render-prompt.shThis script combines pack + handoff + reviewer template into a prompt:
sh
#!/usr/bin/env bash
set -euo pipefail
REVIEWER="${1:?Usage: render-prompt.sh <reviewer> [pack-path] [handoff-path] [output-path]}"
PACK_PATH="${2:-}"
HANDOFF_PATH="${3:-}"
OUTPUT_PATH="${4:-}"
SESSION="${5:-}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
REVIEWER_TITLE="$(echo "$REVIEWER" | awk '{print toupper(substr($0,1,1)) substr($0,2)}')"
if [ -z "$SESSION" ] && [ -f "$ROOT_DIR/.current-session" ]; then
SESSION="$(cat "$ROOT_DIR/.current-session")"
fi
SESSION="${SESSION:-adhoc}"
[ -z "$PACK_PATH" ] && PACK_PATH="$ROOT_DIR/sessions/$SESSION/pack.md"
[ -z "$HANDOFF_PATH" ] && HANDOFF_PATH="$ROOT_DIR/sessions/$SESSION/handoff.md"
[ -z "$OUTPUT_PATH" ] && OUTPUT_PATH="$ROOT_DIR/sessions/$SESSION/${REVIEWER}.prompt.md"
if [ ! -f "$PACK_PATH" ]; then
echo "Pack not found at $PACK_PATH. Run pack.sh first." >&2
exit 1
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
{
echo "# $REVIEWER_TITLE Review Request"
echo
# Use provider-specific template if available, else generic
TEMPLATE="$ROOT_DIR/templates/${REVIEWER}-review.template.md"
if [ ! -f "$TEMPLATE" ]; then
TEMPLATE="$ROOT_DIR/templates/generic-review.template.md"
fi
if [ -f "$TEMPLATE" ]; then
cat "$TEMPLATE"
fi
echo
echo "---"
echo
echo "## Review Pack"
cat "$PACK_PATH"
if [ -f "$HANDOFF_PATH" ]; then
echo
echo "---"
echo
echo "## Handoff"
cat "$HANDOFF_PATH"
fi
} > "$OUTPUT_PATH"
echo "PROMPT_PATH=$OUTPUT_PATH"该脚本将审查包、交接文档和审查工具模板合并为提示词:
sh
#!/usr/bin/env bash
set -euo pipefail
REVIEWER="${1:?Usage: render-prompt.sh <reviewer> [pack-path] [handoff-path] [output-path]}"
PACK_PATH="${2:-}"
HANDOFF_PATH="${3:-}"
OUTPUT_PATH="${4:-}"
SESSION="${5:-}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
REVIEWER_TITLE="$(echo "$REVIEWER" | awk '{print toupper(substr($0,1,1)) substr($0,2)}')"
if [ -z "$SESSION" ] && [ -f "$ROOT_DIR/.current-session" ]; then
SESSION="$(cat "$ROOT_DIR/.current-session")"
fi
SESSION="${SESSION:-adhoc}"
[ -z "$PACK_PATH" ] && PACK_PATH="$ROOT_DIR/sessions/$SESSION/pack.md"
[ -z "$HANDOFF_PATH" ] && HANDOFF_PATH="$ROOT_DIR/sessions/$SESSION/handoff.md"
[ -z "$OUTPUT_PATH" ] && OUTPUT_PATH="$ROOT_DIR/sessions/$SESSION/${REVIEWER}.prompt.md"
if [ ! -f "$PACK_PATH" ]; then
echo "Pack not found at $PACK_PATH. Run pack.sh first." >&2
exit 1
fi
mkdir -p "$(dirname "$OUTPUT_PATH")"
{
echo "# $REVIEWER_TITLE Review Request"
echo
# Use provider-specific template if available, else generic
TEMPLATE="$ROOT_DIR/templates/${REVIEWER}-review.template.md"
if [ ! -f "$TEMPLATE" ]; then
TEMPLATE="$ROOT_DIR/templates/generic-review.template.md"
fi
if [ -f "$TEMPLATE" ]; then
cat "$TEMPLATE"
fi
echo
echo "---"
echo
echo "## Review Pack"
cat "$PACK_PATH"
if [ -f "$HANDOFF_PATH" ]; then
echo
echo "---"
echo
echo "## Handoff"
cat "$HANDOFF_PATH"
fi
} > "$OUTPUT_PATH"
echo "PROMPT_PATH=$OUTPUT_PATH"Create .chalk/reviews/scripts/copy-prompt.sh
.chalk/reviews/scripts/copy-prompt.sh创建.chalk/reviews/scripts/copy-prompt.sh
脚本
.chalk/reviews/scripts/copy-prompt.shsh
#!/usr/bin/env bash
set -euo pipefail
REVIEWER="${1:?Usage: copy-prompt.sh <reviewer> [pack] [handoff] [output] [session]}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OUTPUT="$(bash "$SCRIPT_DIR/render-prompt.sh" "$@")"
echo "$OUTPUT"
PROMPT_PATH="$(echo "$OUTPUT" | sed -n 's/^PROMPT_PATH=//p' | head -1)"
if [ -z "$PROMPT_PATH" ] || [ ! -f "$PROMPT_PATH" ]; then
echo "Could not resolve prompt path." >&2
exit 1
fi
COPIED=0
if command -v pbcopy >/dev/null 2>&1; then
pbcopy < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=pbcopy"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=xclip"
elif command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=wl-copy"
fi
if [ "$COPIED" -eq 0 ]; then
echo "CLIPBOARD=none (copy manually from $PROMPT_PATH)"
fish
#!/usr/bin/env bash
set -euo pipefail
REVIEWER="${1:?Usage: copy-prompt.sh <reviewer> [pack] [handoff] [output] [session]}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OUTPUT="$(bash "$SCRIPT_DIR/render-prompt.sh" "$@")"
echo "$OUTPUT"
PROMPT_PATH="$(echo "$OUTPUT" | sed -n 's/^PROMPT_PATH=//p' | head -1)"
if [ -z "$PROMPT_PATH" ] || [ ! -f "$PROMPT_PATH" ]; then
echo "Could not resolve prompt path." >&2
exit 1
fi
COPIED=0
if command -v pbcopy >/dev/null 2>&1; then
pbcopy < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=pbcopy"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=xclip"
elif command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$PROMPT_PATH" && COPIED=1 && echo "CLIPBOARD=wl-copy"
fi
if [ "$COPIED" -eq 0 ]; then
echo "CLIPBOARD=none (copy manually from $PROMPT_PATH)"
fiCreate .chalk/reviews/templates/generic-review.template.md
.chalk/reviews/templates/generic-review.template.md创建.chalk/reviews/templates/generic-review.template.md
模板
.chalk/reviews/templates/generic-review.template.mdOnly create if it does not already exist (preserve user customizations):
markdown
You are acting as an independent code reviewer.
Task:
- Review the diff only.
- Report defects and risks, not style preferences.
Output format:
1. Findings (highest severity first)
2. Open questions/assumptions
3. Residual risks/testing gaps
Finding schema:
- Severity: P0 (critical) | P1 (high) | P2 (medium) | P3 (low)
- File: <path>:<line>
- Issue: concise summary
- Failure mode: what breaks and when
- Suggested fix: actionable next step
Rules:
- Do not suggest broad refactors unless required for correctness.
- If no blocking issues exist, explicitly state: `No blocking findings`.仅当模板不存在时创建(保留用户自定义内容):
markdown
你将作为独立代码审查员开展工作。
任务:
- 仅审查代码差异。
- 报告缺陷和风险,而非风格偏好。
输出格式:
1. 发现问题(按严重程度从高到低排序)
2. 待解决问题/假设
3. 剩余风险/测试缺口
问题描述格式:
- 严重程度:P0(关键)| P1(高)| P2(中)| P3(低)
- 文件:<路径>:<行号>
- 问题:简洁总结
- 失效模式:何时、何处会出现问题
- 建议修复方案:可执行的下一步操作
规则:
- 除非为了确保正确性,否则不建议大范围重构。
- 如果没有阻塞性问题,请明确说明:`No blocking findings`。Create .chalk/reviews/templates/codex-review.template.md
.chalk/reviews/templates/codex-review.template.md创建.chalk/reviews/templates/codex-review.template.md
模板
.chalk/reviews/templates/codex-review.template.mdOnly create if it does not already exist:
markdown
You are Codex performing an independent PR review.
Primary objective:
- Find real defects and risks in changed lines only.
- Prioritize actionable, high-signal output over style commentary.
Output format (required):
1. `## Verdict`
- `Block merge: yes|no`
- `Blocking findings: P0=<n>, P1=<n>`
- If no P0/P1 findings, include exact text: `No blocking findings`.
2. `## Findings`
- Markdown table: `ID | Severity | File:Line | Issue | Failure mode | Recommended fix | Confidence`
- IDs: F-001, F-002, ...
3. `## Testing Gaps`
- Missing tests that could hide regressions.
4. `## Open Questions`
- Only unresolved assumptions that affect correctness.
Rules:
- Focus on correctness, security, reliability, and regression risk.
- Do not comment on formatting/import ordering/trivial naming.
- Keep recommendations patch-oriented and specific.仅当模板不存在时创建:
markdown
你是Codex,正在执行独立的PR审查。
主要目标:
- 仅在修改的代码行中查找真实缺陷和风险。
- 优先输出可执行、高价值的内容,而非风格评论。
输出格式(必填):
1. `## 评审结论`
- `是否阻止合并:是|否`
- `阻塞性问题数量:P0=<n>, P1=<n>`
- 如果没有P0/P1级问题,请包含确切文本:`No blocking findings`。
2. `## 发现问题`
- Markdown表格:`ID | 严重程度 | 文件:行号 | 问题 | 失效模式 | 建议修复方案 | 置信度`
- ID格式:F-001, F-002, ...
3. `## 测试缺口`
- 可能隐藏回归问题的缺失测试。
4. `## 待解决问题`
- 仅包含影响正确性的未解决假设。
规则:
- 聚焦于正确性、安全性、可靠性和回归风险。
- 不评论格式/导入顺序/命名等细节问题。
- 建议的修复方案需具体且针对代码补丁。Create .chalk/reviews/templates/gemini-review.template.md
.chalk/reviews/templates/gemini-review.template.md创建.chalk/reviews/templates/gemini-review.template.md
模板
.chalk/reviews/templates/gemini-review.template.mdOnly create if it does not already exist:
markdown
You are Gemini performing an independent PR review.
Primary objective:
- Provide a rigorous risk assessment on changed code.
- Emphasize user impact and merge risk.
Output format (required):
1. `## Executive Summary`
- 2-4 sentences on overall risk.
- `Merge recommendation: approve|changes-requested`
- If no P0/P1 findings, include exact text: `No blocking findings`.
2. `## Findings`
- Markdown table: `ID | Severity | Category | File:Line | Issue | Impact | Suggested fix | Confidence`
- IDs: G-001, G-002, ...
- Categories: Security | Correctness | Performance | Reliability | Testing
3. `## Regression & Testing Gaps`
- Missing test coverage and risky edge cases.
4. `## Assumptions`
- Only assumptions that materially affect conclusions.
Rules:
- Review changed lines only.
- No style-only feedback.
- Suggested fixes must be concrete and immediately actionable.仅当模板不存在时创建:
markdown
你是Gemini,正在执行独立的PR审查。
主要目标:
- 对修改后的代码进行严格的风险评估。
- 强调用户影响和合并风险。
输出格式(必填):
1. `## 执行摘要`
- 2-4句话总结整体风险。
- `合并建议:批准|需要修改`
- 如果没有P0/P1级问题,请包含确切文本:`No blocking findings`。
2. `## 发现问题`
- Markdown表格:`ID | 严重程度 | 类别 | 文件:行号 | 问题 | 影响 | 建议修复方案 | 置信度`
- ID格式:G-001, G-002, ...
- 类别:安全 | 正确性 | 性能 | 可靠性 | 测试
3. `## 回归与测试缺口`
- 缺失的测试覆盖和高风险边缘场景。
4. `## 假设条件`
- 仅包含对结论有重大影响的假设。
规则:
- 仅审查修改的代码行。
- 不提供仅涉及风格的反馈。
- 建议的修复方案需具体且可立即执行。Make scripts executable
为脚本添加执行权限
sh
chmod +x .chalk/reviews/scripts/pack.sh .chalk/reviews/scripts/render-prompt.sh .chalk/reviews/scripts/copy-prompt.shsh
chmod +x .chalk/reviews/scripts/pack.sh .chalk/reviews/scripts/render-prompt.sh .chalk/reviews/scripts/copy-prompt.shCreate .chalk/reviews/PIPELINE.md
.chalk/reviews/PIPELINE.md创建.chalk/reviews/PIPELINE.md
文档
.chalk/reviews/PIPELINE.mdWrite a brief usage guide explaining the pipeline, available scripts, and how to add custom reviewer templates. Refresh this on every run.
编写简要使用指南,说明流水线的使用方法、可用脚本以及如何添加自定义审查工具模板。每次运行时更新该文档。
Step 3: Resolve the base branch
步骤3:确定基准分支
- → if it works, use it
git merge-base main HEAD - Try , then
origin/main,masterorigin/master - Store as
{base}
- 执行→ 如果成功,使用该结果
git merge-base main HEAD - 尝试,然后是
origin/main、masterorigin/master - 将结果存储为
{base}
Step 4: Check for a handoff
步骤4:检查交接文档
Look for . If it exists, it will be included in the prompt. If not, warn the user that no handoff was found and suggest running first, but continue anyway.
.chalk/reviews/sessions/{session}/handoff.md/create-handoff查找文件。如果存在,将其包含在提示词中。如果不存在,提醒用户未找到交接文档,并建议先运行,但仍继续执行流程。
.chalk/reviews/sessions/{session}/handoff.md/create-handoffStep 5: Generate the review pack
步骤5:生成审查包
sh
bash .chalk/reviews/scripts/pack.sh "{base}" "{session}" ".chalk/reviews/sessions/{session}/pack.md"sh
bash .chalk/reviews/scripts/pack.sh "{base}" "{session}" ".chalk/reviews/sessions/{session}/pack.md"Step 6: Generate the review prompt
步骤6:生成审查提示词
sh
bash .chalk/reviews/scripts/render-prompt.sh "{reviewer}" \
".chalk/reviews/sessions/{session}/pack.md" \
".chalk/reviews/sessions/{session}/handoff.md" \
".chalk/reviews/sessions/{session}/{reviewer}.prompt.md" \
"{session}"sh
bash .chalk/reviews/scripts/render-prompt.sh "{reviewer}" \
".chalk/reviews/sessions/{session}/pack.md" \
".chalk/reviews/sessions/{session}/handoff.md" \
".chalk/reviews/sessions/{session}/{reviewer}.prompt.md" \
"{session}"Step 7: Copy to clipboard
步骤7:复制到剪贴板
sh
bash .chalk/reviews/scripts/copy-prompt.sh "{reviewer}" \
".chalk/reviews/sessions/{session}/pack.md" \
".chalk/reviews/sessions/{session}/handoff.md" \
".chalk/reviews/sessions/{session}/{reviewer}.prompt.md" \
"{session}"sh
bash .chalk/reviews/scripts/copy-prompt.sh "{reviewer}" \
".chalk/reviews/sessions/{session}/pack.md" \
".chalk/reviews/sessions/{session}/handoff.md" \
".chalk/reviews/sessions/{session}/{reviewer}.prompt.md" \
"{session}"Step 8: Report to the user
步骤8:向用户反馈结果
Show:
- The prompt file path
- Whether it was copied to clipboard
- The reviewer template used (provider-specific or generic)
- Suggest: paste the prompt into the target model, or run with a different provider (e.g. )
/create-review gemini
Also mention:
- To add a custom reviewer, create
.chalk/reviews/templates/{name}-review.template.md - To review with multiple providers: run the skill again with a different argument
展示以下信息:
- 提示词文件路径
- 是否已复制到剪贴板
- 使用的审查工具模板(提供商专属或通用模板)
- 建议:将提示词粘贴到目标AI模型中,或使用其他提供商重新运行(例如)
/create-review gemini
同时说明:
- 要添加自定义审查工具,请创建模板文件
.chalk/reviews/templates/{name}-review.template.md - 要使用多个提供商进行审查:使用不同参数重新运行该工具
Step 9: Save current session
步骤9:保存当前会话
Write the session name to so subsequent runs can pick it up.
.chalk/reviews/.current-session将会话名称写入文件,以便后续运行时可以直接使用该会话。
.chalk/reviews/.current-sessionRules
规则
- Only create template files if they don't already exist — preserve user customizations
- Always refresh scripts (pack.sh, render-prompt.sh, copy-prompt.sh) to latest version
- Always refresh PIPELINE.md to latest version
- Do NOT modify any source code
- If no git changes exist ahead of base, warn the user but still generate (they may have local uncommitted work)
- 仅当模板文件不存在时才创建——保留用户自定义内容
- 始终将脚本(pack.sh、render-prompt.sh、copy-prompt.sh)更新至最新版本
- 始终将PIPELINE.md更新至最新版本
- 不得修改任何源代码
- 如果基准分支之后没有Git变更,提醒用户但仍继续生成(用户可能有本地未提交的修改)