Have Gemini and Codex debate the best approach, then synthesize and implement.
Configuration
Arguments: $ARGUMENTS
Check the arguments for flags:
Mode flags:
--dry-run→ debate and plan only, skip implementation--skip-final→ skip the final review phase--rounds N→ number of debate rounds (default: 2, max: 3)
Strip all flags from arguments to get the task description.
Phase 1: Understand the Task (No Questions)
Explore the codebase - use Glob, Grep, Read to understand:
- Relevant files and their structure
- Existing patterns and conventions
- Dependencies and interfaces
Make reasonable assumptions - do NOT ask clarifying questions
- Use best judgment based on codebase context
- Prefer simpler solutions when ambiguous
- Follow existing patterns in the codebase
Prepare context summary - create a brief summary of:
- The task to be implemented
- Relevant files discovered
- Key patterns and conventions in the codebase
- Any constraints or considerations
Phase 2: Opening Arguments
Have both LLMs propose their approach independently (in parallel).
Opening prompt:
I need to implement the following task:
[Task description]
Here's what I found in the codebase:
[Context summary - relevant files, patterns, conventions]
Propose your implementation approach:
1. **Approach**: Describe your recommended approach in 2-3 sentences
2. **Key decisions**: List the main architectural/design decisions
3. **Files**: What files to create or modify
4. **Steps**: High-level implementation steps
5. **Trade-offs**: What are the pros and cons of this approach?
Be specific and opinionated. Defend your choices.
Spawn BOTH as parallel subagents (Agent tool, subagent_type: "general-purpose", model: "sonnet"). Each subagent prompt must include the full opening prompt text and file list so it can make the MCP call independently.
Gemini subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "gemini",prompt: the opening prompt,files: [array of relevant source files] - Return the COMPLETE response including any
[thread_id:xxx]prefix
Codex subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "openai",prompt: the opening prompt,files: [array of relevant source files] - Return the COMPLETE response including any
[thread_id:xxx]prefix
Extract thread IDs: Save gemini_thread_id and codex_thread_id from the [thread_id:xxx] prefixes in the subagent responses.
Phase 3: Debate Rounds
For each round (default 2, configurable with --rounds N, max 3):
Have each LLM critique the other's latest argument (in parallel). Use thread_id to continue each LLM's conversation — they already have full context of the task and their own prior arguments, so you only need to send the opponent's latest response.
Round 1 rebuttal prompt (same for both, swap the opponent's argument):
Your opponent proposed this alternative approach:
[Opponent's opening argument]
Provide a rebuttal:
1. **Critique**: What are the weaknesses in your opponent's approach?
2. **Defense**: Address any weaknesses in your own approach
3. **Concessions**: Are there any good ideas from your opponent worth adopting?
4. **Updated position**: State your refined recommendation
Be constructive but thorough in your critique.
Subsequent round prompt (same for both, swap the opponent's latest rebuttal):
Your opponent has responded to your critique:
[Opponent's latest rebuttal]
Continue the debate:
1. **Critique**: What weaknesses remain in your opponent's updated position?
2. **Defense**: Address any new points raised against your approach
3. **Concessions**: Any new ideas worth adopting?
4. **Updated position**: State your refined recommendation
Focus on unresolved disagreements. Don't repeat settled points.
Spawn BOTH as parallel subagents (Agent tool, subagent_type: "general-purpose", model: "sonnet"). Each subagent prompt must include the full rebuttal prompt text and thread_id.
Gemini subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "gemini",prompt: rebuttal prompt with Codex's latest response as the opponent,thread_id:gemini_thread_id - Return the COMPLETE response including any
[thread_id:xxx]prefix
Codex subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "openai",prompt: rebuttal prompt with Gemini's latest response as the opponent,thread_id:codex_thread_id - Return the COMPLETE response including any
[thread_id:xxx]prefix
Present both responses to the user after each round.
Phase 4: Moderator's Verdict
As the moderator, analyze the debate and synthesize the best approach:
Score the arguments:
- Which approach is simpler?
- Which approach better fits existing patterns?
- Which critiques were valid?
- What concessions were made?
Identify consensus: Where did both LLMs agree?
Resolve disagreements: For each point of contention:
- Evaluate the arguments from both sides
- Pick the stronger position or find a middle ground
- Prefer simpler solutions when arguments are equally strong
Write the verdict as part of the plan:
# [Feature Name] Implementation Plan
**Goal:** [One sentence describing what this builds]
## Debate Summary
**Gemini's position:** [1-2 sentence summary]
**Codex's position:** [1-2 sentence summary]
**Points of agreement:**
- [Consensus point 1]
- [Consensus point 2]
**Resolved disagreements:**
- [Issue]: Gemini said X, Codex said Y → **Verdict:** [Your decision and why]
**Verdict:** [2-3 sentences on the final synthesized approach]
---
### Task 1: [Short description]
**Files:**
- Create: `exact/path/to/file.py`
- Modify: `exact/path/to/existing.py` (lines 123-145)
**Steps:**
1. [Specific action]
2. [Specific action]
**Code:**
```language
// Include actual code, not placeholders
```
---
Guidelines:
- Exact file paths - never "somewhere in src/"
- Complete code - show the actual code
- Small tasks - 2-5 minutes of work each
- DRY, YAGNI - only what's needed
Save the plan to history/plan-<feature-name>.md.
Phase 5: Implement
If --dry-run: Skip to Phase 7 (Summary) - report the debate and plan without implementing.
Implement the plan without further interaction:
- Follow the plan exactly - implement each task in order
- Commit after each logical unit - keep commits small and focused
- If something is unclear - make a reasonable decision and note it in the commit message
- If a task fails - attempt to fix it before moving on
- Only stop if there's a blocking error that cannot be resolved
Implementation rules:
- Work through tasks sequentially
- Test changes when possible
- Keep commits atomic and well-documented
- Use commit messages that explain the "why"
Phase 6: Final Review
If --skip-final: Skip to Phase 7 (Summary).
After implementation, have both LLMs review the result (in parallel). Use thread_id to continue each LLM's conversation — they already have full context of the task and the debate, so you only need to send the review prompt and the diff.
Final review prompt:
Forget which side you argued during the debate. Review the implementation purely on its merits:
- Any obvious bugs or edge cases missed?
- Code quality issues (error handling, naming, structure)?
- Deviations from best practices?
- Security concerns?
Be concise. Only flag issues worth fixing.
Spawn BOTH as parallel subagents (Agent tool, subagent_type: "general-purpose", model: "sonnet"). Each subagent prompt must include the full review prompt, thread_id, and git_diff details.
Gemini subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "gemini",task_mode: "review",prompt: the final review prompt,thread_id:gemini_thread_idfrom Phase 2,git_diff:{ "files": [list of changed files], "base_ref": "HEAD~N" } - Return the COMPLETE response including any
[thread_id:xxx]prefix
Codex subagent — prompt must include:
- Call
mcp__consult-llm__consult_llmwithmodel: "openai",task_mode: "review",prompt: the final review prompt,thread_id:codex_thread_idfrom Phase 2,git_diff:{ "files": [list of changed files], "base_ref": "HEAD~N" } - Return the COMPLETE response including any
[thread_id:xxx]prefix
Apply fixes if both reviewers identify the same issue, or if one raises a clearly valid concern:
- Fix bugs and edge cases
- Commit each fix separately with clear messages
Skip minor style suggestions or conflicting opinions.
Phase 7: Summary
Present a final summary to the user:
## Summary
**Implemented:** [One sentence describing what was built]
**Debate outcome:**
- Gemini advocated: [key position]
- Codex advocated: [key position]
- Final verdict: [synthesized approach]
**Key decisions from debate:**
- [Decision 1 and why]
- [Decision 2 and why]
**Post-implementation fixes:**
- [Fix applied after final review, if any]
**Commits:**
- `abc1234` - [commit message]
- `def5678` - [commit message]
Converted and distributed by TomeVault — claim your Tome and manage your conversions.