You are tasked with conducting comprehensive research across the codebase to answer user questions by spawning parallel sub-agents and synthesizing their findings.
If the user already provided a research question or topic alongside this command, proceed directly to step 1 below. Only if no query was given, respond with:
Then wait for the user's research query.
-
Read any directly mentioned files first:
- If the user mentions specific files or docs, read them FULLY first
- IMPORTANT: Use the Read tool WITHOUT limit/offset parameters to read entire files
- CRITICAL: Read these files yourself in the main context before spawning any sub-tasks
- This ensures you have full context before decomposing the research
-
Analyze and decompose the research question:
- Break down the user's query into composable research areas
- Take time to think deeply about the underlying patterns, connections, and architectural implications the user might be seeking
- Identify specific components, patterns, or concepts to investigate
- If you have a todo list, use it to track progress
- Consider which directories, files, or architectural patterns are relevant
-
Spawn parallel sub-agents to identify relevant files and map the landscape:
- Create multiple Task agents to search for files and identify what's relevant
- Each sub-agent should focus on locating files and reporting back paths and brief summaries — NOT on deeply analyzing code
- The key is to use these agents for discovery:
- Search for files related to each research area
- Identify entry points, key types, and important functions
- Report back file paths, line numbers, and short descriptions of what each file contains
- Run multiple agents in parallel when they're searching for different things
- Remind agents they are documenting, not evaluating or improving
- If the user explicitly asks for web research, spawn additional agents with WebSearch/WebFetch tools and instruct them to return links with their findings
-
Read the most relevant files yourself in the main context:
- After sub-agents report back, identify the most important files for answering the research question
- Read these files yourself using the Read tool — you need them in your own context to write an accurate, detailed research document
- Do NOT rely solely on sub-agent summaries for the core findings — sub-agent summaries may miss nuances, connections, or important details
- Prioritize files that are central to the research question; skip peripheral files that sub-agents already summarized adequately
- This is the step where you build deep understanding — the previous step was just finding what to read
-
Synthesize findings into a complete picture:
- Combine your own reading with sub-agent discoveries
- Connect findings across different components
- Include specific file paths and line numbers for reference
- Highlight patterns, connections, and architectural decisions
- Answer the user's specific questions with concrete evidence
-
Gather metadata for the research document:
- Run
python3 <skill_directory>/scripts/metadata.py
to get date, commit, branch, and repository info
- Determine the output filename:
docs/agents/research/YYYY-MM-DD-description.md
- YYYY-MM-DD is today's date
- description is a brief kebab-case description of the research topic
- Example:
2025-01-08-authentication-flow.md
- The output folder () can be overridden by instructions in the project's or
-
Generate research document:
- Use the metadata gathered in step 5
- Ensure the directory exists (create if needed)
- Structure the document with YAML frontmatter followed by content:
markdown
---
date: [ISO date/time from metadata]
git_commit: [Current commit hash from metadata]
branch: [Current branch name from metadata]
topic: "[User's Question/Topic]"
tags: [research, codebase, relevant-component-names]
status: complete
---
# Research: [User's Question/Topic]
## Research Question
[Original user query]
## Summary
[High-level documentation of what was found, answering the user's question by describing what exists]
## Detailed Findings
### [Component/Area 1]
- Description of what exists (file.ext:line)
- How it connects to other components
- Current implementation details (without evaluation)
### [Component/Area 2]
...
## Code References
- `path/to/file.py:123` - Description of what's there
- `another/file.ts:45-67` - Description of the code block
## Architecture Documentation
[Current patterns, conventions, and design implementations found in the codebase]
## Open Questions
[Any areas that need further investigation]
-
Present findings to the user:
- Present a concise summary of findings
- Include key file references for easy navigation
- Ask if they have follow-up questions or need clarification
-
Handle follow-up questions:
- If the user has follow-up questions, append to the same research document
- Add a new section:
## Follow-up Research [timestamp]
- Spawn new sub-agents as needed for additional investigation
- Continue updating the document