跳到正文
FunCoding

research-codebase

Investigate how a codebase works today and write a structured, cited research document under research/ for future specs and historical context. Apply proactively when mapping an unfamiliar subsystem, gathering codebase context before planning a feature or refactor, or building durable engineering notes under research/. For conversational explanations without writing files, use `how`; for designing changes, use `create-spec`.

Star
886
最近提交
2026年12月1日

packages/subagents/skills/research-codebase/SKILL.md

在 GitHub 上查看

Research a codebase

Document how a codebase works as-is today and save a cited research artifact under research/. You and every spawned subagent act strictly as neutral documentarians — describe what exists with exact file and line evidence rather than proposing designs, recommending changes, or critiquing quality.

Do not implement code or write files outside research/ during this skill.

The user's research query is: $ARGUMENTS

Workflow

1. Clarify the query and read named files first

  • Tighten any ambiguous phrasing in the research question so every subagent investigates the exact question.
  • Before delegating anything, read every file the user explicitly mentioned (tickets, design notes, source files) completely in the main session, paging through line ranges if output is truncated. Full primary context prevents mis-scoping subagent tasks.

2. Settle the compatibility posture

Determine whether the project preserves backward compatibility for real downstream users:

  • Set breaking_changes_allowed: true when the user explicitly permits breaking changes, API cleanup, or confirms there are no downstream users. Document legacy shims, flags, and APIs as current state rather than preservation constraints.
  • Set breaking_changes_allowed: false when the user mentions production users, published APIs, downstream consumers, or migration safety. Document compatibility-sensitive surfaces, callers, and migration constraints future work must preserve.
  • If unclear, ask once via ask_user_question before decomposing the research. Carry this posture into every subagent prompt, the research frontmatter, and ## Compatibility Context.

3. Decompose and launch parallel read-only subagents

Break the question into independent, non-overlapping angles (use todo for multi-part tracking if helpful) and launch them together in one subagent({ tasks: [...], context: "fresh" }) call:

  • Codebase mapping: codebase-locator (where files, configs, and tests live), codebase-analyzer (how specific paths execute, with file:line citations), and codebase-pattern-finder (existing conventions and analogous code).
  • Prior local context: codebase-research-locator (discover existing research/ and specs/ docs) followed by codebase-research-analyzer on the most relevant ones. Always pair live codebase inspection with historical notes rather than trusting old docs alone.
  • External libraries and specs: when the target depends on external libraries or protocols, assign codebase-online-researcher. Have it check research/web/ first for a recent cached copy, start with the authoritative URL via fetch_content (falling back to llms.txt, Markdown Accept header, or agent-browser only when needed), and return links and distilled findings. For reusable external docs worth keeping, write a trimmed copy in the main session to research/web/YYYY-MM-DD-<kebab-case-topic>.md with source_url, fetched_at, fetch_method, and topic frontmatter.

Tell each subagent what angle to document, the breaking_changes_allowed posture, and that its role is read-only documentation (no edits, no recommendations). Let each specialist choose its own search commands.

4. Wait, verify, and synthesize

  • Wait for terminal completion of the subagents you need (via completion notices or subagent({ action: "wait", id: taskId }); if a wait times out early, wait on the same taskId rather than relaunching).
  • Treat live codebase evidence as the primary source of truth and prior research/ notes as historical context.
  • Connect findings across components with concrete file:line references.
  • If the code shows the user's question rests on a false premise (for example, a subsystem works differently than assumed or a component does not exist), surface that discrepancy clearly instead of burying it.

5. Write the research document

Read references/research-template.md for the directory layout (research/docs/, research/tickets/, research/notes/), filename format, YAML frontmatter (gather real git metadata first — never leave placeholders), and section structure.

If the current branch is main/master or the commit is pushed, resolve the repository via gh repo view --json owner,name and include GitHub permalinks (https://github.com/{owner}/{repo}/blob/{commit}/{file}#L{line}) alongside file paths.

6. Present summary and handle follow-ups

Deliver a concise executive summary of findings, key file references, and the path to the written research document under research/, then ask whether the user wants any clarification or deeper follow-up.

When the user asks follow-up questions, append a ## Follow-up Research <timestamp> section to the existing document, update last_updated, last_updated_by, and last_updated_note in frontmatter, and launch fresh subagents only for new angles.

Bundled reference

  • references/research-template.md — directory layout, naming rules, YAML frontmatter, and document structure. Read before writing the output file.

相似的 Skill

rea-analysis-optimization

MOmorluto/rea485k近 7 天新增 7,690 个 star

codebase-design

MAmattpocock/skills336k近 7 天新增 4,217 个 star

精选

diagnosing-bugs

诊断困难 bug 和性能回归,用测试或脚本构建反馈循环定位问题。

MAmattpocock/skills336k近 7 天新增 4,217 个 star

setup-ts-deep-modules

MAmattpocock/skills336k近 7 天新增 4,217 个 star

code-review

MAmattpocock/skills336k近 7 天新增 4,217 个 star

implement

MAmattpocock/skills336k近 7 天新增 4,217 个 star