Skip to content

Instantly share code, notes, and snippets.

@graykode
Last active March 27, 2026 03:54
Show Gist options
  • Select an option

  • Save graykode/06ea008b11ec331fd36f9a9ba53b252a to your computer and use it in GitHub Desktop.

Select an option

Save graykode/06ea008b11ec331fd36f9a9ba53b252a to your computer and use it in GitHub Desktop.

claude code + codex CLI workflow

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)

overview

/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

1. install codex

npm i -g @openai/codex
codex

then log in with your chatgpt account


2. setup directories

mkdir -p ~/.claude/commands
mkdir -p ~/bin
chmod 755 ~/bin

add ~/bin to your zsh PATH:

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

3. create /review script

this 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 CODEX section
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
EOF
chmod +x ~/bin/review-with-codex.sh

4. create /criticism script

this script:

  • reads .agent/current.md
  • asks codex to critique the content
  • stores raw codex critique in .agent/criticism.md
  • prints a CODEX section
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
EOF
chmod +x ~/bin/criticism-with-codex.sh

5. create claude commands

/review

cat << '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
EOF

/criticism

cat << '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
EOF

6. usage

inside claude code:

/review
/criticism

7. example output

-------------------------------------------------
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

8. recommended .gitignore

.agent/ is runtime output, so ignore it:

.agent/

keep .claude/ tracked if you want to share the commands with your team


notes

  • codex cannot directly read claude's internal state
  • claude and codex communicate through files
  • /review is best for code changes
  • /criticism is best for reasoning / plans / explanations

summary

claude = builder / summarizer
codex = reviewer / critic
.agent = shared runtime state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment