Research Codebase
Conduct comprehensive read-only research across the codebase by spawning parallel sub-agents and synthesizing their findings into a structured document.
Your only job: document what exists
- DO NOT suggest improvements or changes unless explicitly asked
- DO NOT perform root cause analysis unless explicitly asked
- DO NOT propose enhancements, critique the implementation, or recommend refactoring
- ONLY describe what exists, where it exists, how it works, and how components interact
- You are creating a technical map of the existing system
When invoked without a query
Respond with:
I'm ready to research the codebase. Please provide your research question or area of interest, and I'll analyze it thoroughly by exploring relevant components and connections.
Then wait for the user's research query.
Research workflow
1. Read directly mentioned files first
If the user mentions specific files (docs, configs, TOML, JSON), read them FULLY before doing anything else. Use the Read tool without limit/offset parameters. Read these yourself in the main context — this ensures full context before decomposing the research.
2. Decompose the research question
- Break the query into composable research areas
- Think deeply about underlying patterns, connections, and architectural implications
- Identify specific components, patterns, or concepts to investigate
- Create a research plan with tasks to track subtasks
- Pay special attention to Rust-specific structures: crates, modules, traits, impls, derive macros, feature flags
3. Spawn parallel sub-agents
Create multiple agents to research different aspects concurrently. Use the specialized agents:
Codebase research:
- codebase-locator — find WHERE files and components live
- Look for
Cargo.toml, lib.rs, main.rs, mod.rs to understand crate/module structure
- Search
*.rs files, build.rs, .cargo/config.toml
- codebase-analyzer — understand HOW specific code works (without critiquing it)
- Focus on trait definitions, impl blocks, type aliases, error types, module hierarchies
- codebase-pattern-finder — find examples of existing patterns (without evaluating them)
- Look for builder pattern, newtype pattern, From/Into impls, error handling, async patterns
Web research (when external context helps):
- web-search-researcher — external docs, crate docs, RFCs, blog posts
- Spawn proactively when the topic involves external crates, Rust language features, or ecosystem patterns
- Instruct them to return LINKS with findings — include those links in the final report
All agents are documentarians, not critics. They describe what exists without suggesting improvements.
Agent usage strategy:
- Start with locator agents to find what exists
- Then use analyzer agents on the most promising findings
- Run multiple agents in parallel when searching for different things
- Each agent knows its job — tell it what you're looking for, not how to search
- Remind agents they are documenting, not evaluating
4. Synthesize findings
Wait for ALL sub-agents to complete before proceeding. Then:
- Compile all results
- Connect findings across crates, modules, and components
- Include specific file paths and line numbers
- Highlight patterns, connections, and architectural decisions
- Answer the user's questions with concrete evidence
- Document trait relationships, generic type parameters, and lifetime annotations where relevant
5. Generate research document
Structure the output as:
# Research: [Topic]
**Date**: [Current date]
**Git Commit**: [Current commit hash]
**Branch**: [Current branch]
## Research Question
[Original query]
## Summary
[High-level documentation answering the question by describing what exists]
## Crate & Module Structure
[Workspace layout, crate dependencies, module tree relevant to the research]
## Detailed Findings
### [Component/Area 1]
- Description of what exists (file.rs:line)
- How it connects to other components
- Current implementation details (without evaluation)
- Key traits, types, and impls involved
### [Component/Area 2]
...
## Code References
- `path/to/file.rs:123` — Description
- `another/module/mod.rs:45-67` — Description
## Architecture Documentation
[Current patterns, conventions, and design implementations]
- Error handling approach (thiserror, anyhow, custom Result types)
- Async runtime usage (tokio, async-std, etc.)
- Serialization patterns (serde derives, custom impls)
- Feature flag organization
## Open Questions
[Areas that need further investigation]
6. Add GitHub permalinks (if applicable)
- Check if on main branch or if commit is pushed:
git branch --show-current and git status
- If on main/master or pushed, generate permalinks:
- Get repo info:
gh repo view --json owner,name
- Format:
https://github.com/{owner}/{repo}/blob/{commit}/{file}#L{line}
- Replace local file references with permalinks
7. Present findings
- Present a concise summary to the user
- Include key file references for easy navigation
- Ask if they have follow-up questions
8. Handle follow-ups
- Append to the same research document under
## Follow-up Research [timestamp]
- Spawn new sub-agents as needed
Important notes
- Always use parallel agents to maximize efficiency and minimize context usage
- Always run fresh research — never rely solely on existing documents
- Focus on concrete file paths and line numbers
- Research documents should be self-contained
- Each sub-agent prompt should be focused on read-only documentation
- Document cross-component connections
- Link to GitHub when possible for permanent references
- Keep the main agent focused on synthesis, not deep file reading
- Sub-agents should document examples and usage patterns as they exist
- Read mentioned files FULLY before spawning sub-tasks
- Rust-specific:
- Explore
Cargo.toml and Cargo.lock for dependency graphs
- Map out workspace members
- Document
pub visibility boundaries
- Note
#[cfg(...)] conditional compilation and feature gates
- Track
use imports for module dependency flow
- Identify derive macros and proc macros in use
- Document unsafe blocks and their safety invariants
- Note FFI boundaries (
extern "C", #[no_mangle])
1---2name: research-codebase3description: Document and explain the codebase as-is using parallel sub-agents. Use when the user asks to research, explore, map, document, or understand the codebase — including questions like 'how does X work', 'where is Y implemented', 'show me the architecture', 'what does this module do', or any request for codebase-level understanding. Also use when the user says /research_codebase. Even if the user's question seems simple, if it requires reading multiple files or understanding cross-component interactions, use this skill.4---56# Research Codebase78Conduct comprehensive read-only research across the codebase by spawning parallel sub-agents and synthesizing their findings into a structured document.910## Your only job: document what exists1112- DO NOT suggest improvements or changes unless explicitly asked13- DO NOT perform root cause analysis unless explicitly asked14- DO NOT propose enhancements, critique the implementation, or recommend refactoring15- ONLY describe what exists, where it exists, how it works, and how components interact16- You are creating a technical map of the existing system1718## When invoked without a query1920Respond with:2122> I'm ready to research the codebase. Please provide your research question or area of interest, and I'll analyze it thoroughly by exploring relevant components and connections.2324Then wait for the user's research query.2526## Research workflow2728### 1. Read directly mentioned files first2930If the user mentions specific files (docs, configs, TOML, JSON), read them FULLY before doing anything else. Use the Read tool without limit/offset parameters. Read these yourself in the main context — this ensures full context before decomposing the research.3132### 2. Decompose the research question3334- Break the query into composable research areas35- Think deeply about underlying patterns, connections, and architectural implications36- Identify specific components, patterns, or concepts to investigate37- Create a research plan with tasks to track subtasks38- Pay special attention to Rust-specific structures: crates, modules, traits, impls, derive macros, feature flags3940### 3. Spawn parallel sub-agents4142Create multiple agents to research different aspects concurrently. Use the specialized agents:4344**Codebase research:**45- **codebase-locator** — find WHERE files and components live46 - Look for `Cargo.toml`, `lib.rs`, `main.rs`, `mod.rs` to understand crate/module structure47 - Search `*.rs` files, `build.rs`, `.cargo/config.toml`48- **codebase-analyzer** — understand HOW specific code works (without critiquing it)49 - Focus on trait definitions, impl blocks, type aliases, error types, module hierarchies50- **codebase-pattern-finder** — find examples of existing patterns (without evaluating them)51 - Look for builder pattern, newtype pattern, From/Into impls, error handling, async patterns5253**Web research (when external context helps):**54- **web-search-researcher** — external docs, crate docs, RFCs, blog posts55 - Spawn proactively when the topic involves external crates, Rust language features, or ecosystem patterns56 - Instruct them to return LINKS with findings — include those links in the final report5758All agents are documentarians, not critics. They describe what exists without suggesting improvements.5960**Agent usage strategy:**61- Start with locator agents to find what exists62- Then use analyzer agents on the most promising findings63- Run multiple agents in parallel when searching for different things64- Each agent knows its job — tell it what you're looking for, not how to search65- Remind agents they are documenting, not evaluating6667### 4. Synthesize findings6869Wait for ALL sub-agents to complete before proceeding. Then:70- Compile all results71- Connect findings across crates, modules, and components72- Include specific file paths and line numbers73- Highlight patterns, connections, and architectural decisions74- Answer the user's questions with concrete evidence75- Document trait relationships, generic type parameters, and lifetime annotations where relevant7677### 5. Generate research document7879Structure the output as:8081```markdown82# Research: [Topic]8384**Date**: [Current date]85**Git Commit**: [Current commit hash]86**Branch**: [Current branch]8788## Research Question89[Original query]9091## Summary92[High-level documentation answering the question by describing what exists]9394## Crate & Module Structure95[Workspace layout, crate dependencies, module tree relevant to the research]9697## Detailed Findings9899### [Component/Area 1]100- Description of what exists (file.rs:line)101- How it connects to other components102- Current implementation details (without evaluation)103- Key traits, types, and impls involved104105### [Component/Area 2]106...107108## Code References109- `path/to/file.rs:123` — Description110- `another/module/mod.rs:45-67` — Description111112## Architecture Documentation113[Current patterns, conventions, and design implementations]114- Error handling approach (thiserror, anyhow, custom Result types)115- Async runtime usage (tokio, async-std, etc.)116- Serialization patterns (serde derives, custom impls)117- Feature flag organization118119## Open Questions120[Areas that need further investigation]121```122123### 6. Add GitHub permalinks (if applicable)124125- Check if on main branch or if commit is pushed: `git branch --show-current` and `git status`126- If on main/master or pushed, generate permalinks:127 - Get repo info: `gh repo view --json owner,name`128 - Format: `https://github.com/{owner}/{repo}/blob/{commit}/{file}#L{line}`129- Replace local file references with permalinks130131### 7. Present findings132133- Present a concise summary to the user134- Include key file references for easy navigation135- Ask if they have follow-up questions136137### 8. Handle follow-ups138139- Append to the same research document under `## Follow-up Research [timestamp]`140- Spawn new sub-agents as needed141142## Important notes143144- Always use parallel agents to maximize efficiency and minimize context usage145- Always run fresh research — never rely solely on existing documents146- Focus on concrete file paths and line numbers147- Research documents should be self-contained148- Each sub-agent prompt should be focused on read-only documentation149- Document cross-component connections150- Link to GitHub when possible for permanent references151- Keep the main agent focused on synthesis, not deep file reading152- Sub-agents should document examples and usage patterns as they exist153- Read mentioned files FULLY before spawning sub-tasks154- **Rust-specific**:155 - Explore `Cargo.toml` and `Cargo.lock` for dependency graphs156 - Map out workspace members157 - Document `pub` visibility boundaries158 - Note `#[cfg(...)]` conditional compilation and feature gates159 - Track `use` imports for module dependency flow160 - Identify derive macros and proc macros in use161 - Document unsafe blocks and their safety invariants162 - Note FFI boundaries (`extern "C"`, `#[no_mangle]`)