this setup gives you two custom commands inside claude code:
/review→ git-based code review with codex/criticism→ critique claude's latest response with codex
it also separates the output clearly like this:
-------------------------------------------------
CODEX
(raw codex output)
-------------------------------------------------
CLAUDE
(claude summary / next actions)
/review
-> collect git diff
-> codex reviews it
-> print raw codex output
-> claude summarizes it separately
/criticism
-> claude saves latest response to a file
-> codex critiques it
-> print raw codex output
-> claude summarizes it separately
npm i -g @openai/codex
codexthen log in with your chatgpt account
mkdir -p ~/.claude/commands
mkdir -p ~/bin
chmod 755 ~/binadd ~/bin to your zsh PATH:
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcthis script:
- checks staged diff first
- falls back to working tree diff
- falls back to the latest commit diff
- stores raw codex review in
.agent/review.md - prints a
CODEXsection
cat << 'EOF' > ~/bin/review-with-codex.sh
#!/usr/bin/env zsh
set -euo pipefail
WORK_DIR=".agent"
INPUT_FILE="$WORK_DIR/current.diff"
OUTPUT_FILE="$WORK_DIR/review.md"
mkdir -p "$WORK_DIR"
DIFF=$(git diff --staged || true)
if [[ -z "$DIFF" ]]; then
DIFF=$(git diff || true)
fi
if [[ -z "$DIFF" ]]; then
DIFF=$(git diff HEAD~1 HEAD || true)
fi
if [[ -z "$DIFF" ]]; then
echo "no changes found" > "$OUTPUT_FILE"
echo "-------------------------------------------------"
echo "CODEX"
echo
cat "$OUTPUT_FILE"
exit 0
fi
echo "$DIFF" > "$INPUT_FILE"
PROMPT=$(cat << 'PROMPT'
you are a strict code reviewer
review the following git diff
focus on:
- correctness
- bugs
- edge cases
- security issues
- performance problems
- unclear logic
do not praise
output markdown with sections:
1. critical
2. major
3. minor
4. suggested fixes
if there are no critical or major issues, say exactly:
status: clean
PROMPT
)
{
echo "$PROMPT"
echo
echo "$DIFF"
} | codex exec - > "$OUTPUT_FILE"
echo "-------------------------------------------------"
echo "CODEX"
echo
cat "$OUTPUT_FILE"
echo
EOFchmod +x ~/bin/review-with-codex.shthis script:
- reads
.agent/current.md - asks codex to critique the content
- stores raw codex critique in
.agent/criticism.md - prints a
CODEXsection
cat << 'EOF' > ~/bin/criticism-with-codex.sh
#!/usr/bin/env zsh
set -euo pipefail
WORK_DIR=".agent"
INPUT_FILE="$WORK_DIR/current.md"
OUTPUT_FILE="$WORK_DIR/criticism.md"
mkdir -p "$WORK_DIR"
if [[ ! -f "$INPUT_FILE" ]]; then
echo "no input found" > "$OUTPUT_FILE"
echo "-------------------------------------------------"
echo "CODEX"
echo
cat "$OUTPUT_FILE"
exit 0
fi
CONTENT=$(cat "$INPUT_FILE")
if [[ -z "$CONTENT" ]]; then
echo "input file is empty" > "$OUTPUT_FILE"
echo "-------------------------------------------------"
echo "CODEX"
echo
cat "$OUTPUT_FILE"
exit 0
fi
PROMPT=$(cat << 'PROMPT'
you are a harsh critic
criticize the following content
focus on:
- logical gaps
- missing edge cases
- vague claims
- risky assumptions
- implementation weaknesses
- overconfidence
do not praise
output markdown with sections:
1. critical
2. major
3. minor
4. open questions
PROMPT
)
{
echo "$PROMPT"
echo
echo "$CONTENT"
} | codex exec - > "$OUTPUT_FILE"
echo "-------------------------------------------------"
echo "CODEX"
echo
cat "$OUTPUT_FILE"
echo
EOFchmod +x ~/bin/criticism-with-codex.shcat << 'EOF' > ~/.claude/commands/review.md
run ~/bin/review-with-codex.sh
read .agent/review.md
print exactly:
-------------------------------------------------
CLAUDE
then:
1. summarize only critical and major issues
2. suggest concrete fixes
3. keep it concise
4. if the codex output says "no changes found", just tell me there is nothing to review
EOFcat << 'EOF' > ~/.claude/commands/criticism.md
save your latest substantial response, plan, or explanation from the current session into .agent/current.md
then run ~/bin/criticism-with-codex.sh
read .agent/criticism.md
print exactly:
-------------------------------------------------
CLAUDE
then:
1. summarize only critical and major issues
2. highlight the most important weakness first
3. do not rewrite unless I ask
EOFinside claude code:
/review
/criticism
-------------------------------------------------
CODEX
Critical
1. ...
2. ...
Major
1. ...
2. ...
-------------------------------------------------
CLAUDE
top issue is that your EV conclusion is not supported by the sample size
you should normalize exposure and separate size effects before making the conclusion
.agent/ is runtime output, so ignore it:
.agent/keep .claude/ tracked if you want to share the commands with your team
- codex cannot directly read claude's internal state
- claude and codex communicate through files
/reviewis best for code changes/criticismis best for reasoning / plans / explanations
claude = builder / summarizer
codex = reviewer / critic
.agent = shared runtime state