{"slug": "the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for", "title": "The Delegate Pattern: Run Claude Code + Codex + Gemini in Parallel — Zero-Cost Rate Limit Bypass for Multi-Agent AI", "summary": "A developer known as Lux created the 'delegate pattern' to bypass AI rate limits by running Claude Code, Codex CLI, and Gemini CLI in parallel, using Obsidian Markdown files as an asynchronous communication channel. The approach eliminates single-vendor dependency and context pollution by having child agents return results as files, which the parent agent synthesizes upon completion notifications.", "body_md": "The motivation was simple: **AI stops. Frequently.**\n\nWhen 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.\n\nI 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.\n\nThen it hit me: **concentrating everything in one AI vendor is itself the problem.**\n\nClaude (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.\n\nThis is the **delegate pattern**.\n\nSingle-vendor dependency means hitting ceilings fast. The delegate pattern uses 3 independent API pools, dramatically increasing effective throughput.\n\nDumping 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.\n\nWhen you call `codex exec`\n\n/ `agy --prompt`\n\nvia 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.\n\n```\nLux / Claude Code (parent · orchestrator)\n  ├─ Bash → Codex CLI  → Tasks/codex_xxx.md → Reports/codex_xxx.md\n  └─ Bash → Gemini CLI → Tasks/agy_xxx.md   → Reports/agy_xxx.md\n                              ↓\n               Completion notification → Lux reads all results and synthesizes\n```\n\n**Why Obsidian as the communication channel:**\n\n| Tool | Role | How to get |\n|---|---|---|\nClaude Code |\nParent · orchestrator | claude.ai/code |\nObsidian |\nCommunication channel · persistent log | obsidian.md (free) |\nCodex CLI |\nChild agent A (OpenAI) |\n`npm install -g @openai/codex` → `codex login`\n|\nAGY / Gemini CLI |\nChild agent B (Google) |\n`npm install -g @google/gemini-cli` → `agy login`\n|\n\nNote:Codex requires an OpenAI paid plan. AGY requires a Gemini subscription + CLI install + login (no API key needed).\n\nOnce you're set up, just tell Claude Code:\n\n```\nCreate a skill called \"delegate\".\nRole: I (Lux) am the parent, Codex CLI and AGY CLI are the children.\nTasks are passed via Obsidian Markdown files.\nInclude fire command templates and save to .claude/skills/delegate.md\n```\n\nClaude will interactively create the skill file for you.\n\nCopy the skill file directly from the repository:\n\n```\ngit clone https://github.com/melt1007/claude-delegate-pattern.git\ncp claude-delegate-pattern/skills/delegate.md ~/.claude/skills/\n```\n\nAfter copying, tell Claude Code \"read the delegate skill\" and it will be recognized.\n\nWrite instructions for each agent in separate files:\n\n```\n# Codex Research Task\n\n## Objective\n[What you want researched]\n\n## Output destination\nObsidian/Reports/codex_result_20260726.md\n\n## Constraints\n- Read only: this task file and the specified folder\n- Output: write conclusions, reasoning, and steps separately\n```\n\nTell Claude Code \"delegate and summon\" and the skill automatically runs:\n\n```\n# Launch Codex in background\ncodex exec \"Read Tasks/task_codex.md and write results back\" \\\n  --dangerously-bypass-approvals-and-sandbox \\\n  -o \"codex_out.txt\"\n\n# Launch AGY simultaneously\nagy --prompt \"Read Tasks/task_agy.md and do the work\" \\\n  --dangerously-skip-permissions\n```\n\nBoth start in parallel. Claude Code can respond to your next instruction while waiting for completion.\n\nWhen a child agent completes, Claude Code receives a notification. It reads each report file and synthesizes the results.\n\n| Criterion | agmsg (real-time bus) | delegate pattern (file-based async) |\n|---|---|---|\nReliability |\nSSE connection errors · complex disconnect handling | File I/O only · simple and robust |\nMessage conflicts |\nTiming coordination is hard, conflicts happen | Physically separated · zero conflicts |\nLog persistence |\nDepends on memory · volatile | Persisted in Obsidian · always accessible |\nImplementation cost |\nHigh (bus config · state management required) | Low (only file ops and CLI calls) |\nBest for |\nLow-latency interactive processing | \"Request → deliverable\" tasks: research, implementation, review |\n\nThe delegate pattern in one sentence:\n\n\"Run AIs from different companies in parallel and connect them via Obsidian.\"\n\nThis alone solves all three problems simultaneously: rate limit distribution, context pollution prevention, and reliable completion notifications.\n\n```\nWhat you need:\n✅ Claude Code (free tier available)\n✅ Obsidian (free)\n✅ Codex CLI (OpenAI paid plan)\n✅ AGY / Gemini CLI (Google AI Studio)\n✅ delegate.md (get from repo or have Claude create it)\n```\n\nSimple mechanism. Most reliable and scalable multi-agent approach I've found.\n\n**Repository (skill file · task templates):**\n\n👉 [https://github.com/melt1007/claude-delegate-pattern](https://github.com/melt1007/claude-delegate-pattern)\n\n*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.*\n\n", "url": "https://wpnews.pro/news/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for", "canonical_source": "https://dev.to/m_t_bbe0d7e2206ba4769563b/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-limit-bypass-joh", "published_at": "2026-07-26 17:51:19+00:00", "updated_at": "2026-07-26 18:29:29.296778+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "developer-tools", "large-language-models", "ai-infrastructure"], "entities": ["Claude Code", "Codex CLI", "Gemini CLI", "Anthropic", "OpenAI", "Google", "Obsidian", "Lux"], "alternates": {"html": "https://wpnews.pro/news/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for", "markdown": "https://wpnews.pro/news/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for.md", "text": "https://wpnews.pro/news/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for.txt", "jsonld": "https://wpnews.pro/news/the-delegate-pattern-run-claude-code-codex-gemini-in-parallel-zero-cost-rate-for.jsonld"}}