一键导入
long-task-explore
// Use for on-demand deep exploration of an existing codebase - analyzes architecture, data flow, domain model, API surface, dependencies, and code health
// Use for on-demand deep exploration of an existing codebase - analyzes architecture, data flow, domain model, API surface, dependencies, and code health
Use when design doc exists but no ATS doc and no feature-list.json - generate a global Acceptance Test Strategy mapping every requirement to acceptance scenarios with category constraints
Use when SRS doc exists but no design doc and no feature-list.json - take the approved SRS as input and produce an architecture/design document focused on HOW to build it
Use when ATS doc exists (or auto-skipped) but feature-list.json not yet created - scaffold project artifacts and populate features from Design §10.2
Use when no SRS doc and no design doc and no feature-list.json exist - elicit requirements through structured questioning and produce a high-quality SRS document aligned with ISO/IEC/IEEE 29148
Use when starting any session in a long-task project - routes to the correct phase skill based on project state
Use when increment-request.json exists - collect incremental requirements, perform impact analysis, update design, and decompose new features
| name | long-task-explore |
| description | Use for on-demand deep exploration of an existing codebase - analyzes architecture, data flow, domain model, API surface, dependencies, and code health |
Explore an existing codebase to produce a structured understanding document. Dispatches specialized SubAgents to locate key structures, analyze architecture and data flow, and measure code health.
Announce at start: "I'm using the long-task-explore skill to deeply explore this codebase."
This skill can be invoked standalone OR from within pipeline phases (requirements, increment).
In both modes:
docs/rules/ exists (from codebase-scanner), reference it but do not depend on itfile:line evidenceParse user input for optional parameters:
| Parameter | Values | Default |
|---|---|---|
| Depth | quick / standard / deep | Auto-detect by LOC |
--focus | architecture / dataflow / domain / api / deps / health (comma-separated) | All 6 dimensions |
--path | Relative directory path | . (project root) |
| Natural language | Any text describing area of interest | None (full exploration) |
If the user provides a natural-language question (e.g., "帮我理解认证模块", "how does the payment flow work"), treat it as a focus directive — the SubAgents should prioritize that area while still covering the requested dimensions.
Detect the project's characteristics:
Languages: count files by extension (*.py, *.js, *.ts, *.tsx, *.java, *.go, *.rs, *.c, *.cpp, *.rb, *.kt, *.swift), excluding .git/, node_modules/, venv/, .venv/, dist/, build/, __pycache__/
Frameworks: check dependency manifests (package.json, requirements.txt, pyproject.toml, pom.xml, build.gradle, Cargo.toml, go.mod, Gemfile, *.csproj)
LOC estimate: find <path> -type f -name "*.{ext}" | head -500 | xargs wc -l (cap sampling at 500 files for speed)
Depth auto-detection (if user did not specify --depth):
| LOC Range | Default Depth |
|---|---|
| < 1,000 | quick |
| 1,000 – 10,000 | standard |
| > 10,000 | deep |
Existing rules: if docs/rules/README.md exists, read it for context (languages, internal libraries, build system). Pass as supplementary context to SubAgents.
Build a Project Profile object:
- root: {project_root or --path value}
- languages: [list with file counts]
- frameworks: [detected from manifests]
- loc_estimate: N
- depth: quick|standard|deep
- focus: [dimensions] or "all"
- user_question: "..." or null
- existing_rules_summary: "..." or null
Dispatch the codebase-locator SubAgent to quickly identify key structural positions across the codebase.
Agent(
subagent_type="general-purpose",
description="Locate codebase structure for [project]",
prompt="""
Read the agent definition at: {plugin_root}/agents/codebase-locator.md
## Project Profile
{project_profile}
Execute the full locator process per the agent definition.
Return the structured location inventory as specified in the Structured Return Contract.
"""
)
Wait for locator to return before proceeding. The location inventory is the input for Phase 2.
If the locator returns BLOCKED, fall back to a minimal inventory by scanning the top-level directory structure and entry points only.
Based on the locator's inventory, dispatch two SubAgents in parallel:
If depth is quick, skip Phase 2. Instead, synthesize the locator's inventory directly into a brief overview document (Step 6, quick format). This avoids unnecessary SubAgent overhead for small projects.
Determine which SubAgents to dispatch based on --focus:
| Focus includes | Dispatch |
|---|---|
architecture, dataflow, domain, api (any) | Analyzer |
deps, health (any) | Pattern-Finder |
all (default) | Both |
# Parallel Agent 1: Architecture Analyzer
Agent(
subagent_type="general-purpose",
description="Analyze architecture of [project]",
prompt="""
Read the agent definition at: {plugin_root}/agents/codebase-analyzer.md
Read the dimension guide at: {plugin_root}/skills/long-task-explore/references/exploration-dimensions.md
## Project Profile
{project_profile}
## Location Inventory (from Locator)
{locator_results}
## Dimensions to Analyze
{filtered_dimensions: architecture, api, dataflow, domain — based on --focus}
Execute the full analysis process per the agent definition.
Return the structured analysis as specified in the Structured Return Contract.
"""
)
# Parallel Agent 2: Pattern & Health Finder
Agent(
subagent_type="general-purpose",
description="Find patterns and health metrics for [project]",
prompt="""
Read the agent definition at: {plugin_root}/agents/codebase-pattern-finder.md
Read the dimension guide at: {plugin_root}/skills/long-task-explore/references/exploration-dimensions.md
## Project Profile
{project_profile}
## Location Inventory (from Locator)
{locator_results}
## Dimensions to Analyze
{filtered_dimensions: deps, health — based on --focus}
Execute the full analysis process per the agent definition.
Return the structured analysis as specified in the Structured Return Contract.
"""
)
Wait for both SubAgents to complete.
Merge the returns from all SubAgents (1–3 depending on depth and focus):
Create the exploration report:
mkdir -p docs/explore/
Write docs/explore/codebase-research.md using the template at docs/templates/explore-report-template.md.
| Depth | Content | Budget |
|---|---|---|
| Quick | Key Findings Summary + each section as 3–5 bullet points | <= 150 lines |
| Standard | Full 6 sections with Mermaid diagrams and evidence tables | <= 400 lines |
| Deep | Full 6 sections + detailed Code References index + complete hotspot lists | <= 600 lines |
If --focus was specified, only include the requested dimension sections. Always include Key Findings Summary and Code References.
If docs/explore/codebase-research.md already exists, overwrite it cleanly. The report is always a fresh snapshot.
Present the Key Findings Summary to the user in a concise format:
## Exploration Complete
**[project-name]** — [languages] / [frameworks]
Depth: [depth] | Files sampled: [N] / [M total]
### Key Findings
- Architecture: [pattern]
- Entry Points: [N] | API Endpoints: [N] | Domain Entities: [N]
- External Integrations: [N]
- Top Complexity Hotspot: [file:line]
- Test/Source Ratio: [N/M]
- Tech Debt Markers: [N] TODOs, [M] FIXMEs
Full report: docs/explore/codebase-research.md
If the user provided a natural-language question, answer it directly using the synthesized findings before showing the summary.
Inform the user they can ask follow-up questions about specific modules or components.
| Aspect | Quick | Standard | Deep |
|---|---|---|---|
| SubAgents dispatched | 1 (locator only) | 2–3 (locator → analyzer + pattern-finder) | 3 (all) |
| File sampling per agent | Top 30 | Top 60 | Top 120 + all configs |
| Mermaid diagrams | 0 | 2–3 | All applicable |
| Evidence citations | Top-3 per category | Top-5 per category | Exhaustive |
| Output budget | 150 lines | 400 lines | 600 lines |
| Keyword | Dimension | Handled By |
|---|---|---|
architecture | Architecture Overview — module decomposition, patterns, dependency graph | Analyzer |
api | Entry Points & API Surface — endpoints, CLI commands, config surface | Analyzer |
dataflow | Data Flow & State Management — models, pipelines, caching | Analyzer |
domain | Domain Model & Business Logic — entities, rules, algorithms | Analyzer |
deps | Dependencies & Integrations — dependency inventory, coupling, external services | Pattern-Finder |
health | Code Health & Complexity — hotspots, test landscape, tech debt | Pattern-Finder |
file:line examples