Research-first planning for any task. Spawns parallel sub-agents to explore the codebase, checks past solutions, asks clarifying questions, then produces a structured plan stored in docs/plans/. Use when starting any non-trivial task: "plan this feature", "how should we approach...", "let's think through...", or before any multi-file change. Do NOT use for trivial single-file edits or questions that need no planning. Supports multi-LLM mode — offloads codebase exploration and learnings research to Gemini CLI to preserve Claude's token limits.
Transform feature descriptions, bug reports, or improvement ideas into well-structured, research-grounded implementation plans.
Inspired by the compound engineering philosophy: "80% planning and research, 20% execution."
Activate when:
Never plan in the dark. Every plan should be grounded in:
docs/solutions/)This skill supports multi-LLM delegation to reduce Claude token consumption.
.claude/llm-mode.json — if mode is "multi", use the Gemini-Delegated Path belowmode is "single" or file doesn't exist, skip to the Standard Path (the Planning Process section below)In multi mode, Phase 1 Research Tracks A and C are delegated to Gemini CLI. Tracks B and D stay with Claude (B calls /brief which has its own delegation; D needs live package.json checks).
Track A (Codebase Exploration) → Gemini:
Adjust the @folders based on the task. For a typical feature, use @web/src/app/ @web/src/lib/ @web/src/components/. For DB tasks, add @supabase/. For animation tasks, use @web/src/remotion/.
START_TIME=$(date +%s)
# Generate core rules for Gemini context
CORE_RULES=""
for p in "$HOME/Documents/Dev/lex/scripts/generate-core-rules.sh" "/Volumes/Home/Lex - DO NOT TOUCH/Dev/lex/scripts/generate-core-rules.sh"; do
[ -f "$p" ] && CORE_RULES=$("$p" 2>/dev/null) && break
done
echo "You are exploring a codebase for Golden Corpus, a portfolio of AI products. Here are the behavioral rules and known failure patterns to consider:
${CORE_RULES:-No core rules available.}
---
Explore this Next.js codebase for the following task: [INSERT TASK DESCRIPTION].
Find and report:
1. Files that will need changes (with paths and relevant code excerpts)
2. Existing patterns for similar functionality (show examples)
3. Related tests, types, and utilities
4. Technical debt in the affected areas
5. Any configuration or environment variables relevant to this task
Include file paths and code excerpts for every finding." | npx @google/gemini-cli -m gemini-2.5-pro -p "" @web/src/app/ @web/src/lib/ @web/src/components/ -o text > .gemini_temp_plan_track_a.md 2>/dev/null
DURATION_A=$(($(date +%s) - START_TIME))
Track C (Learnings Research) → Gemini:
START_TIME=$(date +%s)
# Core rules already loaded above (from Track A)
echo "You are searching documentation for Golden Corpus projects. Use the behavioral rules and failure patterns from context.
Search these documentation directories for anything relevant to: [INSERT TASK DESCRIPTION].
Look for:
1. Previously solved similar problems (with solution details)
2. Past decisions that constrain or inform this work
3. Best practices documented for this type of task
4. Known issues or gotchas in the affected areas
Quote relevant passages and cite file paths for every finding." | npx @google/gemini-cli -m gemini-2.5-pro -p "" @docs/solutions/ @docs/decisions/ -o text > .gemini_temp_plan_track_c.md 2>/dev/null
DURATION_C=$(($(date +%s) - START_TIME))
Tracks A and C can run sequentially (they use the same CLI). Track B (/brief) and Track D (dependency check) continue as normal Claude tasks in parallel.
After Gemini delegation completes:
rm -f .gemini_temp_plan_track_a.md .gemini_temp_plan_track_c.mdLog the delegation:
Append to .claude/delegation.log and update stats in .claude/llm-mode.json:
For successful delegations:
TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
DURATION=$(($(date +%s) - START_TIME))
echo "$TIMESTAMP | plan | ok | ${DURATION}s | Track A codebase exploration for: [short task description]" >> .claude/delegation.log
python3 -c "
import json, datetime
f='.claude/llm-mode.json'