Gemini CLI Delegation & Large Context Routing
Purpose & When-To-Use
Trigger Conditions:
Use this skill for fast delegation decisions when:
- Large file analysis: Single file >100KB
- Analysis/review tasks: Summarization, comprehension, codebase review
- Sandbox code testing: Safe execution of unfamiliar code
Do NOT use when:
- File <100KB and task is edit/refactor/debug (Claude excels here)
- Multi-file orchestration needed (use separate orchestration agent)
- Real-time debugging or iterative refinement
Pre-Checks
Timestamp & Environment
NOW_ET = 2025-10-26T01:18:53-04:00 (America/New_York, ISO-8601)
Required validations before delegation:
- Input schema validation:
task_descriptionis non-empty stringfile_paths(if provided) resolve to accessible files
- Security pre-flight:
- Scan file paths for patterns like
.env,credentials.json,*.key,*.pem - Abort if secrets detected; prompt user to sanitize
- Scan file paths for patterns like
Procedure
Token Budget: T1≤2000 tokens
Tier 1 — Fast Delegation Decision (T1≤2000 tokens)
Two-step process:
-
Delegation gate (primary decision):
- If file size >100KB → delegate to Gemini
- If task type =
analysis|review|summarize|codebase-review→ delegate to Gemini - Else → keep in Claude
-
Format output:
- If delegating: emit
delegation_commandfor Gemini MCP - Else: emit
recommended_tool: "claude" - Include brief rationale citing threshold
- If delegating: emit
Decision Rules
Primary Routing Logic:
| Condition | Threshold | Action |
|---|---|---|
| File size | >100KB | Delegate to Gemini |
| Task type | analysis, review, summarize, codebase-review |
Delegate to Gemini |
| Sandbox execution | Any code testing | Delegate to Gemini |
| Otherwise | Default | Keep in Claude |
Note: Complex multi-file orchestration belongs in a separate orchestration agent, not this skill.
Abort Conditions:
- Secrets detected in file paths or task description
Output Contract
Schema (TypeScript-style):
interface DelegationResult {
delegation_decision: boolean; // true = delegate to Gemini
recommended_tool: "claude" | "gemini-mcp";
delegation_command?: string; // only if delegation_decision = true
rationale: string; // max 160 chars, cites threshold
security_flags: string[]; // empty if clean; else warnings
}
Required fields:
delegation_decision,recommended_tool,rationale,security_flags(always)delegation_command(only ifdelegation_decision = true)
Examples
Example 1: Large File Analysis (Delegate)
# Input
task_description: "Summarize research paper"
file_paths: ["./paper.pdf"]
context_size_estimate: 3500 # KB
# Output
{
"delegation_decision": true,
"recommended_tool": "gemini-mcp",
"delegation_command": "ask gemini to analyze @./paper.pdf and summarize key findings",
"rationale": "File size 3.5MB > 100KB threshold",
"security_flags": []
}
Example 2: Small File Edit (Keep in Claude)
# Input
task_description: "Refactor authentication function"
file_paths: ["./auth.py"]
context_size_estimate: 45 # KB
# Output
{
"delegation_decision": false,
"recommended_tool": "claude",
"rationale": "File <100KB and task type 'refactor' suits Claude precision",
"security_flags": []
}
Quality Gates
Token Budget Enforcement:
- Token budget: T1≤2k tokens for fast delegation decision (T2/T3 not applicable - skill simplified to T1 only)
- Examples must be ≤30 lines each (including fences)
Safety Checks:
- No API keys or secrets in delegation_command
- PII screening if task involves user data
- Sandbox isolation for code execution tasks
Determinism:
- Same inputs (file size, task type) must produce same delegation decision
- Rationale must cite specific threshold (e.g., "File size >100KB")
Resources
Primary Sources:
- Gemini MCP Tool Repository — MCP server implementation, CLI integration (accessed 2025-10-26T01:18:53-04:00)
- Gemini API Long Context Documentation — 1M token context window (accessed 2025-10-26T01:18:53-04:00)
- Model Context Protocol - Claude Docs — MCP specification (accessed 2025-10-26T01:18:53-04:00)
Configuration Templates:
resources/mcp-config-template.json— Claude Desktop MCP setup for gemini-mcp-toolresources/delegation-decision-matrix.md— Static reference table (not computed during skill execution)
More from williamzujkowski/cognitive-toolworks
ux wireframe designer
Design user experience wireframes, user flows, and interactive mockups for web and mobile applications using industry-standard notation
2database schema designer
Design normalized database schemas with ERDs, migration plans, and indexing strategies for relational and document databases
1rust safety & performance analyzer
Review Rust code for memory safety, concurrency patterns, performance optimization, and ecosystem tooling (cargo, clippy, rustfmt).
1multi-cloud cost optimizer
Optimize costs across AWS, GCP, Azure with cross-cloud waste detection, workload placement, commitment balancing, and unified FinOps.
1cryptographic security validator
Validate cryptographic implementations using NIST standards with TLS configuration, cipher suite analysis, and certificate lifecycle checks.
1observability stack configurator
Configure comprehensive observability with metrics, logging, tracing, and alerting using Prometheus, OpenTelemetry, CloudWatch, and Grafana.
1