一键导入
research-codebase
// Document codebase as-is with research directory for historical context.
// Document codebase as-is with research directory for historical context.
Create a detailed execution plan/spec/PRD for implementing features or refactors in a codebase, designed around the program's entrypoints, the doors that carry domain intent, by leveraging existing research in the codebase.
Delegate work to builtin or custom subagents with single-agent, chain, parallel, async, forked-context, and intercom-coordinated workflows. Use for parallel codebase discovery, debug-and-fix, refinement, and multi-step tasks where a single parent agent stays in control while specialist subagents contribute locate, analyze, pattern-find, research, debug, or simplify passes.
Control tmux-compatible sessions/windows/panes for interactive CLIs: list, capture output, send keys, paste text, monitor prompts.
Automate browser interactions, test web pages and work with Playwright tests.
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
Example skill loaded from resources_discover
| name | research-codebase |
| description | Document codebase as-is with research directory for historical context. |
You are tasked with conducting comprehensive research across the codebase to answer user questions by spawning parallel sub-agents and synthesizing their findings.
The user's research question/request is: $ARGUMENTS
<EXTREMELY_IMPORTANT>
</EXTREMELY_IMPORTANT>
Read any directly mentioned files first:
readFile tool WITHOUT limit/offset parameters to read entire filesAnalyze and decompose the research question:
Spawn parallel sub-agent tasks:
For codebase research:
research/docs/ relative to the current working directoryresearch/docs/2024-01-10-database-implementation.mdresearch/docs/2024-01-11-authentication-flow.mdIMPORTANT: All agents are documentarians, not critics. They will describe what exists without suggesting improvements or identifying issues.
For research directory:
For online search:
bunx @playwright/cli / curl). Instruct it to apply the token-efficient fetch order: (1) try curl https://<site>/llms.txt for an AI-friendly index (see llmstxt.org), (2) try curl <url> -H "Accept: text/markdown" to get pre-converted Markdown (supported on Cloudflare-hosted docs via Markdown for Agents), (3) fall back to HTML parsing via playwright-cliresearch/web/<YYYY-MM-DD>-<kebab-case-topic>.md (with frontmatter noting source_url, fetched_at, and fetch_method) so future research can reuse them without re-fetchingresearch/docs/Redis locks usage, the agent might find relevant usage and create a document research/docs/2024-01-15-redis-locks-usage.md with internal links to Redis docs and code references (and cache the fetched Redis docs under research/web/)OAuth flows, the agent might find relevant external articles and create a document research/docs/2024-01-16-oauth-flows.md with links to those articlesThe key is to use these agents intelligently:
Wait for all sub-agents to complete and synthesize:
Generate research document:
research/
├── tickets/
│ ├── YYYY-MM-DD-XXXX-description.md
├── docs/
│ ├── YYYY-MM-DD-topic.md
├── notes/
│ ├── YYYY-MM-DD-meeting.md
├── ...
└──
Naming conventions:
2025-01-08-1478-parent-child-tracking.md2025-01-08-authentication-flow.mdStructure the document with YAML frontmatter followed by content:
---
date: !`date '+%Y-%m-%d %H:%M:%S %Z'`
researcher: [Researcher name from thoughts status]
git_commit: !`git rev-parse --verify HEAD 2>/dev/null || echo "no-commits"`
branch: !`git branch --show-current 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unborn"`
repository: !`basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown-repo"`
topic: "[User's Question/Topic]"
tags: [research, codebase, relevant-component-names]
status: complete
last_updated: !`date '+%Y-%m-%d'`
last_updated_by: [Researcher name]
---
# Research
## 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](link))
- 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]
## Historical Context (from research/)
[Relevant insights from research/ directory with references]
- `research/docs/YYYY-MM-DD-topic.md` - Information about module X
- `research/notes/YYYY-MM-DD-meeting.md` - Past notes from internal engineering, customer, etc. discussions
- ...
## Related Research
[Links to other research documents in research/]
## Open Questions
[Any areas that need further investigation]
Add GitHub permalinks (if applicable):
git branch --show-current and git statusgh repo view --json owner,namehttps://github.com/{owner}/{repo}/blob/{commit}/{file}#L{line}Present findings:
Handle follow-up questions:
last_updated and last_updated_by to reflect the updatelast_updated_note: "Added follow-up research for [brief description]" to frontmatter## Follow-up Research [timestamp]Please DO NOT implement anything in this stage, just create the comprehensive research document
Always use parallel Task agents to maximize efficiency and minimize context usage
Always run fresh codebase research - never rely solely on existing research documents
The research/ directory provides historical context to supplement live findings
Focus on finding concrete file paths and line numbers for developer reference
Research documents should be self-contained with all necessary context
Each sub-agent prompt should be specific and focused on read-only documentation operations
Document cross-component connections and how systems interact
Include temporal context (when the research was conducted)
Link to GitHub when possible for permanent references
Keep the main agent focused on synthesis, not deep file reading
Have sub-agents document examples and usage patterns as they exist
Explore all of research/ directory, not just research subdirectory
CRITICAL: You and all sub-agents are documentarians, not evaluators
REMEMBER: Document what IS, not what SHOULD BE
NO RECOMMENDATIONS: Only describe the current state of the codebase
File reading: Always read mentioned files FULLY (no limit/offset) before spawning sub-tasks
Critical ordering: Follow the numbered steps exactly
Frontmatter consistency:
last_updated, git_commit)research/ directory.