Standalone /research skill that scans the codebase, discovers canonical sources via websearch, reads and deepens in parallel via subagents, and writes structured topic files + sources.md to an explicit output path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
90 lines
4.8 KiB
Markdown
90 lines
4.8 KiB
Markdown
---
|
||
name: research
|
||
description: >-
|
||
Use when the user wants to research a topic and generate structured reference
|
||
markdown files from web sources. Handles: finding canonical docs for a
|
||
tool/library/API, reading and deepening into linked pages, organizing extracted
|
||
content into topic files (overview, installation, configuration, cli-reference,
|
||
api-reference, examples, troubleshooting). Do NOT use when the user wants to
|
||
write documentation from existing code or specs (use write-docs), install or
|
||
query a specific documentation MCP server (use neuledge-context), or research
|
||
a bug/incident (use diagnose).
|
||
metadata:
|
||
category: research
|
||
allowed-tools:
|
||
- WebSearch
|
||
- WebFetch
|
||
- Read
|
||
- Write
|
||
model: sonnet
|
||
---
|
||
|
||
<requirements>
|
||
|
||
## Required inputs
|
||
|
||
- **Topic** — the subject to research (tool, library, API, concept); inferred from user description if clear, ask if ambiguous
|
||
- **Output path** — directory where reference files will be written; must be provided explicitly — do not infer or default
|
||
- **Starting URLs** — optional; if provided, skip discovery websearch and read these first
|
||
|
||
## Constraints
|
||
|
||
- Never write files outside the explicitly provided output path
|
||
- Skip any default topic file if no relevant content is found for it — do not create empty files
|
||
- Create additional topic files beyond the default list when content warrants it (e.g. `webhooks.md`, `rate-limits.md`)
|
||
- Subagents handle parallel source reading and link deepening — the orchestrator writes all files; subagents return summaries only, never write directly
|
||
- `sources.md` is always written, even if only one source was read
|
||
- Each topic file must have frontmatter with `topic` and `source_keys`; body is prose only — no inline URLs
|
||
- Source keys in `sources.md` must be kebab-case slugs derived from the source domain or page title
|
||
- Default topic list and file format spec live in `references/` sub-files — read them at step 1
|
||
|
||
</requirements>
|
||
|
||
<steps>
|
||
|
||
## Process
|
||
|
||
1. **Scan codebase.** Search the working directory for existing usage of the topic — imports, config files, version pins, existing reference files. Use findings to narrow research scope (e.g. target the version already in use, skip topics already documented). Read `references/topics.md` for the default topic list and `references/file-format.md` for the output file format spec.
|
||
|
||
2. **Discover sources.** If no starting URLs were provided, websearch for canonical documentation (prefer `llms.txt`, developer docs, official API references over tutorials or blog posts). Collect 3–5 candidate URLs before reading any.
|
||
|
||
3. **Read sources in parallel.** Spawn one subagent per source URL. Each subagent fetches the page, extracts relevant content, identifies links worth deepening, and returns a structured summary (content by topic area + links to follow). Subagents do not write files.
|
||
|
||
4. **Deepen.** For each subagent that returned links worth following, spawn child subagents per branch. Continue until content becomes repetitive or out of scope. Cap at ~10 additional pages total across all branches.
|
||
|
||
5. **Consolidate.** Merge all subagent summaries by topic area. Identify which default topics have sufficient content and which custom topics emerged.
|
||
|
||
6. **Write topic files.** For each topic with content, write `<output-path>/<topic>.md` using the format in `references/file-format.md`. Orchestrator writes all files — never delegate file writing to a subagent.
|
||
|
||
7. **Write `sources.md`.** Write `<output-path>/sources.md` mapping each source slug to its URL, description, and list of topic files it contributed to. Include sources that yielded no content, marked `no content extracted`.
|
||
|
||
## Output format
|
||
|
||
- `<output-path>/<topic>.md` per topic with content — formatted per `references/file-format.md`
|
||
- `<output-path>/sources.md` — always produced; maps slug → URL, description, contributing files
|
||
|
||
</steps>
|
||
|
||
<checks>
|
||
|
||
## Failure handling
|
||
|
||
- Output path not provided — stop and ask; do not infer or default
|
||
- No sources found after websearch — report what was searched, ask user to provide starting URLs
|
||
- Subagent returns no usable content — skip that source, log in `sources.md` as `no content extracted`
|
||
- All topic files would be empty — stop, report what was searched, do not write any files
|
||
|
||
## Self-check
|
||
|
||
- [ ] Codebase scanned before any websearch was performed
|
||
- [ ] Output path was explicitly provided — not inferred
|
||
- [ ] `references/topics.md` and `references/file-format.md` read at step 1
|
||
- [ ] No topic file written without content
|
||
- [ ] `sources.md` written with all sources read (including those with no content extracted)
|
||
- [ ] All file writes performed by the orchestrator, not subagents
|
||
- [ ] Each topic file has `topic` and `source_keys` frontmatter fields
|
||
- [ ] All source keys in topic files have a matching entry in `sources.md`
|
||
- [ ] No files written outside the provided output path
|
||
|
||
</checks>
|