Gemini Manager Skill — Collaborative Mode
Codex and Gemini work as a team. Codex analyzes, plans, and implements. Gemini reviews, challenges, and approves. Neither acts alone for major changes.
Architecture
User Request
↓
Codex (Analyze codebase + create plan)
↓
Gemini (Review plan → APPROVE / NEEDS_CHANGES)
↓ ↓
[if questions] [if approved]
↓ ↓
User (Clarify) Codex (Implement)
↓ ↓
← back to Gemini review Gemini (Review changes → APPROVE / REJECT)
↓ ↓
[if approved] [if rejected]
↓ ↓
Done Codex (Fix issues)
↓
← back to Gemini review
Core Principles
<collaboration_rules>
- •Plan before code — Codex creates a concrete implementation plan before writing code.
- •Dual approval required — Gemini must approve the plan and the final changes.
- •User resolves ambiguity — If either model has open product/requirement questions, ask the user.
- •Codex implements — Codex writes code and runs verification.
- •Gemini reviews — Gemini does review/approval only; it does not modify repository files.
- •Iterate to consensus — Keep looping until Gemini approves or the user changes direction.
- •Transparency — Show the user plan and review feedback at each stage.
- •Capacity-aware execution — Keep prompts and diffs reviewable; chunk when needed.
- •Deterministic failure handling — Timeouts, usage limits, and malformed verdicts follow fixed playbooks.
- •Resume-friendly state — Maintain a handoff artifact so work can recover from context loss or usage caps. </collaboration_rules>
Before Starting
Validate environment:
./skills/gemini-manager/scripts/gemini-task.sh --check
This verifies Gemini CLI is available and prints active defaults.
Create a small session state folder (recommended):
mkdir -p .gemini-manager
Important: Headless Shell Context
When this skill is used through Codex tool execution, run Gemini review commands in an unrestricted shell context.
Sandboxed command execution can fail headless auth with Interactive consent could not be obtained even when cached credentials exist.
If that error appears, re-run the exact Gemini review command outside sandbox restrictions.
Operational Guardrails
- •Keep each Gemini review payload focused on one decision.
- •Prefer compact payloads:
- •
review-plan: target <=300 lines. - •
review-changes: target <=500 lines.
- •If payload exceeds those limits, split into batches and add a final reconciliation review.
- •Prefer stdin/heredoc submission for large payloads to avoid shell quoting/arg-size issues.
- •Always include:
- •Goal and scope.
- •Exact files touched.
- •Risks/edge cases.
- •Exact verification commands and outcomes.
- •Store a rolling summary in
.gemini-manager/session-handoff.mdafter each major step.
Workflow
Phase 0: Session Contract
Before planning, establish:
- •Success criteria.
- •Allowed scope boundaries.
- •Whether degraded mode is allowed if Gemini is unavailable.
Phase 1: Codex Analyzes and Creates the Plan
Codex reads relevant code and produces a plan with:
- •Goal
- •Files to modify/create
- •Technical approach and rationale
- •Ordered implementation steps
- •Edge cases/risks
- •Testing/verification strategy
Recommended plan format:
## Implementation Plan **Goal:** [What we're building/changing] **Files:** - `path/to/file.ts` — [what changes] - `path/to/other.ts` — [what changes] **Approach:** [Technical strategy and why] **Steps:** 1. [Step 1] 2. [Step 2] 3. [Step 3] **Edge Cases:** - [Risk or concern] **Testing:** - [How to verify]
Phase 2: Gemini Reviews the Plan
Send the plan to Gemini for review:
cat <<'EOF' | ./skills/gemini-manager/scripts/gemini-task.sh review-plan ## Implementation Plan Goal: [goal] Files: - [files] Approach: [approach] Steps: 1. [steps] Edge Cases: - [risks] Testing: - [verification] CONTEXT — Relevant code: [Include key snippets Gemini needs for plan validation] EOF
Parse Gemini response:
- •
VERDICT: APPROVE→ continue to Phase 3. - •
VERDICT: NEEDS_CHANGES→ revise and re-submit. - •Missing or malformed
VERDICT→ re-submit once with stricter instruction: "Return exactVERDICT:line." - •Timeout/no response → follow the timeout playbook before retrying.
- •If Gemini asks user-facing requirement questions, ask the user and feed answers into the next revision.
Do not implement until Gemini returns APPROVE.
Phase 3: Codex Implements
After plan approval, Codex implements the plan.
Rules:
- •Follow the approved plan.
- •If implementation reveals new constraints that change strategy, update the plan and return to Phase 2 first.
- •Keep
.gemini-manager/session-handoff.mdcurrent after each completed step.
If using a plan file, mark tasks complete as work is verified:
./skills/gemini-manager/scripts/plan-utils.sh complete "Task Name" <plan_file.md>
Phase 4: Gemini Reviews the Changes
After implementation, send a final review package:
cat <<'EOF' | ./skills/gemini-manager/scripts/gemini-task.sh review-changes ## Changes Review **Original Plan:** [Approved plan] **Changes Made:** [List files and edits] **Diff Summary:** [Key diff snippets or concise full diff] **Testing Done:** [What was executed and results] EOF
Parse Gemini response:
- •
VERDICT: APPROVE→ done. - •
VERDICT: REJECT→ Codex fixes issues, then re-submit to Gemini. - •Missing/malformed
VERDICT→ retry once with narrower payload and explicit verdict requirement.
If changes are too large for one review:
- •Submit chunked reviews by logical area (API, DB, UI, etc.).
- •Resolve issues per chunk.
- •Submit one final reconciliation review with consolidated risk/test summary.
Phase 5: Completion
Once Gemini approves:
- •Report what shipped.
- •Summarize issues Gemini flagged and how they were resolved.
- •If using a plan file, show final status:
./skills/gemini-manager/scripts/plan-utils.sh status <plan_file.md>
Session Handoff Artifact
Maintain .gemini-manager/session-handoff.md with this minimal structure:
## Session Handoff Date: [YYYY-MM-DD HH:MM TZ] Task: [current objective] Plan verdict: [APPROVE/NEEDS_CHANGES + timestamp] Change verdict: [APPROVE/REJECT + timestamp] Current step: [where execution paused] Files changed: [list] Verification run: [commands + pass/fail] Open issues: [must-fix items] Next command: [single next action]
Command Reference
Check Environment
./skills/gemini-manager/scripts/gemini-task.sh --check
The helper script enforces model gemini-3-pro-preview for all modes.
Submit Plan for Review
./skills/gemini-manager/scripts/gemini-task.sh review-plan "plan content with context"
Submit Changes for Review
./skills/gemini-manager/scripts/gemini-task.sh review-changes "changes with diff and context"
Legacy: Direct Gemini Pass-through
./skills/gemini-manager/scripts/gemini-task.sh exec "REQUEST: ..."
Plan File Utilities
./skills/gemini-manager/scripts/plan-utils.sh validate <plan_file.md> ./skills/gemini-manager/scripts/plan-utils.sh status <plan_file.md> ./skills/gemini-manager/scripts/plan-utils.sh next <plan_file.md> ./skills/gemini-manager/scripts/plan-utils.sh complete "Task Name" <plan_file.md> ./skills/gemini-manager/scripts/plan-utils.sh list <plan_file.md>
Capacity and Failure Playbooks
Gemini Not Available
If gemini CLI is missing or unhealthy:
- •Run
./skills/gemini-manager/scripts/gemini-task.sh --check. - •Repair Gemini CLI/auth.
- •Retry once with a minimal prompt before full review payload.
- •If still failing, pause for user direction or enter degraded mode only with explicit user approval.
Gemini Timeout or Empty Response
- •Retry once with:
- •Smaller payload.
- •
-tincrease (up to script max).
- •If retry fails, split payload into smaller review batches.
- •If all batches fail, stop dual-review loop and request user decision (wait/retry/degraded mode).
Gemini Usage/Rate Limit (Quota Exhausted)
Symptoms: limit/rate messages, repeated failures without verdict.
Actions:
- •Save handoff artifact immediately.
- •Back off and retry later with smaller payload.
- •Prefer lower reasoning effort/context where acceptable.
- •Resume from plan status and handoff once quota resets.
Codex Context Saturation ("Out of Memory")
Symptoms: forgotten constraints, repeated re-reading, drift from approved plan.
Actions:
- •Stop edits after current atomic change.
- •Update
.gemini-manager/session-handoff.mdwith current status. - •Run:
./skills/gemini-manager/scripts/plan-utils.sh status <plan_file.md> git diff --name-only
- •Restart with handoff + plan status as source of truth.
- •Re-run Gemini review if strategy changed.
Interrupted Session / Crash / Usage Cutoff
Recovery sequence:
- •
git status - •
./skills/gemini-manager/scripts/plan-utils.sh status <plan_file.md> - •Read
.gemini-manager/session-handoff.md - •Resume at the recorded "Next command."
Role Separation
| Codex (Planner + Implementer) | Gemini (Reviewer) |
|---|---|
| Analyzes codebase | Reviews and challenges plans |
| Creates implementation plans | Identifies gaps and risks |
| Asks user for clarification | Raises user-facing questions |
| Writes all code | Does not modify repository files |
| Follows approved plan | Approves or rejects changes |
| Fixes review findings | Verifies fixes in re-review |
Handling Disagreements
If Codex and Gemini disagree on approach:
- •Codex re-submits with explicit reasoning and constraints.
- •Gemini re-evaluates.
- •If unresolved after two rounds, present both approaches to the user and ask for direction.
Degraded Mode (Explicit User Approval Required)
Use only when Gemini review is temporarily impossible (outage/usage cap/consistent timeouts).
- •Explain why dual approval cannot be completed now.
- •Provide risk summary and unreviewed areas.
- •Ask user for explicit approval to proceed in degraded mode.
- •If approved, Codex can continue with:
- •strict scope freeze
- •full local verification
- •mandatory deferred Gemini review when available
- •Record degraded-mode decision in
.gemini-manager/session-handoff.md.
Infinite Review Loop
If Gemini rejects three rounds in a row:
- •Show user repeated findings.
- •Show what has already been tried.
- •Offer 2-3 concrete options with tradeoffs.
- •Wait for user direction before continuing.
Best Practices
<planning_tips>
- •Include concrete file paths, function names, and risks in plan reviews.
- •Include diff snippets plus test output in change reviews.
- •Keep review payloads focused on relevant context.
- •Prefer incremental changes over large monolithic diffs. </planning_tips>
<review_tips>
- •Address valid findings immediately.
- •When disagreeing with a finding, explain constraints and rationale explicitly in the next review submission.
- •Separate must-fix blockers from optional refinements to avoid loop churn. </review_tips>
<capacity_tips>
- •Keep a running context summary; do not rely on long chat history alone.
- •Batch large reviews and merge conclusions in a final reconciliation pass.
- •Favor deterministic templates and checklists over free-form prompts. </capacity_tips>