Two-phase codebase analysis. Phase 1: discover features from code. Phase 2: trace workflows.
Discovers features and workflows from your codebase using parallel subagents. Triggers when you ask to "map my codebase" or "find all features" to bootstrap the Feature Tree.
/plugin marketplace add Nothflare/feature-tree/plugin install feature-tree@feature-treeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Two-phase process to populate Feature Tree from an existing codebase:
Both phases are optional. Run Phase 1 alone, skip to Phase 2 with manual guidance, or run both.
Scan the codebase structure and propose modules:
src/, lib/, app/)I found these potential modules:
| Module | Path | Notes |
|--------|------|-------|
| auth | src/auth | login, session, oauth files |
| payments | src/payments | stripe, checkout |
| users | src/users | profile, settings |
| utils | src/utils | shared helpers → likely INFRA |
Add, remove, or rename any? [Enter to confirm]
Log module detection: bootstrap_log("Proposed modules: auth, payments, users, utils", "MODULE_DETECT")
For each confirmed module, spawn an Explore subagent with Feature Tree context:
Task(
subagent_type="Explore",
prompt=f"""
## Context: Feature Tree Bootstrap
Feature Tree tracks atomic features and infrastructure for AI-assisted development.
**FEATURE** = Atomic, user-facing capability
- Something you'd say "implement the X feature"
- Examples: AUTH.login, PAYMENT.checkout, USER.profile_update
- Must be completable in one Claude session
**INFRASTRUCTURE** = Shared utilities, not user-facing alone
- Use INFRA.* prefix: INFRA.rate_limiter, INFRA.logger, INFRA.validation
- Gets linked to features via `uses` field
**CONFIDENCE:**
- HIGH: Obvious from names/structure (file literally named login.ts with handleLogin export)
- MEDIUM: Reasonable inference from patterns
- LOW: Ambiguous, might be wrong
## Your Task
Analyze module: {module_name}
Path: {module_path}
1. Identify features (user-facing capabilities)
2. Identify infrastructure (shared utilities)
3. Note cross-module dependencies
Return JSON:
{{
"module": "{module_name}",
"features": [
{{
"id": "DOMAIN.name",
"name": "Human Readable Name",
"description": "What it does",
"files": ["path/to/file.ts"],
"code_symbols": ["functionName", "ClassName"],
"confidence": "MEDIUM"
}}
],
"infrastructure": [
{{
"id": "INFRA.name",
"name": "Human Readable Name",
"files": ["path/to/file.ts"],
"code_symbols": ["helperFn"],
"confidence": "HIGH"
}}
],
"cross_refs": [
{{
"target": "@other_module",
"reason": "calls their exported function",
"symbols": ["importedSymbol"]
}}
]
}}
"""
)
Launch all subagents in a single message (parallel execution).
After collecting all subagent results:
uses relationships
@auth referencing validateToken → feature uses AUTH.token_validationusesFor each synthesized feature:
add_feature(
id="AUTH.login",
name="User Login",
description="Validates credentials, creates session",
confidence="MEDIUM",
uses=["INFRA.rate_limiter"] # from cross_refs
)
update_feature(
id="AUTH.login",
files=["src/auth/login.ts", "src/auth/session.ts"],
code_symbols=["handleLogin", "createSession", "validateCredentials"]
)
bootstrap_log("Created AUTH.login (MEDIUM)", "FEATURE_CREATE")
Present results and offer choices:
## Phase 1 Complete: 15 features discovered
| ID | Name | Confidence | Uses |
|----|------|------------|------|
| AUTH.login | User Login | MEDIUM | INFRA.rate_limiter |
| AUTH.register | User Registration | MEDIUM | INFRA.validation |
| INFRA.rate_limiter | Rate Limiter | HIGH | - |
| INFRA.validation | Input Validation | HIGH | - |
...
**Flagged for review:**
- UTILS.format_date — LOW confidence, might be INFRA
- AUTH.session vs USER.session — possible overlap
**What next?**
1. Continue to Phase 2 (workflow discovery)
2. Review/edit features first
3. Done for now
Find terminal features (natural workflow entry points):
uses edges)Present to user:
Starting points for workflow tracing:
| Feature | Entry Point |
|---------|-------------|
| AUTH.login | POST /auth/login |
| AUTH.register | POST /auth/register |
| PAYMENT.checkout | POST /checkout |
Add any entry points I missed? [Enter to confirm]
For each starting point, spawn subagent:
Task(
subagent_type="Explore",
prompt=f"""
## Context: Feature Tree Workflow Tracing
You're tracing a workflow from a known entry point. Map it to existing features.
**Known features in this codebase:**
{list_of_feature_ids_and_names}
## Your Task
Starting feature: {feature_id}
Entry point: {entry_file}:{entry_symbol}
1. Trace the code path from entry to completion
2. Map each step to a known feature ID (from list above)
3. Note the user-visible outcome
Return JSON:
{{
"starting_feature": "{feature_id}",
"trace": ["AUTH.login", "INFRA.rate_limiter", "DB.session_create"],
"user_outcome": "User is logged in with session cookie",
"confidence": "MEDIUM"
}}
IMPORTANT: Use existing feature IDs from the list. Don't invent new ones.
"""
)
Subagent traces are hints, not final answers. Review for gaps:
Traces collected from 5 workflows.
Potential gaps detected:
- AUTH.login trace doesn't show session storage mechanism
- PAYMENT.checkout trace unclear on error handling
- 2 traces reference "sendEmail" — not mapped to any feature
Investigate gaps before synthesis? [y/n]
If yes: Use Grep/Read to follow unclear paths, potentially discover missing features.
Transform raw traces to clean flows:
Raw trace:
["AUTH.login", "INFRA.rate_limiter", "DB.user_find", "AUTH.session_create"]
Synthesized workflow:
add_workflow(
id="AUTH.login_flow",
name="User Login Flow",
description="User submits credentials and receives session",
depends_on=["AUTH.login", "AUTH.session_create"], # exclude INFRA internals
confidence="MEDIUM",
mermaid="""
graph TD
A[User submits credentials] --> B[AUTH.login]
B --> C[AUTH.session_create]
C --> D[User logged in]
"""
)
bootstrap_log("Created AUTH.login_flow (MEDIUM)", "WORKFLOW_CREATE")
Synthesis rules:
Verify all features appear in at least one workflow:
Coverage: 12/15 features in workflows
Uncovered:
- USER.settings (no workflow traces it)
- AUTH.password_reset (no workflow traces it)
Options:
1. Add these as starting points, trace again
2. Skip — I'll add workflows manually later
If option 1: Loop back to Step 2.2 with uncovered features.
Group related flows into journeys:
Proposed journeys:
| Journey | Flows |
|---------|-------|
| USER_ONBOARDING | register_flow, verify_email_flow, first_login_flow |
| CHECKOUT | add_to_cart_flow, payment_flow, confirmation_flow |
Create these journey groupings? [y/n]
If yes: Create parent workflows with child flows.