Keeping AI Running Without Letting It Drift Is Hard#
After using tools such as Claude Code and Codex for a while, it is tempting to let them run continuously. The problem is that they may write in the wrong direction, skip validation, or overflow the useful context window during long runs. To address this, I designed a workflow where Claude Code supervises Codex.
This idea is suitable for iterative development from 1 to n. For a 0 to 1 new project, I still recommend doing the early work yourself or watching the model closely.
| |
Choose the Right Tools#
My own setup includes ChatGPT Plus, Codex access, and GLM coding plan lite, which can be configured in Claude Code. I also have Gemini, but my personal experience with Gemini CLI is average, so this article demonstrates Claude Code + Codex.
- GLM coding plan: large quota, and I rarely hit the limit.
- Claude Code: sometimes finishes too early.
- Codex: relatively steadier, but more expensive, so use it carefully.
For the Codex model, I recommend ChatGPT-5.2-medium. Officially, Codex-suffix models are optimized for coding and agent tasks1, but my own test results were not ideal. medium is close to “Auto.” You can choose high, but avoid Xhigh; it worked well in my test but burned through a week of quota in one day.
Overall Idea#
Role split: Claude Code acts as Supervisor, and Codex acts as Worker.
The real danger is not that the model cannot write code, but that it thinks it is finished when it only made something that looks complete, skips reproducible validation, or drifts confidently until the human receives a mess. Splitting the work across two agents reduces this risk: one writes, one accepts.
Startup: the process begins with an OpenSpec change proposal generated by Codex. The proposal is transformed into tasks in tasks.md. When a task needs execution, Claude Code starts a worker call through codex exec and invokes OpenSpec in natural language. OpenSpec 0.21.0 is preferred because newer versions changed the workflow and use skills triggers2.
Execution and delivery: after Codex writes code, it must create a reproducible validation bundle under auto_test_openspec.
- CLI tasks must include an automated script, usually
run.sh. - GUI tasks must include a Markdown MCP operation procedure and a script only for starting the service.
Acceptance: Claude Code personally runs the scripts. For GUI tasks, it follows the MCP procedure, drives a browser with playwright-mcp, and captures screenshots as evidence3.
Only after Claude Code confirms the validation bundle passes and the evidence chain is complete can it check tasks, update feature_list.json, commit/archive, and write evidence pointers into progress.txt.
Directory structure:
| |
Memory Design#
Each task uses a separate worker context to avoid context pollution. Memory is handled through three files:
tasks.mdis task memory and the process source of truth.progress.txtis append-only process memory for handoffs, validation results, failures, and blockers.feature_list.jsonis the authoritative feature-state ledger. Worker may read it, but only Supervisor updates it after validation passes3.
A useful startup ritual is to require Worker to read progress.txt, feature_list.json, and recent Git history before starting, then write worker_startup.txt as evidence that previous context was inspected.
Two Layers of Anti-Drift Insurance#
| Feature | tasks.md | feature_list.json |
|---|---|---|
| Core role | Execution layer | Management state layer |
| Granularity | Fine task steps | Coarse feature refs |
| Worker permission | May add delivery bundle paths | Must not modify |
| Supervisor permission | Checks boxes and writes evidence | Sets passes to true after validation |
| Format | Markdown | JSON |
| Lifecycle | Dynamic logs and retries | Changes only after real PASS |
The two ledgers are connected through Ref tags such as [#R1]. A task line in tasks.md maps to a corresponding feature ref in feature_list.json. Supervisor must first verify the task evidence in tasks.md; only then can it update the feature state.
Initial Configuration#
Install Claude Code, Codex, and OpenSpec. For OpenSpec, I recommend version 0.21.0 for this workflow.
| |
For GUI or mixed tasks, configure playwright-mcp so Supervisor can operate the browser and collect screenshots instead of relying on manual clicks. A Context7 MCP server is also useful when the agent needs documentation during a blocker.
The workflow also uses repository skills for requirement interviewing, feature-list generation, and unblock research:
Repeated Workflow#
Open Codex and ask it to create a change proposal, for example: Create an OpenSpec proposal for adding automatic night-mode switching to this project.
Then run $openspec-change-interviewer <id> so the model interviews you and aligns requirements. The <id> is the current proposal folder name under openspec/changes.
Next, run $openspec-feature-list <id> so the model generates feature_list.json.
Finally, open Claude Code and run /monitor-openspec-codex <id>.
<id>is the folder name of the current proposal underopenspec/changes.










