
如何讓 Claude Code 與 Codex 一起工作
我現在的專案越來越複雜。
一開始,也許只是想做一個工具:把論文 PDF 丟進去,讓 AI 幫我整理、摘要,最後產生科學圖的 prompt。
但慢慢地,這個流程變成一條完整的 pipeline:
- PDF / paper
- Markdown normalization
- section-aware chunking
- vector index
- local LLM summary
- scientific figure prompt
- ComfyUI / 3D / animation workflow
這已經不是單一 script 可以解決的事情。
它牽涉到文件解析、資料結構、chunk 設計、本地模型能力、prompt 工程、圖像生成流程,以及整個專案架構的穩定性。
所以我開始同時使用兩個 AI coding agent:
- Claude Code
- Codex
一個比較適合規劃、檢查架構、思考風險。另一個比較適合執行、修改程式、修 bug、跑測試。
這看起來像是多了一倍能力。但很快會遇到一個問題:
兩個大腦如果沒有共同記憶,反而會互相干擾。
兩個大腦,各自聰明,但不一定合作
Claude Code 可能看了專案後,覺得應該先整理架構。
Codex 可能看了同一個資料夾後,直接開始修某個 bug。
Claude Code 可能想把 pipeline 拆成更清楚的模組。
Codex 可能已經在另一個檔案裡做了快速修改。
兩個 AI 都不是故意破壞專案。它們只是各自根據自己看到的 context 做判斷。
問題是:
- Claude Code 不一定知道 Codex 剛剛改了什麼。
- Codex 不一定知道 Claude Code 剛剛決定了什麼。
如果兩個 agent 沒有共同狀態,它們就像兩個研究員在同一間實驗室工作,但沒有共用實驗紀錄本。
每個人都很努力。但整個專案可能越改越亂。
問題不在 AI 不夠聰明,而在沒有共享工作記憶
這件事讓我意識到:
在複雜專案裡,真正的問題不是「哪個 AI 比較強」。
真正的問題是:
- 它們是否知道目前任務是什麼?
- 它們是否知道誰正在負責?
- 它們是否知道哪些檔案不能亂動?
- 它們是否知道上一個 agent 做了什麼?
- 它們是否知道下一步應該做什麼?
如果沒有這些資訊,再強的 AI 也可能各做各的。
所以我需要的不是更多 agent,而是一個讓 agent 彼此協調的系統。
Markdown 作為兩個大腦的共同白板
解法其實很簡單:
用 Markdown 當作兩個 AI 的共同工作記憶。
在專案根目錄放三個檔案:
- AGENTS.md
- CLAUDE.md
- AI_STATE.md
其中最重要的是:
AI_STATE.md
它不是普通筆記。它是 Claude Code 和 Codex 的共同白板。
它要記錄:
- 目前任務
- 目前負責者
- 被鎖定的檔案
- 最新狀態
- 已完成的修改
- 執行過的測試
- 剩下的問題
- 下一步建議
這樣 Claude Code 進來時,不會像第一次看到這個專案。Codex 進來時,也不會從自己的角度重新發明整個流程。
它們都先讀同一份狀態檔,再決定要做什麼。
三個核心檔案
1. AGENTS.md
這是給 Codex 看的規則。
它告訴 Codex:
- 開始工作前,先讀 AI_STATE.md。
- 不要直接亂改檔案。
- 修改前先寫 plan。
- 修改後要更新 handoff。
2. CLAUDE.md
這是給 Claude Code 看的規則。
它告訴 Claude Code:
- 你的角色通常是 planner / reviewer。
- 不要一開始就大改架構。
- 先檢查專案狀態。
- 先確認 Codex 是否已經在做某個部分。
- 所有重要決策都要寫回 AI_STATE.md。
3. AI_STATE.md
這是兩個大腦真正共享的地方。
它像這樣:
- Current task: Improve Markdown-first paper processing pipeline.
- Current owner: Claude Code.
- Locked files: markdown parser and chunker.
- Latest status: Claude Code is reviewing the architecture.
- Next step: Codex should implement the next module after review.
這個檔案就是兩個大腦之間的交接紀錄。
人類仍然是總指揮
即使有 Claude Code 和 Codex,人類還是最重要的角色。
因為 AI 可以幫忙規劃、實作、檢查、整理,但它不知道真正的研究目標與風險優先順序。
在人類的角色裡,最重要的是:
- 定義目標
- 決定任務優先順序
- 判斷架構是否合理
- 決定哪個 agent 負責哪一段
- 檢查最後結果是否符合研究需求
所以這不是讓 AI 自己亂跑。
而是建立一個分工系統:
- Human:定義方向與判斷結果
- Claude Code:規劃、審查、架構思考
- Codex:實作、修 bug、跑測試
- Markdown:共享工作記憶
- Git:最終變更紀錄
對 notebooklm-comfyUI-3d 的意義
notebooklm-comfyUI-3d 已經不是單純的圖像生成專案。
它比較像一個科學文件到科學視覺化的完整系統。
所以它特別需要避免兩件事:
- 第一,AI 直接亂改架構。
- 第二,兩個 AI 同時修改同一段 pipeline。
因此,我希望這個專案的基本工作模式變成:
- 先寫任務
- 再分配角色
- 再讓一個 agent 工作
- 另一個 agent review
- 最後把狀態寫回 AI_STATE.md
也就是:
Task -> AI_STATE.md -> Claude Code / Codex -> Code change -> Review -> AI_STATE.md
這樣專案才會越做越穩,而不是越做越亂。
這個故事的核心
兩個大腦的合作,不是把兩個 AI 同時丟進同一個資料夾,叫它們自己想辦法。
真正的合作需要三件事:
- 共同任務
- 共同記憶
- 共同規則
Claude Code 和 Codex 都很強。但它們需要一個共同白板。
在這個系統裡,Markdown 就是那個白板。
它讓兩個大腦不是各自思考,而是圍繞同一個專案狀態工作。
這才是真正的多 AI 協作。
How Claude Code And Codex Can Work Together
My project is becoming more and more complex.
At first, I may have only wanted a tool: drop in a paper PDF, let AI organize and summarize it, and then produce prompts for scientific figures.
But over time, that workflow became a full pipeline:
- PDF / paper
- Markdown normalization
- section-aware chunking
- vector index
- local LLM summary
- scientific figure prompt
- ComfyUI / 3D / animation workflow
This is no longer something a single script can solve.
It involves document parsing, data structure design, chunking strategy, local model capability, prompt engineering, image generation workflows, and the stability of the whole project architecture.
So I started using two AI coding agents at the same time:
- Claude Code
- Codex
One is better suited to planning, checking architecture, and thinking through risks. The other is better suited to implementation, editing code, fixing bugs, and running tests.
At first, that looks like twice the capability. But soon a problem appears:
If two brains do not share memory, they can interfere with each other.
Two Brains, Both Smart, But Not Automatically Cooperative
Claude Code may look at the project and decide the architecture should be organized first.
Codex may look at the same folder and immediately start fixing a bug.
Claude Code may want to split the pipeline into clearer modules.
Codex may already have made a quick change in another file.
Neither AI is trying to damage the project. Each one is simply making decisions from the context it can see.
The problem is:
- Claude Code may not know what Codex just changed.
- Codex may not know what Claude Code just decided.
Without shared state, two agents are like two researchers working in the same lab without a shared lab notebook.
Everyone is working hard. But the project can still become more chaotic.
The Problem Is Not Intelligence. It Is Shared Working Memory.
This made me realize something:
In a complex project, the real question is not "which AI is stronger?"
The real questions are:
- Do they know what the current task is?
- Do they know who is responsible?
- Do they know which files should not be touched?
- Do they know what the previous agent did?
- Do they know what should happen next?
Without that information, even strong AI agents can work in separate directions.
So what I needed was not more agents. I needed a coordination system.
Markdown As A Shared Whiteboard
The solution is simple:
Use Markdown as the shared working memory for both AI agents.
Place three files at the project root:
- AGENTS.md
- CLAUDE.md
- AI_STATE.md
The most important one is:
AI_STATE.md
It is not an ordinary note. It is the shared whiteboard between Claude Code and Codex.
It records:
- current task
- current owner
- locked files
- latest status
- completed changes
- commands and tests that were run
- remaining issues
- recommended next step
Then Claude Code does not enter the project as if it were seeing everything for the first time. Codex also does not reinvent the workflow from its own partial angle.
Both agents read the same state file before deciding what to do.
Three Core Files
1. AGENTS.md
This file is for Codex.
It tells Codex:
- Read AI_STATE.md before starting.
- Do not edit files blindly.
- Write a plan before changing things.
- Update the handoff after changing things.
2. CLAUDE.md
This file is for Claude Code.
It tells Claude Code:
- Your role is usually planner and reviewer.
- Do not begin with a large architecture rewrite.
- Inspect the project state first.
- Check whether Codex is already responsible for a task.
- Write important decisions back to AI_STATE.md.
3. AI_STATE.md
This is where the two brains truly share state.
It can record things like:
- Current task: Improve Markdown-first paper processing pipeline.
- Current owner: Claude Code.
- Locked files: markdown parser and chunker.
- Latest status: Claude Code is reviewing the architecture.
- Next step: Codex should implement the next module after review.
This file becomes the handoff record between the two brains.
The Human Is Still The Commander
Even with Claude Code and Codex, the human remains the most important role.
AI can help plan, implement, review, and organize, but it does not know the true research goal or the real priority of risks.
The human role is to:
- define the goal
- decide task priority
- judge whether the architecture is reasonable
- assign which agent owns which part
- check whether the final result matches the research need
So this is not about letting AI run loose.
It is a division of labor:
- Human: direction and judgment
- Claude Code: planning, review, architecture thinking
- Codex: implementation, bug fixing, test execution
- Markdown: shared working memory
- Git: final change history
What This Means For notebooklm-comfyUI-3d
notebooklm-comfyUI-3d is no longer just an image generation project.
It is closer to a complete system for turning scientific documents into scientific visualization.
That means it especially needs to avoid two things:
- First, AI directly rewriting architecture without coordination.
- Second, two AI agents modifying the same pipeline at the same time.
So I want the basic working mode of this project to become:
- write the task
- assign the role
- let one agent work
- let the other agent review
- write the status back to AI_STATE.md
In other words:
Task -> AI_STATE.md -> Claude Code / Codex -> Code change -> Review -> AI_STATE.md
This is how the project becomes more stable over time, instead of more tangled.
The Core Of The Story
Two-brain collaboration does not mean throwing two AI agents into the same folder and hoping they figure it out.
Real cooperation needs three things:
- shared task
- shared memory
- shared rules
Claude Code and Codex are both powerful. But they need a shared whiteboard.
In this system, Markdown is that whiteboard.
It keeps the two brains from thinking separately, and helps them work around the same project state.
That is what real multi-agent collaboration looks like.