researching-codebases
Researching Codebases
Coordinate parallel sub-agents to answer complex codebase questions.
When to Use
- Questions spanning multiple files or components
- "How does X work?" requiring tracing through code
- Finding patterns or examples across the codebase
- Understanding architectural decisions or data flow
When NOT to Use
- Simple "where is X?" - use
code-locatordirectly - Single file questions - just read the file
- External/web research only - use
web-searcherdirectly
Workflow
0. Check past research (optional)
Before decomposing a new research question, consider checking for related past research:
- Run
list-research.pyscript to see recent research docs - Run
search-research.pyscript with relevant keywords - If related research exists, run
read-research.pyscript to load it - Build on previous findings instead of starting fresh
See research-tools.md for script usage.
1. Read mentioned files first
If the user references specific files, read them FULLY before spawning agents. This gives you context for decomposition.
2. Decompose the question
Break the query into parallel research tasks. Consider:
- Which areas of the codebase are relevant?
- Do I need locations, analysis, or examples?
- See
agent-selection.mdfor agent capabilities
3. Spawn parallel agents
Launch multiple agents concurrently for independent tasks. Use the task tool with appropriate subagent_type.
Wait for ALL agents to complete before synthesizing.
4. Synthesize and respond
Combine findings into a coherent answer:
- Direct answer to the question
- Key
file:linereferences - Connections between components
- Open questions if any areas need more investigation
5. Offer to save (optional)
For substantial research, ask:
Want me to save this to a research doc? (project:
.research/or global:~/.research/)
Skip this for quick answers.
When saving:
- Run
gather-metadata.pyscript to get date, repo, branch, commit, cwd. - Add query (from user's question) and tags (from content)
- Format YAML frontmatter per
output-format.md - Create directory if it doesn't exist
- Use filename:
{filename_date}_topic-slug.md
Agent Reference
See agent-selection.md for when to use each agent.
Common Mistakes
Spawning agents before reading context: Read any files the user mentions first.
Not waiting for all agents: Synthesize only after ALL agents complete.
Over-documenting simple answers: Not every question needs a saved research doc.
Sequential when parallel works: If tasks are independent, spawn them together.
More from cachemoney/agent-toolkit
coolify-compose
Convert Docker Compose files to Coolify templates. Use when creating Coolify services, converting docker-compose.yml for Coolify deployment, working with SERVICE_URL/SERVICE_PASSWORD magic variables, or troubleshooting Coolify compose errors.
22diataxis
Structure, classify, and write documentation using the Diátaxis framework. Use when writing docs, README files, guides, tutorials, how-to guides, API references, or organizing documentation architecture. Also use when asked to improve documentation, restructure docs, decide what type of doc to write, or classify existing content. Covers tutorials, how-to guides, reference, and explanation.
9backend-to-frontend-handoff-docs
Create API handoff documentation for frontend developers. Use when backend work is complete and needs to be documented for frontend integration, or user says 'create handoff', 'document API', 'frontend handoff', or 'API documentation'.
9requirements-clarity
Clarify ambiguous requirements through focused dialogue before implementation. Use when requirements are unclear, features are complex (>2 days), or involve cross-team coordination. Ask two core questions - Why? (YAGNI check) and Simpler? (KISS check) - to ensure clarity before coding.
9jj
Jujutsu (jj) — the Git-compatible version control system. Activate ONLY when a .jj/ directory is present in the project or when jj/jujutsu is explicitly mentioned. Do NOT activate for plain git repos without .jj/. Use for any VCS operations in jj-managed projects: commit, push, pull, branch, bookmark, rebase, squash, merge, diff, log, status, working copy, change ID, revset, fileset, template, configuration, workspaces.
9perplexity
Web search and research using Perplexity AI. Use when user says "search", "find", "look up", "ask", "research", or "what's the latest" for generic queries. NOT for library/framework docs (use Context7) or workspace questions.
9