Why I Built This
The motivation was simple: AI stops. Frequently.
When running large tasks with Claude Code, you hit Anthropic’s rate limits fast. When you add more sub-agents to run in parallel, Claude’s own context gets polluted and performance degrades.
I also tried a real-time message bus (agmsg). Multiple CLI windows throwing messages caused confusion. SSE connections dropped, losing notifications. Infrastructure maintenance cost was too high.
Then it hit me: concentrating everything in one AI vendor is itself the problem.
Claude (Anthropic), Codex (OpenAI), and AGY/Gemini (Google) each have independent APIs and rate limit pools. Run them in parallel, and when one hits its limit, the others keep going. Use files as the communication channel, and there’s no confusion or disconnection.
This is the delegate pattern.
The 3 Problems It Solves
Problem 1: Rate Limits
Single-vendor dependency means hitting ceilings fast. The delegate pattern uses 3 independent API pools, dramatically increasing effective throughput.
Problem 2: Context Pollution
Dumping all research logs and code output into the parent agent’s context makes it forget earlier instructions. In the delegate pattern, child agents run in separate processes and return only their results as files.
Problem 3: Missed Notifications / Message Confusion
When you call codex exec / agy --prompt via Bash, Claude Code recognizes them as sub-agents. Claude Code’s built-in completion notification infrastructure handles everything automatically — no Monitor tool or custom polling loops needed.
Architecture Overview
Lux / Claude Code (parent · orchestrator)
├─ Bash → Codex CLI → Tasks/codex_xxx.md → Reports/codex_xxx.md
└─ Bash → Gemini CLI → Tasks/agy_xxx.md → Reports/agy_xxx.md
↓
Completion notification → Lux reads all results and synthesizes
Enter fullscreen mode Exit fullscreen mode
Why Obsidian as the communication channel:
- Each agent gets a dedicated file path → message confusion is physically impossible
- Even if Claude Code’s context disappears, reading Obsidian files restores full context
- The human (developer) can check it at any time — it serves as a permanent evidence log
What You Need (Setup)
Tool Role How to get Claude Code Parent · orchestrator claude.ai/code Obsidian Communication channel · persistent log obsidian.md (free) Codex CLI Child agent A (OpenAI)npm install -g @openai/codex → codex login
AGY / Gemini CLI
Child agent B (Google)
npm install -g @google/gemini-cli → agy login
Note: Codex requires an OpenAI paid plan. AGY requires a Gemini subscription + CLI install + login (no API key needed).
Let Claude Build the Skill
Once you’re set up, just tell Claude Code:
Create a skill called "delegate".
Role: I (Lux) am the parent, Codex CLI and AGY CLI are the children.
Tasks are passed via Obsidian Markdown files.
Include fire command templates and save to .claude/skills/delegate.md
Enter fullscreen mode Exit fullscreen mode
Claude will interactively create the skill file for you.
Want to skip setup?
Copy the skill file directly from the repository:
git clone https://github.com/melt1007/claude-delegate-pattern.git
cp claude-delegate-pattern/skills/delegate.md ~/.claude/skills/
Enter fullscreen mode Exit fullscreen mode
After copying, tell Claude Code “read the delegate skill” and it will be recognized.
Running It
Step 1: Create a task file in Obsidian
Write instructions for each agent in separate files:
# Codex Research Task
## Objective
[What you want researched]
## Output destination
Obsidian/Reports/codex_result_20260726.md
## Constraints
- Read only: this task file and the specified folder
- Output: write conclusions, reasoning, and steps separately
Enter fullscreen mode Exit fullscreen mode
Step 2: Parallel fire from Claude Code
Tell Claude Code “delegate and summon” and the skill automatically runs:
# Launch Codex in background
codex exec "Read Tasks/task_codex.md and write results back"
--dangerously-bypass-approvals-and-sandbox
-o "codex_out.txt"
# Launch AGY simultaneously
agy --prompt "Read Tasks/task_agy.md and do the work"
--dangerously-skip-permissions
Enter fullscreen mode Exit fullscreen mode
Both start in parallel. Claude Code can respond to your next instruction while waiting for completion.
Step 3: Receive completion → synthesize
When a child agent completes, Claude Code receives a notification. It reads each report file and synthesizes the results.
Comparison with Real-Time Bus (agmsg)
Criterion agmsg (real-time bus) delegate pattern (file-based async) Reliability SSE connection errors · complex disconnect handling File I/O only · simple and robust Message conflicts Timing coordination is hard, conflicts happen Physically separated · zero conflicts Log persistence Depends on memory · volatile Persisted in Obsidian · always accessible Implementation cost High (bus config · state management required) Low (only file ops and CLI calls) Best for Low-latency interactive processing “Request → deliverable” tasks: research, implementation, reviewSummary
The delegate pattern in one sentence:
“Run AIs from different companies in parallel and connect them via Obsidian.”
This alone solves all three problems simultaneously: rate limit distribution, context pollution prevention, and reliable completion notifications.
What you need:
✅ Claude Code (free tier available)
✅ Obsidian (free)
✅ Codex CLI (OpenAI paid plan)
✅ AGY / Gemini CLI (Google AI Studio)
✅ delegate.md (get from repo or have Claude create it)
Enter fullscreen mode Exit fullscreen mode
Simple mechanism. Most reliable and scalable multi-agent approach I’ve found.
Repository (skill file · task templates):
👉 https://github.com/melt1007/claude-delegate-pattern
This article was written using the delegate pattern itself. Claude Code (Lux) acted as orchestrator, generating 3 drafts in parallel — Codex, AGY, and Lux — then synthesizing them into this final version.
Enter fullscreen mode Exit fullscreen mode
답글 남기기