- 4
- steps per round
- 3
- max iterations
- 1
- SKILL.md file
Skip to the prompt for Claude Code ↓
Loop kaise chalta hai
Claude: PLAN --> Codex: EXECUTE --> Claude: CHECK --> Codex: IMPROVE
| |
sab pass? STOP <----- nahi to wapas CHECK| Role | Kaun | Kaam |
|---|---|---|
| Planner | Claude | Task ko chhote steps + "done" criteria mein todta hai |
| Executor | Codex | Plan ke mutabiq code likhta hai |
| Checker | Claude | Diff padhta hai, tests chalata hai, issues ki list banata hai |
| Improver | Codex | Sirf us list ke issues fix karta hai |
- Stop condition: checker kahe "sab criteria pass" (tests green + koi issue nahi).
- Max iterations: 3 (cap zaroor lagao, warna loop chalta reh sakta hai aur usage jalta hai).
- Roles ulta bhi kar sakte ho (Codex plan, Claude execute). Concept same hai: ek banata hai, doosra parakhta hai.
Ye cheezein ready rakho
- Claude Code account: Pro, Max, Team, Enterprise ya Console. Free claude.ai plan mein Claude Code nahi hai (docs ke mutabiq).
- Codex ke liye ChatGPT account se sign-in (ya API key). Kaunsa plan Codex deta hai aur kitni limit: check current limits OpenAI ke pricing page pe.
- Node.js 22+ (npm install ke liye) aur Git.
- Ek project folder jo git repo ho.
Claude Code install
irm https://claude.ai/install.ps1 | iexcurl -fsSL https://claude.ai/install.sh | bashNaya terminal kholo, claude --version chalao, phir claude se login karo.
Codex CLI install
npm install -g @openai/codex
codex --version
codex # pehli baar: "Sign in with ChatGPT"macOS/Linux pe OpenAI ka installer bhi hai: curl -fsSL https://chatgpt.com/codex/install.sh | sh.
Claude Codex ko kaise bulata hai
Claude Code Bash se koi bhi CLI chala sakta hai. Codex ka non-interactive mode codex exec hai:
cat .loop/task.md | codex exec --sandbox workspace-write ---sandbox workspace-write= Codex sirf project ki files edit kar sake. Default read-only hai.-ka matlab prompt stdin se aaye (quotes ki jhanjhat nahi).danger-full-accesskabhi mat use karo.
Skill folder banao aur SKILL.md paste karo
mkdir -p ~/.claude/skills/claude-codex-loop(Windows: %USERPROFILE%\.claude\skills\claude-codex-loop.) Sirf ek project ke liye: .claude/skills/claude-codex-loop/ project ke andar. Phir usme SKILL.md banao:
---
name: claude-codex-loop
description: Run a plan/execute/check/improve loop where Claude plans and checks and Codex executes and improves. Use when the user asks for the Claude x Codex loop.
disable-model-invocation: true
argument-hint: "[task description]"
allowed-tools: Bash(codex exec *) Bash(git *)
---
Task: $ARGUMENTS
Rules: max 3 iterations. Never touch .env or secrets. Codex runs only with --sandbox workspace-write.
1. PLAN (you, Claude): write .loop/plan.md with small steps and a "Done when" list
of testable criteria (tests pass, lint clean, specific behavior works).
Make sure we are on a new git branch first.
2. EXECUTE (Codex): run
cat .loop/plan.md | codex exec --sandbox workspace-write -
with the instruction "Implement this plan. Do not change anything outside it."
3. CHECK (you, Claude): read `git diff`, run the project's tests/lint, compare with
"Done when". Write .loop/issues.md: PASS or a numbered list of concrete problems.
4. IMPROVE (Codex): if issues exist, run
cat .loop/issues.md | codex exec --sandbox workspace-write -
with "Fix only these issues." Then go back to step 3.
5. STOP when CHECK says PASS or after 3 iterations. Report: iterations used, what
changed, anything still failing. Do not commit; leave the diff for the human.Claude Code skills docs ke mutabiq disable-model-invocation: true ka matlab skill sirf tum manually chalate ho. allowed-tools sirf us ek turn ke liye pre-approve karta hai.
Chalao
Claude Code kholo (project folder mein) aur:
/claude-codex-loop add a /health endpoint with a testWorked example
Task: "Express app mein /health endpoint + test."
- Plan: Claude
.loop/plan.mdbanata hai: route add, Jest test, "Done when:npm testpass, GET /health = 200{status:"ok"}". - Execute: Codex route aur test likhta hai.
- Check: Claude tests chalata hai. Test fail: response JSON key galat.
issues.mdmein 1 issue. - Improve: Codex sirf wo fix karta hai.
- Check (round 2): PASS. Loop stop. Tum
git diffkhud review karte ho.
(Ye illustration hai, koi guaranteed result nahi.)
Safety
- Diff khud review karo commit se pehle. Checker bhi AI hai, galat ho sakta hai.
- Prod secrets mat do:
.env, API keys, production DB URL agents ke paas na hon. Alag dev keys use karo. - Iteration cap (3) aur chhota task: loop ka har round dono taraf usage khata hai.
- Naye git branch pe chalao taake wapas ja sako.
danger-full-accessya "sab approve" mode avoid karo.
Common Mistakes
- Vague task: "app better banao". "Done when" measurable likho.
- Cap nahi lagaya: loop atak ke usage jala deta hai.
- Checker ke paas tests hi nahi: phir "PASS" ka matlab kuch nahi.
- Executor ko poora folder + secrets access de diya.
- Ek round mein bohot bada task. Chhote tasks mein todo.
- Codex login/install bhoole,
codex: command not found:codex --versionpehle check karo. - Diff review kiye bina merge.
Checklist
- Claude Code install + login (
claude --version) - Codex CLI install + sign-in (
codex --version) - Project git repo hai, naya branch bana
-
~/.claude/skills/claude-codex-loop/SKILL.mdpaste kiya -
.env/secrets agents se door - Max iterations = 3
- Task chhota, "Done when" measurable
-
/claude-codex-loop <task>chalaya, diff review kiya
Using Claude Code or Codex?
Paste this. Let your agent set it up.
Set up the Claude x Codex loop skill from https://theaikhan.com/guides/claude-codex-loop
1. Run `claude --version` and `codex --version`. If one is missing, stop and tell me how to install it.
2. Create ~/.claude/skills/claude-codex-loop/SKILL.md with the exact SKILL.md from the guide.
3. Never read or touch .env files or secrets.
4. When done, tell me to open my project on a new git branch and run:
/claude-codex-loop <small task with a clear "done when">