Add feature discovery

From brabos-ai/code-addiction · View interactive version

Add feature discovery is an AI agent skill from the GitHub repository brabos-ai/code-addiction. Use when analyzing codebase for a specific feature - creates/updates discovery.md with technical analysis, patterns, files mapping and caches for future sessions

How to use this skill

Skill file

Feature Discovery

<!-- uses:

-->

Skill for technical codebase analysis focused on a specific feature. Persists analysis in discovery.md for reuse across sessions.

Principle: Analyze once, use always. Cache per feature.


When to Use

When NOT to Use


Workflow

REQUIRED: Apply before writing:

Phase 1: Check Cache

cat .codeadd/docs/features/[FEATURE_ID]/discovery.md

|State|Action|

|---|---|

|Filled and recent|Use as context, skip to Phase 4|

|Empty/template|Phase 2 (full analysis)|

|Outdated|Phase 2 focused on changes|

Phase 1.5: Past Features Discovery

Goal: Identify features with direct or indirect relation to the current feature.

EXECUTE as a separate subagent [read-only, light] BEFORE Phase 2.

Cache: IF past-features.md exists AND metadata.updated = today → reuse, skip Phase 1.5.

Required input:

Process:

1. Extract keywords from about.md (domain, entities, actions)
2. For each feature in RECENT_CHANGELOGS:
   a. Read the "## Quick Ref" section of changelog.md (if it exists) → match by domain, keywords, touched
   b. IF Quick Ref does not exist: read first 30 lines of changelog.md as fallback
3. For each match found:
   a. Read the full iterations.jsonl of the feature
   b. Read the about.md of the feature (scope, requirements)
   c. Classify the relation: extends | depends | conflicts | shares-pattern | shares-domain
4. Return the past-features.md content in your report — you write no file

Match criteria (in order of relevance):

| Criterion | Weight |

|-----------|--------|

| Same domain (Quick Ref domain) | High |

| Files in common (Quick Ref touched) | High |

| Keywords in common (Quick Ref keywords) | Medium |

| Patterns in common (Quick Ref patterns) | Medium |

| Same module/package | Low |

Returns: the complete past-features.md content, in the subagent's report.

⛔ This phase runs read-only and writes NO file. The subagent dispatched here is

@discovery-agent, which declares readonly: true. The dispatching step writes

.codeadd/docs/features/${FEATURE_ID}/past-features.md from what comes back. Phase 2 below is a separate

[read-write] dispatch and is not subject to this.

past-features.md format:

# Past Features Analysis: [Feature Name]

## Matches

### F[XXXX]-[name] ([relation-type])
- **Domain:** [domain1, domain2]
- **Shared files:** `src/path/file.ts`
- **Patterns used:** [pattern1, pattern2]
- **Key decisions:** [most relevant decision]
- **Iterations summary:** N iterations, N pivots
- **Relevance:** [why it matters for the current feature]

## No Match
- F[XXXX]-[name] — [reason in 1 line]

## Metadata
{"updated":"YYYY-MM-DD","feature":"F[XXXX]-[name]","matches":N,"total_analyzed":N,"by":"past-features-agent"}

Phase 2: Focused Analysis

Goal: Analyze ONLY what is relevant to the feature.

EXECUTE as a separate subagent [read-write, standard] AFTER Phase 1.5.

Wiki grounding: the dispatching command passes selected .codeadd/wiki/ page paths (from add--knowledge-discovery, when the wiki exists) into this subagent's prompt. Build on documented patterns instead of re-deriving them; if a page contradicts the code, flag the contradiction in the subagent's return — it feeds the wiki maintenance loop.

BEFORE analyzing the codebase:

1. Read .codeadd/docs/features/${FEATURE_ID}/past-features.md (generated by Phase 1.5)
2. Use as context:
   - Files already touched by related features → prioritize in search
   - Patterns used → follow the same ones
   - Past decisions → do not contradict
   - Potential conflicts → map them
3. Include "Related Features" section in discovery.md
1. Read about.md → understand requirements
2. Identify domain/area affected
3. Search related files (Glob/Grep)
4. Identify existing similar patterns
5. Map dependencies

What to analyze:

{"analysisAreas":{"Entities":"Models/entities related to the domain","Patterns":"Similar features as reference","Infrastructure":"Existing services, repositories, controllers","Frontend":"Related components, hooks, stores","Integrations":"External APIs, webhooks, events"}}

Phase 3: Structure Findings

The file is written under .codeadd/docs/ — follow Docs Branch in {{skill:add--doc-schemas/SKILL.md}}.

Template discovery.md (Business Style):

# Discovery: [Feature]

## Summary
{"patterns":["main pattern"],"files_create":N,"files_modify":N,"deps":["critical dep"],"complexity":"low|medium|high","risks":["main risk"]}

---

## Technical Context

### Relevant Stack
- **Backend:** [specific technologies]
- **Frontend:** [specific technologies]
- **Infra:** [if applicable]

### Identified Patterns
- **[Pattern]:** used in [location] — [how to apply here]

---

## Codebase Analysis

### Related Files
- `path/file.ts` — [purpose, ~10 words]

### Similar Features
- **[Feature X]:** [what to reuse] — `path/`

---

## File Mapping

### Create
- `path/new-file.ts` — [purpose]

### Modify
- `path/existing.ts` — [what changes]

---

## Prerequisites Analysis (CRITICAL)

**Goal:** Identify WHAT MUST EXIST for the feature to work.

**For EACH requirement in about.md, analyze across all prerequisite types:**

| Type | Requirement | Prerequisite | Exists? | Action |
|------|-------------|--------------|---------|--------|
| Data/Model | RF01 | Field X on entity Y | ✅/❌ | Create if ❌ |
| Flow | RF01 | Endpoint to assign X | ✅/❌ | Create if ❌ |
| Integration | RF01 | External API Y | ✅/❌ | Configure if ❌ |
| Existing Data | RF01 | Records with field X | ✅/❌ | Migrate if ❌ |

**Rule:** If any prerequisite is ❌, the feature CANNOT be considered complete without implementing it first.

---

## Delivery Completeness

**Central question:** With this scope, can the end user USE the functionality?

### Functional Delivery Validation

| Validated in Questionnaire | Required Layer | In Scope? | User can use? |
|----------------------------|----------------|-----------|---------------|
| [validated item] | Frontend/Backend/DB | ✅/❌ | ✅/❌ |

**Failure examples:**
- Validated "checkbox" but excluded frontend → ❌ User can't use
- Validated "type choice" but excluded frontend → ❌ User can't use
- Backend only without UI → ❌ Feature unusable (except for pure APIs)

**If "User can use?" = ❌ → Scope INCOMPLETE. Add the missing layer.**

---

## Dependencies

### Internal
- `@package/module` — [what to use]

### External
- `package@version` — [purpose]

---

## Technical Assumptions

- **[Assumption]:** [impact if incorrect]

---

## Identified Risks

- **[Risk]:** [mitigation]

---

## Planning Summary

[3-5 lines: complexity, attention points, critical dependencies]

---

## Updates
[{"date":"YYYY-MM-DD","change":"short description"}]

---

## Metadata
{"updated":"YYYY-MM-DD","sessions":N,"by":"[subagent]"}

Always update ## Summary and ## Updates when there are changes.

Phase 4: Persist/Update

If creating: Write full discovery.md with metadata

If updating:

  1. Preserve valid existing information
  2. Complement with new findings
  3. Increment sessions in metadata
  4. Update updated date

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.