claude-codex-code-review 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/codex-review.md +2 -2
- package/.codex-review.yml +1 -1
- package/README.md +43 -18
- package/bin/codex-review +22 -37
- package/package.json +6 -4
- package/scripts/claude-review.sh +287 -0
- package/scripts/codex-review.sh +1 -1
- package/skills/claude-review/SKILL.md +74 -0
|
@@ -8,7 +8,7 @@ argument-hint: [optional review instructions]
|
|
|
8
8
|
|
|
9
9
|
Run the project Codex review script first:
|
|
10
10
|
|
|
11
|
-
!`scripts/codex-review.sh
|
|
11
|
+
!`scripts/codex-review.sh $ARGUMENTS`
|
|
12
12
|
|
|
13
13
|
Then read `.ai-review/codex-review.md`, `.ai-review/effective-config.env`, and `.codex-review.yml` if they exist.
|
|
14
14
|
|
|
@@ -34,7 +34,7 @@ If the project has no `.codex-review.yml` and the user passes no command argumen
|
|
|
34
34
|
```yaml
|
|
35
35
|
mode: ask
|
|
36
36
|
review_scope: uncommitted
|
|
37
|
-
max_fix_rounds:
|
|
37
|
+
max_fix_rounds: 2
|
|
38
38
|
auto_fix_severities: []
|
|
39
39
|
```
|
|
40
40
|
|
package/.codex-review.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# claude-codex-code-review
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Claude Code 和 Codex CLI 之间的交叉代码审查工具。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- **在 Claude Code 中**:用 `/codex-review` 调用 Codex CLI 审查代码,再由 Claude 修复问题。
|
|
6
|
+
- **在 Codex CLI 中**:用 claude-review skill 调用 Claude 审查代码,再由 Codex 修复问题。
|
|
7
|
+
|
|
8
|
+
典型流程(Claude Code → Codex 审查):
|
|
6
9
|
|
|
7
10
|
1. 你在 Claude Code 里让 Claude 写代码。
|
|
8
11
|
2. 写完后手动运行 `/codex-review`。
|
|
@@ -11,6 +14,15 @@
|
|
|
11
14
|
5. Claude 读取结果,列出问题,并询问你要修复哪些。
|
|
12
15
|
6. 你确认后,Claude 只修复选中的问题。
|
|
13
16
|
|
|
17
|
+
典型流程(Codex CLI → Claude 审查):
|
|
18
|
+
|
|
19
|
+
1. 你在 Codex CLI 里让 Codex 写代码。
|
|
20
|
+
2. 写完后触发 claude-review skill。
|
|
21
|
+
3. Claude 审查当前项目的未提交改动。
|
|
22
|
+
4. review 结果保存到 `.ai-review/claude-review.md`。
|
|
23
|
+
5. Codex 读取结果,列出问题,并询问你要修复哪些。
|
|
24
|
+
6. 你确认后,Codex 只修复选中的问题。
|
|
25
|
+
|
|
14
26
|
## 安装
|
|
15
27
|
|
|
16
28
|
### 全局安装(默认)
|
|
@@ -31,8 +43,8 @@ curl -fsSL https://raw.githubusercontent.com/lkkwxy/claude-codex-claude-codex-re
|
|
|
31
43
|
|
|
32
44
|
全局安装会:
|
|
33
45
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
46
|
+
- 将 `/codex-review` 斜杠命令安装到 `~/.claude/commands/`(Claude Code 使用)
|
|
47
|
+
- 将 `claude-review` skill 安装到 `~/.codex/skills/claude-review/`(Codex CLI 使用)
|
|
36
48
|
- 将 `.ai-review/` 加入全局 gitignore,确保中间文件不会被任何项目提交
|
|
37
49
|
|
|
38
50
|
如果某个项目需要自定义配置,在该项目根目录创建 `.codex-review.yml` 即可。
|
|
@@ -65,14 +77,10 @@ npx claude-codex-code-review install -- --local
|
|
|
65
77
|
npx claude-codex-code-review install -- --target-dir /path/to/project
|
|
66
78
|
```
|
|
67
79
|
|
|
68
|
-
如果需要覆盖已有文件:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
npx claude-codex-code-review install -- --force
|
|
72
|
-
```
|
|
73
|
-
|
|
74
80
|
## 使用
|
|
75
81
|
|
|
82
|
+
### 在 Claude Code 中(用 Codex 审查)
|
|
83
|
+
|
|
76
84
|
安装后,在任意项目里打开 Claude Code,运行:
|
|
77
85
|
|
|
78
86
|
```text
|
|
@@ -85,9 +93,25 @@ npx claude-codex-code-review install -- --force
|
|
|
85
93
|
/codex-review --mode severity --auto-fix-severities P0,P1
|
|
86
94
|
```
|
|
87
95
|
|
|
96
|
+
### 在 Codex CLI 中(用 Claude 审查)
|
|
97
|
+
|
|
98
|
+
安装后,在任意项目里打开 Codex CLI,Codex 会自动发现 `claude-review` skill。你可以:
|
|
99
|
+
|
|
100
|
+
- 直接告诉 Codex「用 Claude 审查我的代码」
|
|
101
|
+
- 通过 `/skills` 菜单选择 `claude-review`
|
|
102
|
+
|
|
88
103
|
## 安装内容
|
|
89
104
|
|
|
90
|
-
|
|
105
|
+
全局安装会写入这些文件:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
~/.claude/commands/codex-review.md
|
|
109
|
+
~/.claude/scripts/codex-review.sh
|
|
110
|
+
~/.codex/skills/claude-review/SKILL.md
|
|
111
|
+
~/.codex/skills/claude-review/claude-review.sh
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
项目级安装会写入这些文件:
|
|
91
115
|
|
|
92
116
|
```text
|
|
93
117
|
.claude/commands/codex-review.md
|
|
@@ -96,11 +120,12 @@ scripts/codex-review.sh
|
|
|
96
120
|
.gitignore
|
|
97
121
|
```
|
|
98
122
|
|
|
99
|
-
|
|
123
|
+
运行审查后,会生成:
|
|
100
124
|
|
|
101
125
|
```text
|
|
102
|
-
.ai-review/codex-review.md
|
|
103
|
-
.ai-review/
|
|
126
|
+
.ai-review/codex-review.md (Codex 审查结果)
|
|
127
|
+
.ai-review/claude-review.md (Claude 审查结果)
|
|
128
|
+
.ai-review/*.log
|
|
104
129
|
.ai-review/effective-config.env
|
|
105
130
|
```
|
|
106
131
|
|
|
@@ -113,7 +138,7 @@ scripts/codex-review.sh
|
|
|
113
138
|
```yaml
|
|
114
139
|
mode: ask
|
|
115
140
|
review_scope: uncommitted
|
|
116
|
-
max_fix_rounds:
|
|
141
|
+
max_fix_rounds: 2
|
|
117
142
|
auto_fix_severities: []
|
|
118
143
|
```
|
|
119
144
|
|
|
@@ -128,7 +153,7 @@ auto_fix_severities: []
|
|
|
128
153
|
```yaml
|
|
129
154
|
mode: ask
|
|
130
155
|
review_scope: uncommitted
|
|
131
|
-
max_fix_rounds:
|
|
156
|
+
max_fix_rounds: 2
|
|
132
157
|
auto_fix_severities: []
|
|
133
158
|
```
|
|
134
159
|
|
|
@@ -165,8 +190,8 @@ codex --help
|
|
|
165
190
|
|
|
166
191
|
## 设计原则
|
|
167
192
|
|
|
168
|
-
- Codex
|
|
169
|
-
-
|
|
193
|
+
- 审查阶段只审查,不修改代码(无论 Codex 审查还是 Claude 审查)。
|
|
194
|
+
- 修复阶段只处理审查方明确指出的问题。
|
|
170
195
|
- 默认不自动修复,先由用户判断。
|
|
171
196
|
- 不自动 commit,最终提交仍由开发者确认。
|
|
172
197
|
- 最多执行配置允许的修复轮次,避免自动循环。
|
package/bin/codex-review
CHANGED
|
@@ -10,9 +10,7 @@ while [ -L "$SOURCE" ]; do
|
|
|
10
10
|
done
|
|
11
11
|
PACKAGE_ROOT="$(cd "$(dirname "$SOURCE")/.." && pwd -P)"
|
|
12
12
|
TARGET_DIR="$(pwd)"
|
|
13
|
-
FORCE=0
|
|
14
13
|
GLOBAL=1
|
|
15
|
-
LOCAL=0
|
|
16
14
|
|
|
17
15
|
usage() {
|
|
18
16
|
cat <<'USAGE'
|
|
@@ -25,14 +23,12 @@ Installs the Claude Code /codex-review command globally (default) or into a spec
|
|
|
25
23
|
Options:
|
|
26
24
|
--local Install into the current project instead of globally.
|
|
27
25
|
--target-dir <dir> Install into a specific project directory (implies --local).
|
|
28
|
-
--force Overwrite existing codex-review files.
|
|
29
26
|
-h, --help Show this help.
|
|
30
27
|
|
|
31
28
|
Examples:
|
|
32
29
|
npx claude-codex-code-review install
|
|
33
30
|
npx claude-codex-code-review install -- --local
|
|
34
31
|
npx claude-codex-code-review install -- --target-dir /path/to/project
|
|
35
|
-
npx claude-codex-code-review install -- --force
|
|
36
32
|
USAGE
|
|
37
33
|
}
|
|
38
34
|
|
|
@@ -53,11 +49,6 @@ copy_file() {
|
|
|
53
49
|
fail "package template is missing: $source_path"
|
|
54
50
|
fi
|
|
55
51
|
|
|
56
|
-
if [ -f "$dest_path" ] && [ "$FORCE" -ne 1 ]; then
|
|
57
|
-
log "Keeping existing $dest_path"
|
|
58
|
-
return
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
52
|
mkdir -p "$(dirname "$dest_path")"
|
|
62
53
|
cp "$source_path" "$dest_path"
|
|
63
54
|
}
|
|
@@ -68,11 +59,9 @@ append_gitignore_once() {
|
|
|
68
59
|
|
|
69
60
|
touch "$gitignore_path"
|
|
70
61
|
if grep -Fxq "$entry" "$gitignore_path"; then
|
|
71
|
-
|
|
72
|
-
else
|
|
73
|
-
printf "\n%s\n" "$entry" >> "$gitignore_path"
|
|
74
|
-
log "Added .gitignore entry: $entry"
|
|
62
|
+
return
|
|
75
63
|
fi
|
|
64
|
+
printf "\n%s\n" "$entry" >> "$gitignore_path"
|
|
76
65
|
}
|
|
77
66
|
|
|
78
67
|
install_global() {
|
|
@@ -92,34 +81,36 @@ install_global() {
|
|
|
92
81
|
mkdir -p "$global_commands_dir"
|
|
93
82
|
mkdir -p "$global_scripts_dir"
|
|
94
83
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
else
|
|
98
|
-
cp "$source_script" "$global_scripts_dir/codex-review.sh"
|
|
99
|
-
chmod +x "$global_scripts_dir/codex-review.sh"
|
|
100
|
-
log "Installed $global_scripts_dir/codex-review.sh"
|
|
101
|
-
fi
|
|
84
|
+
cp "$source_script" "$global_scripts_dir/codex-review.sh"
|
|
85
|
+
chmod +x "$global_scripts_dir/codex-review.sh"
|
|
102
86
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
sed "s|Bash(scripts/codex-review.sh:|Bash(${script_path}:|g;
|
|
107
|
-
s|scripts/codex-review.sh \"\$ARGUMENTS\"|${script_path} \"\$ARGUMENTS\"|g" \
|
|
108
|
-
"$source_template" > "$global_commands_dir/codex-review.md"
|
|
109
|
-
log "Installed $global_commands_dir/codex-review.md"
|
|
110
|
-
fi
|
|
87
|
+
sed "s|Bash(scripts/codex-review.sh:|Bash(${script_path}:|g;
|
|
88
|
+
s|scripts/codex-review.sh |${script_path} |g" \
|
|
89
|
+
"$source_template" > "$global_commands_dir/codex-review.md"
|
|
111
90
|
|
|
112
91
|
local excludes_file
|
|
113
92
|
excludes_file="$(git config --global core.excludesFile 2>/dev/null || true)"
|
|
114
93
|
if [ -z "$excludes_file" ]; then
|
|
115
94
|
excludes_file="$HOME/.gitignore_global"
|
|
116
95
|
git config --global core.excludesFile "$excludes_file"
|
|
117
|
-
log "Set git global core.excludesFile to $excludes_file"
|
|
118
96
|
fi
|
|
119
97
|
append_gitignore_once "$excludes_file"
|
|
120
98
|
|
|
121
|
-
|
|
122
|
-
|
|
99
|
+
local codex_skill_dir="$HOME/.codex/skills/claude-review"
|
|
100
|
+
local source_skill="$PACKAGE_ROOT/skills/claude-review/SKILL.md"
|
|
101
|
+
local source_claude_script="$PACKAGE_ROOT/scripts/claude-review.sh"
|
|
102
|
+
|
|
103
|
+
if [ -f "$source_skill" ] && [ -f "$source_claude_script" ]; then
|
|
104
|
+
mkdir -p "$codex_skill_dir"
|
|
105
|
+
cp "$source_claude_script" "$codex_skill_dir/claude-review.sh"
|
|
106
|
+
chmod +x "$codex_skill_dir/claude-review.sh"
|
|
107
|
+
sed "s|~/.codex/skills/claude-review/claude-review.sh|${codex_skill_dir}/claude-review.sh|g" \
|
|
108
|
+
"$source_skill" > "$codex_skill_dir/SKILL.md"
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
log "Global install complete."
|
|
112
|
+
log "/codex-review is now available in all Claude Code projects."
|
|
113
|
+
log "claude-review skill is now available in Codex CLI."
|
|
123
114
|
}
|
|
124
115
|
|
|
125
116
|
COMMAND="${1:-install}"
|
|
@@ -153,10 +144,6 @@ while [ "$#" -gt 0 ]; do
|
|
|
153
144
|
GLOBAL=0
|
|
154
145
|
shift
|
|
155
146
|
;;
|
|
156
|
-
--force)
|
|
157
|
-
FORCE=1
|
|
158
|
-
shift
|
|
159
|
-
;;
|
|
160
147
|
-h|--help)
|
|
161
148
|
usage
|
|
162
149
|
exit 0
|
|
@@ -182,5 +169,3 @@ chmod +x "scripts/codex-review.sh"
|
|
|
182
169
|
append_gitignore_once ".gitignore"
|
|
183
170
|
|
|
184
171
|
log "Installed /codex-review into $TARGET_DIR"
|
|
185
|
-
log "Usage in Claude Code: /codex-review"
|
|
186
|
-
log "Optional: /codex-review --mode severity --auto-fix-severities P0,P1"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-codex-code-review",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Cross-review between Claude Code and Codex CLI. Provides /codex-review in Claude Code and claude-review skill in Codex CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"claude-codex-code-review": "bin/codex-review"
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
".claude/commands/codex-review.md",
|
|
11
11
|
".codex-review.yml",
|
|
12
12
|
"bin/codex-review",
|
|
13
|
-
"scripts/codex-review.sh"
|
|
13
|
+
"scripts/codex-review.sh",
|
|
14
|
+
"scripts/claude-review.sh",
|
|
15
|
+
"skills/claude-review/SKILL.md"
|
|
14
16
|
],
|
|
15
17
|
"scripts": {
|
|
16
|
-
"test": "bash -n scripts/codex-review.sh scripts/install.sh bin/codex-review"
|
|
18
|
+
"test": "bash -n scripts/codex-review.sh scripts/claude-review.sh scripts/install.sh bin/codex-review"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|
|
19
21
|
"node": ">=18"
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -u
|
|
3
|
+
set -o pipefail
|
|
4
|
+
|
|
5
|
+
OUTPUT_DIR=".ai-review"
|
|
6
|
+
REVIEW_FILE="${OUTPUT_DIR}/claude-review.md"
|
|
7
|
+
LOG_FILE="${OUTPUT_DIR}/claude-review.log"
|
|
8
|
+
EFFECTIVE_CONFIG_FILE="${OUTPUT_DIR}/effective-config.env"
|
|
9
|
+
CONFIG_FILE=".codex-review.yml"
|
|
10
|
+
DEFAULT_MODE="ask"
|
|
11
|
+
DEFAULT_REVIEW_SCOPE="uncommitted"
|
|
12
|
+
DEFAULT_MAX_FIX_ROUNDS="2"
|
|
13
|
+
DEFAULT_AUTO_FIX_SEVERITIES="[]"
|
|
14
|
+
MODE_ARG=""
|
|
15
|
+
REVIEW_SCOPE_ARG=""
|
|
16
|
+
MAX_FIX_ROUNDS_ARG=""
|
|
17
|
+
AUTO_FIX_SEVERITIES_ARG=""
|
|
18
|
+
EXTRA_INSTRUCTIONS=()
|
|
19
|
+
|
|
20
|
+
timestamp() {
|
|
21
|
+
date "+%Y-%m-%d %H:%M:%S %z"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
usage() {
|
|
25
|
+
cat <<'USAGE'
|
|
26
|
+
Usage: claude-review.sh [options] [follow-up instructions]
|
|
27
|
+
|
|
28
|
+
Runs Claude Code review on uncommitted changes and writes the result to
|
|
29
|
+
.ai-review/claude-review.md.
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
--mode <ask|auto|severity>
|
|
33
|
+
Fix policy Codex should apply after reading the review. Default: ask.
|
|
34
|
+
|
|
35
|
+
--review-scope <uncommitted>
|
|
36
|
+
Review scope. Default: uncommitted.
|
|
37
|
+
|
|
38
|
+
--max-fix-rounds <number>
|
|
39
|
+
Maximum automatic fix rounds. Default: 1.
|
|
40
|
+
|
|
41
|
+
--auto-fix-severities <list>
|
|
42
|
+
Comma-separated severities for mode=severity, e.g. P0,P1. Default: empty.
|
|
43
|
+
|
|
44
|
+
-h, --help
|
|
45
|
+
Show this help.
|
|
46
|
+
USAGE
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fail() {
|
|
50
|
+
local message="$1"
|
|
51
|
+
mkdir -p "$OUTPUT_DIR"
|
|
52
|
+
{
|
|
53
|
+
printf "[%s] ERROR: %s\n" "$(timestamp)" "$message"
|
|
54
|
+
} | tee -a "$LOG_FILE" >&2
|
|
55
|
+
exit 1
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
read_config_value() {
|
|
59
|
+
local key="$1"
|
|
60
|
+
local default_value="$2"
|
|
61
|
+
|
|
62
|
+
if [ ! -f "$CONFIG_FILE" ]; then
|
|
63
|
+
printf "%s" "$default_value"
|
|
64
|
+
return
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
local value
|
|
68
|
+
value="$(awk -F ':' -v key="$key" '
|
|
69
|
+
$1 == key {
|
|
70
|
+
sub(/^[[:space:]]+/, "", $2)
|
|
71
|
+
sub(/[[:space:]]+$/, "", $2)
|
|
72
|
+
gsub(/^["'"'"']|["'"'"']$/, "", $2)
|
|
73
|
+
print $2
|
|
74
|
+
exit
|
|
75
|
+
}
|
|
76
|
+
' "$CONFIG_FILE")"
|
|
77
|
+
|
|
78
|
+
if [ -n "$value" ]; then
|
|
79
|
+
printf "%s" "$value"
|
|
80
|
+
else
|
|
81
|
+
printf "%s" "$default_value"
|
|
82
|
+
fi
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
while [ "$#" -gt 0 ]; do
|
|
86
|
+
case "$1" in
|
|
87
|
+
--mode)
|
|
88
|
+
[ "$#" -ge 2 ] || fail "--mode requires a value."
|
|
89
|
+
MODE_ARG="$2"
|
|
90
|
+
shift 2
|
|
91
|
+
;;
|
|
92
|
+
--mode=*)
|
|
93
|
+
MODE_ARG="${1#*=}"
|
|
94
|
+
shift
|
|
95
|
+
;;
|
|
96
|
+
--review-scope)
|
|
97
|
+
[ "$#" -ge 2 ] || fail "--review-scope requires a value."
|
|
98
|
+
REVIEW_SCOPE_ARG="$2"
|
|
99
|
+
shift 2
|
|
100
|
+
;;
|
|
101
|
+
--review-scope=*)
|
|
102
|
+
REVIEW_SCOPE_ARG="${1#*=}"
|
|
103
|
+
shift
|
|
104
|
+
;;
|
|
105
|
+
--max-fix-rounds)
|
|
106
|
+
[ "$#" -ge 2 ] || fail "--max-fix-rounds requires a value."
|
|
107
|
+
MAX_FIX_ROUNDS_ARG="$2"
|
|
108
|
+
shift 2
|
|
109
|
+
;;
|
|
110
|
+
--max-fix-rounds=*)
|
|
111
|
+
MAX_FIX_ROUNDS_ARG="${1#*=}"
|
|
112
|
+
shift
|
|
113
|
+
;;
|
|
114
|
+
--auto-fix-severities)
|
|
115
|
+
[ "$#" -ge 2 ] || fail "--auto-fix-severities requires a value."
|
|
116
|
+
AUTO_FIX_SEVERITIES_ARG="$2"
|
|
117
|
+
shift 2
|
|
118
|
+
;;
|
|
119
|
+
--auto-fix-severities=*)
|
|
120
|
+
AUTO_FIX_SEVERITIES_ARG="${1#*=}"
|
|
121
|
+
shift
|
|
122
|
+
;;
|
|
123
|
+
-h|--help)
|
|
124
|
+
usage
|
|
125
|
+
exit 0
|
|
126
|
+
;;
|
|
127
|
+
--)
|
|
128
|
+
shift
|
|
129
|
+
while [ "$#" -gt 0 ]; do
|
|
130
|
+
EXTRA_INSTRUCTIONS+=("$1")
|
|
131
|
+
shift
|
|
132
|
+
done
|
|
133
|
+
;;
|
|
134
|
+
-*)
|
|
135
|
+
fail "unknown option: $1"
|
|
136
|
+
;;
|
|
137
|
+
*)
|
|
138
|
+
EXTRA_INSTRUCTIONS+=("$1")
|
|
139
|
+
shift
|
|
140
|
+
;;
|
|
141
|
+
esac
|
|
142
|
+
done
|
|
143
|
+
|
|
144
|
+
if ! command -v git >/dev/null 2>&1; then
|
|
145
|
+
fail "git is not available on PATH."
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
149
|
+
fail "current directory is not inside a git repository."
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
if ! command -v claude >/dev/null 2>&1; then
|
|
153
|
+
fail "claude CLI is not available on PATH."
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
MODE="${MODE_ARG:-$(read_config_value "mode" "$DEFAULT_MODE")}"
|
|
157
|
+
REVIEW_SCOPE="${REVIEW_SCOPE_ARG:-$(read_config_value "review_scope" "$DEFAULT_REVIEW_SCOPE")}"
|
|
158
|
+
MAX_FIX_ROUNDS="${MAX_FIX_ROUNDS_ARG:-$(read_config_value "max_fix_rounds" "$DEFAULT_MAX_FIX_ROUNDS")}"
|
|
159
|
+
AUTO_FIX_SEVERITIES="${AUTO_FIX_SEVERITIES_ARG:-$(read_config_value "auto_fix_severities" "$DEFAULT_AUTO_FIX_SEVERITIES")}"
|
|
160
|
+
EXTRA_INSTRUCTIONS_TEXT="${EXTRA_INSTRUCTIONS[*]:-}"
|
|
161
|
+
|
|
162
|
+
case "$MODE" in
|
|
163
|
+
ask|auto|severity) ;;
|
|
164
|
+
*) fail "invalid --mode '$MODE'. Expected ask, auto, or severity." ;;
|
|
165
|
+
esac
|
|
166
|
+
|
|
167
|
+
case "$REVIEW_SCOPE" in
|
|
168
|
+
uncommitted) ;;
|
|
169
|
+
*) fail "invalid --review-scope '$REVIEW_SCOPE'. Only uncommitted is currently supported." ;;
|
|
170
|
+
esac
|
|
171
|
+
|
|
172
|
+
case "$MAX_FIX_ROUNDS" in
|
|
173
|
+
''|*[!0-9]*) fail "invalid --max-fix-rounds '$MAX_FIX_ROUNDS'. Expected a non-negative integer." ;;
|
|
174
|
+
*) ;;
|
|
175
|
+
esac
|
|
176
|
+
|
|
177
|
+
PENDING_CHANGES="$(git status --porcelain)"
|
|
178
|
+
|
|
179
|
+
mkdir -p "$OUTPUT_DIR"
|
|
180
|
+
: > "$LOG_FILE"
|
|
181
|
+
{
|
|
182
|
+
printf "MODE=%s\n" "$MODE"
|
|
183
|
+
printf "REVIEW_SCOPE=%s\n" "$REVIEW_SCOPE"
|
|
184
|
+
printf "MAX_FIX_ROUNDS=%s\n" "$MAX_FIX_ROUNDS"
|
|
185
|
+
printf "AUTO_FIX_SEVERITIES=%s\n" "$AUTO_FIX_SEVERITIES"
|
|
186
|
+
} > "$EFFECTIVE_CONFIG_FILE"
|
|
187
|
+
|
|
188
|
+
{
|
|
189
|
+
printf "[%s] Starting Claude review\n" "$(timestamp)"
|
|
190
|
+
printf "Working directory: %s\n" "$(pwd)"
|
|
191
|
+
printf "Review file: %s\n" "$REVIEW_FILE"
|
|
192
|
+
printf "Log file: %s\n" "$LOG_FILE"
|
|
193
|
+
printf "Effective mode: %s\n" "$MODE"
|
|
194
|
+
printf "Effective review scope: %s\n" "$REVIEW_SCOPE"
|
|
195
|
+
printf "Effective max fix rounds: %s\n" "$MAX_FIX_ROUNDS"
|
|
196
|
+
printf "Effective auto-fix severities: %s\n" "$AUTO_FIX_SEVERITIES"
|
|
197
|
+
if [ -n "$EXTRA_INSTRUCTIONS_TEXT" ]; then
|
|
198
|
+
printf "Extra instructions: %s\n" "$EXTRA_INSTRUCTIONS_TEXT"
|
|
199
|
+
fi
|
|
200
|
+
} >> "$LOG_FILE"
|
|
201
|
+
|
|
202
|
+
if [ ! -f "$CONFIG_FILE" ]; then
|
|
203
|
+
{
|
|
204
|
+
printf "[%s] Config file %s not found; using built-in defaults.\n" "$(timestamp)" "$CONFIG_FILE"
|
|
205
|
+
} >> "$LOG_FILE"
|
|
206
|
+
fi
|
|
207
|
+
|
|
208
|
+
if [ -z "$PENDING_CHANGES" ]; then
|
|
209
|
+
{
|
|
210
|
+
printf "# Claude Review\n\n"
|
|
211
|
+
printf "No staged, unstaged, or untracked changes were found.\n"
|
|
212
|
+
} > "$REVIEW_FILE"
|
|
213
|
+
{
|
|
214
|
+
printf "[%s] No uncommitted changes found; skipped Claude review.\n" "$(timestamp)"
|
|
215
|
+
} >> "$LOG_FILE"
|
|
216
|
+
printf "No uncommitted changes found. Wrote %s\n" "$REVIEW_FILE"
|
|
217
|
+
exit 0
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
DIFF_CONTENT=""
|
|
221
|
+
STAGED_DIFF="$(git diff --cached 2>/dev/null)"
|
|
222
|
+
UNSTAGED_DIFF="$(git diff 2>/dev/null)"
|
|
223
|
+
UNTRACKED_FILES="$(git ls-files --others --exclude-standard 2>/dev/null)"
|
|
224
|
+
|
|
225
|
+
if [ -n "$STAGED_DIFF" ]; then
|
|
226
|
+
DIFF_CONTENT="${DIFF_CONTENT}
|
|
227
|
+
=== Staged Changes ===
|
|
228
|
+
${STAGED_DIFF}"
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
if [ -n "$UNSTAGED_DIFF" ]; then
|
|
232
|
+
DIFF_CONTENT="${DIFF_CONTENT}
|
|
233
|
+
=== Unstaged Changes ===
|
|
234
|
+
${UNSTAGED_DIFF}"
|
|
235
|
+
fi
|
|
236
|
+
|
|
237
|
+
if [ -n "$UNTRACKED_FILES" ]; then
|
|
238
|
+
UNTRACKED_CONTENT=""
|
|
239
|
+
while IFS= read -r file; do
|
|
240
|
+
if [ -f "$file" ]; then
|
|
241
|
+
FILE_CONTENT="$(head -c 10000 "$file" 2>/dev/null)"
|
|
242
|
+
UNTRACKED_CONTENT="${UNTRACKED_CONTENT}
|
|
243
|
+
--- ${file} (new file) ---
|
|
244
|
+
${FILE_CONTENT}"
|
|
245
|
+
fi
|
|
246
|
+
done <<< "$UNTRACKED_FILES"
|
|
247
|
+
if [ -n "$UNTRACKED_CONTENT" ]; then
|
|
248
|
+
DIFF_CONTENT="${DIFF_CONTENT}
|
|
249
|
+
=== Untracked Files ===
|
|
250
|
+
${UNTRACKED_CONTENT}"
|
|
251
|
+
fi
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
REVIEW_PROMPT="You are a senior code reviewer. Review the following uncommitted code changes.
|
|
255
|
+
|
|
256
|
+
For each issue found, assign a severity level:
|
|
257
|
+
- P0: Critical - security vulnerabilities, data loss, crashes
|
|
258
|
+
- P1: High - bugs, logic errors, performance issues
|
|
259
|
+
- P2: Medium - code quality, maintainability concerns
|
|
260
|
+
- P3: Low - style, naming, minor suggestions
|
|
261
|
+
|
|
262
|
+
Format your response as a Markdown document with:
|
|
263
|
+
1. A summary section
|
|
264
|
+
2. Issues grouped by severity (P0, P1, P2, P3)
|
|
265
|
+
3. For each issue: file path, line reference if possible, description, and suggested fix
|
|
266
|
+
|
|
267
|
+
If there are no issues, say so clearly.
|
|
268
|
+
${EXTRA_INSTRUCTIONS_TEXT:+
|
|
269
|
+
Additional review instructions: ${EXTRA_INSTRUCTIONS_TEXT}}"
|
|
270
|
+
|
|
271
|
+
{
|
|
272
|
+
printf "[%s] Running: claude -p (review)\n" "$(timestamp)"
|
|
273
|
+
} >> "$LOG_FILE"
|
|
274
|
+
|
|
275
|
+
if printf "%s" "$DIFF_CONTENT" | claude -p "$REVIEW_PROMPT" > "$REVIEW_FILE" 2>> "$LOG_FILE"; then
|
|
276
|
+
{
|
|
277
|
+
printf "[%s] Claude review completed successfully.\n" "$(timestamp)"
|
|
278
|
+
} >> "$LOG_FILE"
|
|
279
|
+
printf "Claude review completed. Wrote %s\n" "$REVIEW_FILE"
|
|
280
|
+
else
|
|
281
|
+
status=$?
|
|
282
|
+
{
|
|
283
|
+
printf "[%s] Claude review failed with exit code %s.\n" "$(timestamp)" "$status"
|
|
284
|
+
} >> "$LOG_FILE"
|
|
285
|
+
printf "# Claude Review Failed\n\nClaude review failed with exit code %s. See %s for details.\n" "$status" "$LOG_FILE" > "$REVIEW_FILE"
|
|
286
|
+
exit "$status"
|
|
287
|
+
fi
|
package/scripts/codex-review.sh
CHANGED
|
@@ -9,7 +9,7 @@ EFFECTIVE_CONFIG_FILE="${OUTPUT_DIR}/effective-config.env"
|
|
|
9
9
|
CONFIG_FILE=".codex-review.yml"
|
|
10
10
|
DEFAULT_MODE="ask"
|
|
11
11
|
DEFAULT_REVIEW_SCOPE="uncommitted"
|
|
12
|
-
DEFAULT_MAX_FIX_ROUNDS="
|
|
12
|
+
DEFAULT_MAX_FIX_ROUNDS="2"
|
|
13
13
|
DEFAULT_AUTO_FIX_SEVERITIES="[]"
|
|
14
14
|
MODE_ARG=""
|
|
15
15
|
REVIEW_SCOPE_ARG=""
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "claude-review"
|
|
3
|
+
description: "Use Claude to review uncommitted code changes. Invoke this skill when the user asks to review code with Claude, run claude-review, or wants a second opinion from Claude on their changes."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Claude Review
|
|
7
|
+
|
|
8
|
+
Use this skill to review uncommitted code changes using Claude Code.
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- User asks to review code with Claude
|
|
13
|
+
- User wants a code review of their uncommitted changes
|
|
14
|
+
- User mentions "claude-review" or "claude review"
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
1. Run the review script to get Claude's analysis:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
~/.codex/skills/claude-review/claude-review.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. Read the review result from `.ai-review/claude-review.md` and the effective config from `.ai-review/effective-config.env`.
|
|
25
|
+
|
|
26
|
+
3. Also read `.codex-review.yml` in the current project if it exists (project-specific config).
|
|
27
|
+
|
|
28
|
+
4. Summarize whether Claude reported actionable findings.
|
|
29
|
+
|
|
30
|
+
5. If there are no actionable findings, say that clearly and stop.
|
|
31
|
+
|
|
32
|
+
6. If there are actionable findings, list them by severity and include file/line references when Claude provided them.
|
|
33
|
+
|
|
34
|
+
7. Ask the user which findings to fix before editing anything.
|
|
35
|
+
|
|
36
|
+
8. If the user chooses findings to fix, only fix those selected findings.
|
|
37
|
+
|
|
38
|
+
9. Do not perform unrelated refactors.
|
|
39
|
+
|
|
40
|
+
10. Do not create a commit.
|
|
41
|
+
|
|
42
|
+
11. After fixing selected findings, offer to run the review again for confirmation.
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
The review script reads `.codex-review.yml` from the current project directory. If missing, it uses built-in defaults:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
mode: ask
|
|
50
|
+
review_scope: uncommitted
|
|
51
|
+
max_fix_rounds: 2
|
|
52
|
+
auto_fix_severities: []
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Configuration meanings:
|
|
56
|
+
|
|
57
|
+
- `mode: ask` — always ask before fixing.
|
|
58
|
+
- `mode: auto` — automatically fix actionable findings.
|
|
59
|
+
- `mode: severity` — only auto-fix findings matching `auto_fix_severities`; ask for all others.
|
|
60
|
+
- `max_fix_rounds` — limits automatic review/fix loops.
|
|
61
|
+
|
|
62
|
+
The script also accepts command-line options:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
--mode ask|auto|severity
|
|
66
|
+
--review-scope uncommitted
|
|
67
|
+
--max-fix-rounds 1
|
|
68
|
+
--auto-fix-severities P0,P1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Dependencies
|
|
72
|
+
|
|
73
|
+
- git
|
|
74
|
+
- claude (Claude Code CLI, authenticated)
|