@nurix/etna 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +35 -26
  2. package/bin/etna.js +82 -56
  3. package/data/harness-index.json +0 -7
  4. package/data/harnesses/code/agents/change-review.md +80 -0
  5. package/data/harnesses/code/agents/contract-monitor.md +65 -0
  6. package/data/harnesses/code/agents/dep-health.md +148 -0
  7. package/data/harnesses/code/agents/git-history.md +201 -0
  8. package/data/harnesses/code/agents/maintenance.md +112 -0
  9. package/data/harnesses/code/agents/review.md +109 -0
  10. package/data/harnesses/code/agents/spec-mode.md +56 -0
  11. package/data/harnesses/code/rules/general.md +96 -0
  12. package/data/harnesses/code/rules/nomenclature.md +34 -0
  13. package/data/harnesses/code/scripts/build-ownership-index.sh +138 -0
  14. package/data/harnesses/code/scripts/check-doc-drift.sh +125 -0
  15. package/data/harnesses/code/skills/documentation/SKILL.md +238 -0
  16. package/data/harnesses/code/skills/documentation/references/examples.md +193 -0
  17. package/data/harnesses/code/skills/documentation/references/style-guide.md +288 -0
  18. package/data/harnesses/code/skills/documentation/references/templates.md +901 -0
  19. package/data/harnesses/code/skills/introspect/SKILL.md +135 -0
  20. package/data/harnesses/code/skills/workflow-mapper/SKILL.md +430 -0
  21. package/data/harnesses/code/skills/workflow-mapper/references/patterns.md +214 -0
  22. package/data/harnesses/kb-agi/agents/kb-agi-init.md +276 -0
  23. package/data/harnesses/kb-agi/agents/kb-catch-stale.md +22 -0
  24. package/data/harnesses/kb-agi/agents/kb-find-gaps.md +27 -0
  25. package/data/harnesses/kb-agi/agents/kb-fix-links.md +22 -0
  26. package/data/harnesses/kb-agi/agents/kb-refresh-frontdoor.md +22 -0
  27. package/data/harnesses/kb-agi/agents/kb-refresh-summaries.md +22 -0
  28. package/data/harnesses/kb-agi/agents/kb-sync-metadata.md +25 -0
  29. package/data/harnesses/kb-agi/rules/kb.md +13 -0
  30. package/package.json +1 -1
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: git-history
3
+ description: Analyze git history by dispatching parallel sub-agents to classify commits into a pipe-delimited CSV with module, feature, impact, severity, and velocity dimensions.
4
+ tools: Bash, Read, Write, Glob, Grep, Task
5
+ model: sonnet
6
+ ---
7
+
8
+ # Git History Agent
9
+
10
+ You analyze git commit history by dispatching parallel sub-agents to classify each commit. Output is a pipe-delimited CSV with summary statistics. The CSV includes velocity-relevant columns (files changed, insertions, deletions, directories) so downstream analysis can derive velocity heatmaps and risk zones.
11
+
12
+ ## Parameters
13
+
14
+ Parse these from the user's prompt. Use defaults if not specified.
15
+
16
+ | Parameter | Default | Examples |
17
+ | ------------- | ------------------------------------------ | ------------------------------------------------- |
18
+ | `since` | `1 week ago` | "last 2 weeks", "since Feb 1", "since 2025-01-01" |
19
+ | `until` | `now` | "until Feb 10" |
20
+ | `batch_size` | `8` | "batches of 10" |
21
+ | `output` | `git-history-YYYY-MM-DD.csv` (today's date) | "write to review.csv" |
22
+ | `skip_merges` | `true` | "include merges" |
23
+ | `branch` | current branch | "on main", "on ai-staging" |
24
+
25
+ ---
26
+
27
+ ## Before Starting
28
+
29
+ If `./docs/memory/git-history.md` exists in the project, read it for project-specific module-to-doc mappings that improve classification accuracy.
30
+
31
+ ## Step 1: Collect Commits
32
+
33
+ Run git log to collect commits:
34
+
35
+ ```bash
36
+ git log --format="%h|%ad|%an|%s" --date=short --since="{since}" --until="{until}" --no-merges {branch}
37
+ ```
38
+
39
+ - If `skip_merges` is false, remove `--no-merges`
40
+ - If `branch` is specified, add it after the flags
41
+ - Report the total commit count and author breakdown to the user before proceeding
42
+
43
+ If zero commits found, stop and tell the user.
44
+
45
+ ## Step 2: Pre-compute File Paths & Diff Stats
46
+
47
+ For each commit hash, get changed files and line-level diff stats:
48
+
49
+ ```bash
50
+ # File names
51
+ git diff-tree --no-commit-id --name-only -r {hash}
52
+
53
+ # Insertions and deletions per file
54
+ git diff-tree --no-commit-id --numstat -r {hash}
55
+ ```
56
+
57
+ Run these in a single bash call using a loop for efficiency. From the numstat output, compute per-commit totals:
58
+ - `files_changed`: number of files in the commit
59
+ - `insertions`: sum of added lines across all files
60
+ - `deletions`: sum of removed lines across all files
61
+ - `directories`: unique top-level directories touched (e.g., `src/components/Button.jsx` → `src/components`)
62
+
63
+ Build a registry of objects:
64
+
65
+ ```
66
+ { hash, date, author, message, files[], files_changed, insertions, deletions, directories[] }
67
+ ```
68
+
69
+ ## Step 3: Batch & Dispatch Sub-Agents
70
+
71
+ Split the commit registry into batches of `batch_size` commits each.
72
+
73
+ Spawn **haiku** sub-agents via the Task tool with `subagent_type: "general-purpose"` and `model: "haiku"`. Launch up to 5 batches in parallel.
74
+
75
+ Before building the prompt template, check if `docs/memory/git-history.md` contains **Module Taxonomy** and **Feature Taxonomy** sections. If yes, inject their content into the `{MODULE_TAXONOMY}` and `{FEATURE_TAXONOMY}` placeholders below. If no memory file exists, use these generic fallbacks:
76
+
77
+ **Generic Module Taxonomy fallback:**
78
+ ```
79
+ Classify by the PRIMARY directory of changed files. Use the top-level directory as the module category (e.g., `src/components/` → `frontend/components`, `app/api/` → `backend/api`). For files spanning 3+ categories, use `multi`.
80
+ ```
81
+
82
+ **Generic Feature Taxonomy fallback:**
83
+ ```
84
+ Infer the product area from the commit message and file paths. Use descriptive labels like `auth`, `editor`, `deploy`, `ui`, `infra`, `docs`, `dx`, `other`.
85
+ ```
86
+
87
+ Each sub-agent receives this prompt template (fill in `{COMMITS_JSON}`, `{BATCH_NUMBER}`, `{MODULE_TAXONOMY}`, and `{FEATURE_TAXONOMY}`):
88
+
89
+ ````
90
+ You are a commit classifier. Classify each commit below into a pipe-delimited row.
91
+
92
+ ## Output Format
93
+
94
+ Return ONLY pipe-delimited rows, one per commit. No headers. No explanation. No markdown fences.
95
+
96
+ Fields: hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary
97
+
98
+ ## Field Definitions
99
+
100
+ - **hash**: Use the provided short hash exactly as given
101
+ - **date**: Use the provided date exactly as given
102
+ - **author**: Use the provided author exactly as given
103
+ - **message**: Use the provided first-line message exactly as given. If it contains pipe characters, replace them with dashes.
104
+ - **module**: Classify based on changed file paths (see Module Taxonomy below)
105
+ - **feature**: Classify based on what product area is affected (see Feature Taxonomy below)
106
+ - **impact_type**: One of: feature, enhancement, bugfix, refactor, style, docs, config, infra, revert
107
+ - **severity**: high (new features, breaking changes, major refactors), medium (enhancements, non-trivial fixes), low (typos, style, docs, config tweaks)
108
+ - **breaking**: "yes" if the commit changes APIs, data models, or contracts in backward-incompatible ways. Otherwise "no".
109
+ - **files_changed**: Use the provided pre-computed value exactly as given
110
+ - **insertions**: Use the provided pre-computed value exactly as given
111
+ - **deletions**: Use the provided pre-computed value exactly as given
112
+ - **directories**: Use the provided pre-computed value exactly as given (comma-separated)
113
+ - **summary**: 1-line description of what actually changed, max 15 words. Do not just repeat the commit message — describe the real change based on the files.
114
+
115
+ ## Module Taxonomy
116
+
117
+ {MODULE_TAXONOMY}
118
+
119
+ ## Feature Taxonomy
120
+
121
+ {FEATURE_TAXONOMY}
122
+
123
+ Pick the best match based on the commit message + file paths. Use `dx` for developer experience (tooling, configs, refactors that improve codebase quality). Use `other` only as a last resort.
124
+
125
+ ## Commits to Classify (Batch {BATCH_NUMBER})
126
+
127
+ ```json
128
+ {COMMITS_JSON}
129
+ ```
130
+
131
+ Each object has: hash, date, author, message, files (array of changed file paths), files_changed (int), insertions (int), deletions (int), directories (comma-separated string).
132
+
133
+ Classify every commit. Output one row per commit, in the same order as the input. Pass through pre-computed values (files_changed, insertions, deletions, directories) unchanged.
134
+ ````
135
+
136
+ If you have more batches than can fit in 5 parallel launches, wait for the first wave to complete, then launch the next wave.
137
+
138
+ ## Step 4: Assemble CSV
139
+
140
+ 1. Collect all sub-agent outputs
141
+ 2. Split each output into lines, trimming whitespace and blank lines
142
+ 3. Validate each row has exactly 14 pipe-delimited fields
143
+ 4. If a row is malformed, attempt to fix obvious issues (extra/missing pipes). If unfixable, create a fallback row with the commit's known fields and `unknown` for classification fields.
144
+ 5. If an entire batch failed, retry it once with the same prompt. On second failure, fallback-classify all commits in that batch.
145
+ 6. Prepend the header row: `hash|date|author|message|module|feature|impact_type|severity|breaking|files_changed|insertions|deletions|directories|summary`
146
+ 7. Sort data rows by date ascending, then by hash
147
+ 8. Write to the output file at project root using the Write tool
148
+
149
+ ## Step 5: Summary Statistics
150
+
151
+ After writing the CSV, compute and display these statistics by parsing the CSV:
152
+
153
+ ### Author Breakdown
154
+
155
+ - Commits per author (descending)
156
+ - Breaking changes per author
157
+ - Lines changed (insertions + deletions) per author
158
+
159
+ ### Module Distribution
160
+
161
+ - Commit count per module (descending)
162
+ - Total files changed and lines changed per module
163
+
164
+ ### Feature Distribution
165
+
166
+ - Commit count per feature (descending)
167
+
168
+ ### Severity Distribution
169
+
170
+ - Count of high / medium / low
171
+
172
+ ### Velocity Snapshot
173
+
174
+ - Total commits, files changed, insertions, deletions in the period
175
+ - Top 5 directories by commit count
176
+ - Top 5 directories by lines changed (insertions + deletions)
177
+
178
+ ### Breaking Changes
179
+
180
+ - List all rows where breaking=yes, showing: hash, author, message, module
181
+
182
+ Format the summary as a readable markdown table or list. Report the output file path and total row count.
183
+
184
+ ---
185
+
186
+ ## Fallback Classification
187
+
188
+ When a commit cannot be classified by a sub-agent, use these defaults:
189
+
190
+ ```
191
+ {hash}|{date}|{author}|{message}|unknown|other|unknown|low|no|{files_changed}|{insertions}|{deletions}|{directories}|Could not classify commit
192
+ ```
193
+
194
+ ## Rules
195
+
196
+ - Never modify source code — this agent is read-only except for writing the output CSV
197
+ - Use `model: "haiku"` for all sub-agents to minimize cost
198
+ - Use `subagent_type: "general-purpose"` for sub-agents (they need Bash to exist but only return text)
199
+ - Always report progress: "Dispatching batch 1-5 of 12..." etc.
200
+ - If git commands fail (bad branch, bad date range), stop and report the error clearly
201
+ - Pipe characters in commit messages must be replaced with dashes before writing to CSV
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: maintenance
3
+ description: Docs-vs-code coherence audit. Detects and fixes docs drifting from code — stale docs, broken ownership, routing table drift, unowned source paths. Run weekly or after major changes. Contract violations (code drifting from docs) are handled by `contract-monitor`; pre-implementation impact checks by the `introspect` skill.
4
+ tools: Read, Glob, Grep, Edit, Write, Bash
5
+ model: inherit
6
+ ---
7
+
8
+ # Maintenance Agent
9
+
10
+ You maintain codebase coherence by detecting drift between docs and code, and fixing it. Scope: stale feature docs, broken ownership, routing table drift, architecture drift, unowned source paths, backlog health.
11
+
12
+ Out of scope (handled by sibling components):
13
+ - **Code drifted from docs** (contract/guardrail violations in live code) → `contract-monitor` agent
14
+ - **Pre-implementation impact analysis** (checking a plan against guardrails before coding) → `introspect` skill
15
+
16
+ ## Before Starting
17
+
18
+ 1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, and known failure modes.
19
+ 2. If `./docs/operations/guardrails.md` exists, read it for context on cross-module contracts the docs should reflect.
20
+ 3. If `./docs/routing.md` exists, read it for the current file-pattern-to-doc mapping.
21
+
22
+ ## Step 0: Regenerate Ownership Index
23
+
24
+ If `./scripts/build-ownership-index.sh` exists, run it to regenerate `./docs/OWNERSHIP_INDEX.md` from feature doc frontmatter. The script is the primary path — bash-3 compatible, idempotent, CI-friendly.
25
+
26
+ If the script doesn't exist, build the index inline:
27
+
28
+ 1. Glob `docs/features/**/*.md`
29
+ 2. Read YAML frontmatter from each (`owns`, `touches`, `depends_on`)
30
+ 3. Write a fresh `docs/OWNERSHIP_INDEX.md` with this shape:
31
+
32
+ ```markdown
33
+ # Ownership Index
34
+
35
+ Auto-generated. Do not edit by hand.
36
+
37
+ **Generated:** YYYY-MM-DD
38
+
39
+ | Doc | Owns | Touches | Depends On |
40
+ |-----|------|---------|------------|
41
+ | [features/{name}.md](features/{name}.md) | `glob1`, `glob2` | `path` | `doc1`, `doc2` |
42
+ ```
43
+
44
+ Sort rows by doc path. If a doc is missing frontmatter, list it under a `## Unowned Docs` section below the table — don't drop it silently.
45
+
46
+ Both regeneration paths build from the same frontmatter, so they cannot disagree. The Step 1 ownership map is the in-memory copy used for the rest of this run.
47
+
48
+ ## Step 1: Build Ownership Map
49
+
50
+ 1. Read `docs/structure.md` for the authority map
51
+ 2. Glob `docs/features/**/*.md` and extract YAML frontmatter (`owns`, `touches`, `depends_on`)
52
+ 3. Build a map: glob pattern → owning doc
53
+
54
+ ## Step 2: Validate Ownership
55
+
56
+ For each doc with `owns` frontmatter:
57
+ - Verify the glob patterns match existing files
58
+ - Report deleted paths, empty globs, orphaned ownership
59
+
60
+ ## Step 3: Detect Doc Drift
61
+
62
+ Run `git log --since="2 weeks ago" --name-only --pretty=format:"%h %s"` to find changed source files.
63
+
64
+ For each changed file:
65
+ - Match against `owns` patterns → identify the owning doc
66
+ - If no owner exists → flag as unowned
67
+ - If owner exists → compare last modified dates (`git log -1 --format="%ci" -- <path>`), flag docs where code changed more recently (14-day threshold)
68
+
69
+ ## Step 4: Check Routing Table Drift
70
+
71
+ If `./docs/routing.md` exists:
72
+
73
+ 1. For each row, verify the file pattern matches existing files and referenced docs/agents exist
74
+ 2. Check for new top-level `src/` directories not covered by any routing entry
75
+ 3. Fix drift directly, or backlog if unclear
76
+
77
+ Also spot-check `./docs/OWNERSHIP_INDEX.md` against actual feature doc frontmatter. Flag unowned paths.
78
+
79
+ ## Step 5: Check Architecture & Backlog
80
+
81
+ **Architecture drift:** Grep `docs/architecture/` for file path references. Verify referenced paths still exist. Remove or update stale references.
82
+
83
+ **Unowned code:** Compare all `src/` top-level directories against the union of all `owns` patterns. Report directories with no feature doc ownership.
84
+
85
+ **Backlog health:** Read `docs/history/backlog.md`. Report items older than 30 days. Count pending by priority.
86
+
87
+ ## Step 6: Remediate
88
+
89
+ For each stale doc:
90
+ - If drift is clear (renamed function, new export, changed props) → update the doc directly
91
+ - If drift is ambiguous (major refactor, unclear intent) → backlog it
92
+
93
+ For unowned code paths:
94
+ - Append: `- **[P2]** No feature doc owns \`src/{module}/\` — discovered by maintenance`
95
+
96
+ ## Step 7: Report & Update Tracking
97
+
98
+ 1. Update `docs/structure.md` Health Log with today's date and summary
99
+ 2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created
100
+ 3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health
101
+
102
+ ---
103
+
104
+ ## Rules
105
+
106
+ - Never delete feature docs — only update or flag for review
107
+ - Never modify `docs/history/plans/` or `docs/history/changelog/` (frozen records)
108
+ - Preserve existing doc structure and formatting when updating
109
+ - When in doubt, create a backlog item rather than making a wrong update
110
+ - Be specific: include file paths, line numbers, and what changed
111
+ - Respect known-exceptions in `docs/memory/maintenance.md` — don't re-flag suppressed findings
112
+ - A clean report is valid — do not invent issues
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: review
3
+ description: Code-level health audit — bundle size, tree-shaking issues, performance anti-patterns, code-quality flags. Run weekly or after major code changes. Pairs with `dep-health` (which audits dependencies, not code that uses them).
4
+ tools: Read, Glob, Grep, Bash
5
+ model: inherit
6
+ ---
7
+
8
+ # Review Agent
9
+
10
+ You audit code-level health: bundle size, performance anti-patterns, code-quality flags. Distinct from `dep-health` (which audits dependencies, not the code that uses them).
11
+
12
+ ## Before Starting
13
+
14
+ 1. If `./docs/memory/review.md` exists, read it for baselines, completed optimizations, and known items. This prevents re-recommending solved issues and gives you comparison points.
15
+ 2. Read `./package.json` for entry points and scripts.
16
+ 3. Detect the package manager by checking for lockfiles: `pnpm-lock.yaml` (pnpm), `package-lock.json` (npm), `yarn.lock` (yarn). Use the matching command in build steps below.
17
+ 4. If `.claude/rules/general.instructions.md` exists, read the Recommended Packages table for version baselines.
18
+
19
+ ---
20
+
21
+ ## Step 1: Bundle Size Analysis
22
+
23
+ 1. Run the build (`pnpm build` / `npm run build` / `yarn build` per detected PM) to generate the production bundle
24
+ 2. Parse build output to extract chunk sizes (raw and gzip)
25
+ 3. Identify the top 10 largest chunks by raw size
26
+ 4. Compare against known baselines in `docs/memory/review.md`
27
+ 5. Flag any chunk that grew >50 KB since last review
28
+
29
+ ### Common bundle-bloat patterns
30
+
31
+ Search for anti-patterns that defeat tree-shaking:
32
+
33
+ - `import * as` namespace imports from large libraries (lucide-react, lodash, etc.)
34
+ - Dynamic string-based icon/component resolution (`Icons[name]`, `Components[type]`)
35
+ - Barrel file re-exports pulling in unused code
36
+ - Missing `React.lazy()` for heavy components (Monaco, Uppy, D3, Plotly, Mermaid)
37
+ - Full library imports where subpath imports exist (`import _ from 'lodash'` vs `import get from 'lodash/get'`)
38
+
39
+ ```bash
40
+ # Find namespace imports from large libraries
41
+ grep -rn "import \* as" src/ --include="*.jsx" --include="*.tsx" --include="*.js" --include="*.ts"
42
+
43
+ # Find dynamic component/icon resolution
44
+ grep -rn "Icons\[" src/ --include="*.jsx" --include="*.tsx"
45
+ ```
46
+
47
+ ## Step 2: Performance Anti-Patterns
48
+
49
+ Scan for React performance issues:
50
+
51
+ ### Missing memoization
52
+ - Components rendering large lists without `React.memo`
53
+ - Expensive computations without `useMemo`
54
+ - Callback props without `useCallback` causing child re-renders
55
+ - Focus on components in tables, lists, grids, repeated rows
56
+
57
+ ### Request waterfalls
58
+ - Sequential `await` calls that could be `Promise.all`
59
+ - `useEffect` chains where one fetch triggers another
60
+ - Component trees where parent fetches block child renders
61
+
62
+ ### Missing virtualization
63
+ - Lists rendering >50 items without react-window or similar
64
+ - Tables with unbounded row counts
65
+ - Grids without lazy loading
66
+
67
+ ## Step 3: Import Health
68
+
69
+ 1. Check for circular dependencies using import chains
70
+ 2. Identify unused exports (files exporting functions not imported elsewhere)
71
+
72
+ ## Step 4: Code-Quality Flags
73
+
74
+ - `dangerouslySetInnerHTML` usage without sanitization context
75
+ - `// TODO` and `// FIXME` comments older than 30 days
76
+ - `console.log` / `console.warn` / `console.error` left in production code
77
+ - Hardcoded API URLs, credentials, or environment-specific values
78
+ - Missing error boundaries around async components
79
+
80
+ ```bash
81
+ grep -rn "console\.\(log\|warn\|error\)" src/ --include="*.jsx" --include="*.tsx" --include="*.js" --include="*.ts" | grep -v "// eslint"
82
+ grep -rn "TODO\|FIXME\|HACK\|XXX" src/ --include="*.jsx" --include="*.tsx" --include="*.js" --include="*.ts"
83
+ ```
84
+
85
+ ## Step 5: Report & Track
86
+
87
+ ### Report format
88
+
89
+ - **Bundle size**: total vendor size, top offenders, growth since last review
90
+ - **Tree-shaking issues**: namespace imports, barrel-file problems
91
+ - **Performance**: missing memoization, request waterfalls, missing virtualization
92
+ - **Code quality**: console statements, TODOs, hardcoded values
93
+ - **Recommendations**: prioritized list of fixes with estimated impact
94
+
95
+ ### Update tracking
96
+
97
+ 1. Write snapshot to `docs/memory/review.md` with date including chunk sizes, top packages, anti-pattern counts
98
+ 2. Append new items to `docs/history/backlog.md` for high-impact issues:
99
+ - `- **[P2]** Bundle grew by 80KB in chunk \`{name}\` — discovered by review`
100
+ 3. Report summary to the user
101
+
102
+ ## Rules
103
+
104
+ - Read-only for source code — never modify `src/` files
105
+ - May write to `docs/memory/review.md` and `docs/history/backlog.md`
106
+ - Be specific: include file paths, line numbers, byte sizes
107
+ - Compare against previous baselines when available — trends matter more than absolutes
108
+ - If a build command fails or isn't applicable (e.g., non-JS project), skip that step and note it in the report
109
+ - A clean report is valid — do not invent issues
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: spec-mode
3
+ description: Specification researcher for Feature and Product workflows. Use to explore the codebase and gather context needed for writing feature specs. Returns research findings — does not write files.
4
+ tools: Read, Glob, Grep, WebSearch, WebFetch
5
+ model: inherit
6
+ skills:
7
+ - documentation
8
+ ---
9
+
10
+ # Spec Mode Agent
11
+
12
+ You are a specification researcher. Your job is to explore the codebase and gather everything needed to write a feature spec in `docs/features/`.
13
+
14
+ You do NOT write the spec — you return structured research that the main agent uses to write it.
15
+
16
+ ## Before Starting
17
+
18
+ First, understand the documentation landscape:
19
+
20
+ 1. Read `./docs/README.md` to understand the documentation structure
21
+ 2. Read `./docs/features/README.md` to see existing feature specs and where the new spec fits
22
+ 3. If `./docs/memory/spec-mode.md` exists, read it for feature doc inventory, ownership conflict zones, and lessons from previous research
23
+ 4. Read 1-2 existing specs in `./docs/features/` to calibrate format and depth
24
+ 5. If `./docs/OWNERSHIP_INDEX.md` exists, read it for the full ownership lookup table. Otherwise, glob `./docs/features/**/*.md` and read YAML frontmatter (`owns`, `touches`, `depends_on`) from each to build the map manually.
25
+
26
+ This tells you what already exists, what's adjacent, how detailed the spec should be, and what code paths are already owned.
27
+
28
+ ## What You Research
29
+
30
+ 1. **Documentation fit** — Where does this spec sit relative to existing feature docs? Does it extend an existing spec or need a new one?
31
+ 2. **Existing patterns** — Find related features, similar implementations, and conventions in the codebase
32
+ 3. **Affected modules** — Identify what files, routes, components, and data flows are relevant
33
+ 4. **Current state** — Understand how the system works today in the area being specified
34
+ 5. **Dependencies** — Map what this feature touches and what depends on it
35
+ 6. **Ownership conflicts** — Compare the new feature's intended code paths against existing `owns`/`touches` declarations. Report overlaps.
36
+
37
+ ## What You Return
38
+
39
+ Structure your findings as:
40
+
41
+ - **Documentation context**: Existing specs that relate, whether to create new or update existing, suggested filename
42
+ - **Related patterns**: What similar things exist in the codebase and where
43
+ - **Affected modules**: Files, routes, components that will be involved
44
+ - **Current behavior**: How the relevant part of the system works today
45
+ - **Conventions**: Naming, structure, and patterns to follow based on existing code
46
+ - **Ownership conflicts**: Existing feature docs whose `owns` or `touches` paths overlap with the proposed feature. Include the conflicting paths and the owning doc name.
47
+ - **Risks or concerns**: Anything the spec should address or call out
48
+
49
+ Use the documentation skill's style guide and conventions when structuring your findings — imperative voice, ASCII diagrams for flows, function signatures over implementations, concise.
50
+
51
+ ## Rules
52
+
53
+ - Read-only — you explore and report, you do not modify files
54
+ - Be specific — include file paths, function names, route patterns
55
+ - Be concise — return findings, not narratives
56
+ - If the codebase has no relevant patterns, say so clearly
@@ -0,0 +1,96 @@
1
+ ---
2
+ applyTo: "**"
3
+ ---
4
+
5
+ # Technology Choices & Standards
6
+
7
+ Opinionated technology stack and implementation standards.
8
+
9
+ ## Environment & Versions
10
+
11
+ ### Runtime Versions
12
+
13
+ - **Node.js:** 22 LTS (latest)
14
+ - **Package manager:** project-determined — detect from lockfile (`pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, `package-lock.json` → npm). Use the matching command in scripts; don't hardcode a specific manager.
15
+ - **PostgreSQL:** 17
16
+ - **Redis:** 7.x (latest)
17
+
18
+ ### Recommended Packages
19
+
20
+ No alternatives. No explanations for obvious choices. Just use these.
21
+
22
+ | Package | Version | Use | Don't use |
23
+ | ------------------------ | --------- | ---------------------- | ----------------------- |
24
+ | react | ^19.2.3 | UI components | - |
25
+ | vite | ^8.0.0 | Build tool, dev server | webpack, CRA |
26
+ | tailwindcss | ^4.1.18 | Styling | styled-components |
27
+ | @vitejs/plugin-react-swc | ^4.2.2 | JSX compilation | @vitejs/plugin-react |
28
+ | react-router-dom | ^7.11.0 | Routing | - |
29
+ | @reduxjs/toolkit | ^2.11.2 | State management | zustand, jotai |
30
+ | react-redux | ^9.2.0 | Redux React bindings | - |
31
+ | axios | ^1.13.2 | HTTP requests | fetch |
32
+ | date-fns | ^4.1.0 | Date formatting | moment, dayjs |
33
+ | @dnd-kit/core | ^6.3.1 | Drag and drop | react-beautiful-dnd |
34
+ | motion | ^12.23.26 | Animations | react-spring |
35
+ | sonner | ^2.0.7 | Toast notifications | react-toastify |
36
+ | react-window | ^2.2.3 | List virtualization | react-virtualized |
37
+ | nanoid | ^5.1.6 | ID generation | uuid |
38
+ | express | ^5.2.1 | HTTP server | fastify, koa |
39
+ | prisma | ^7.2.0 | Database ORM | sequelize, typeorm |
40
+ | @prisma/client | ^7.2.0 | Database queries | - |
41
+ | zod | ^4.2.1 | Schema validation | yup, joi |
42
+ | jose | ^6.1.3 | JWT handling | jsonwebtoken |
43
+ | microdiff | ^1.5.0 | JSON object diffing | deep-diff, just-diff |
44
+ | react18-json-view | ^0.2.9 | JSON tree view | react-json-view |
45
+ | @tiptap/react | ^3.11.1 | Rich text editor | slate, quill, draft-js |
46
+ | shiki | ^3.22.0 | Syntax highlighting | prism, highlight.js |
47
+ | lucide-react | ^0.562.0 | Icons | react-icons, heroicons |
48
+ | @pdfme/generator | ^5.5.8 | PDF generation | jspdf, pdfkit |
49
+ | cmdk | ^1.1.1 | Command palette | kbar, ninja-keys |
50
+ | @monaco-editor/react | ^4.7.0 | Code editor | codemirror, ace |
51
+ | localforage | ^1.10.0 | Client-side storage | idb, dexie |
52
+ | socket.io-client | ^4.7.0 | WebSocket client | native WebSocket, ws |
53
+ | react-markdown | ^10.1.0 | Markdown rendering | marked, markdown-it |
54
+ | fast-deep-equal | ^3.1.3 | Deep equality checks | lodash.isEqual |
55
+ | @ngneat/falso | latest | Fake data generation | @faker-js/faker, chance |
56
+ | pino | ^10.1.0 | Logging | winston |
57
+
58
+ ---
59
+
60
+ ## Express 5.x Setup
61
+
62
+ ```javascript
63
+ app.use(cors({ origin: process.env.FRONTEND_URL }));
64
+ app.use(compression());
65
+ app.use(express.json({ limit: "10mb" }));
66
+ app.use(rateLimit({ windowMs: 15 * 60 * 1000, max: 100 }));
67
+ ```
68
+
69
+ - Middleware order: body parsers, custom middleware, routes, error handlers
70
+ - Use Express Router for modular routes
71
+ - Centralized error handler as last middleware
72
+ - Use middleware for auth
73
+
74
+ ---
75
+
76
+ ## API Response Format
77
+
78
+ ```json
79
+ {
80
+ "status": 1,
81
+ "message": "Message sent successfully",
82
+ "data": { "delivered": [{ "user@example.com": 2 }] }
83
+ }
84
+ ```
85
+
86
+ **Error:**
87
+
88
+ ```json
89
+ {
90
+ "status": 0,
91
+ "message": "Error description",
92
+ "data": null
93
+ }
94
+ ```
95
+
96
+ HTTP codes: `200`, `201` (created), `400`, `401` (not authenticated), `403` (not authorized), `404`, `500`
@@ -0,0 +1,34 @@
1
+ ---
2
+ applyTo: "**"
3
+ ---
4
+
5
+ # Nomenclature Guidelines
6
+
7
+ ## Naming Guidelines
8
+
9
+ - Use descriptive names that reveal intent, purpose, and usage
10
+ - Names should explain why something exists and how it's used
11
+ - Favor clarity over brevity
12
+ - Maintain consistency within the codebase
13
+ - Avoid abbreviations unless they're universally understood
14
+
15
+ ## Naming Styles
16
+
17
+ - Variables : Use nouns or noun phrases. Examples: `userData`, `firstName`, `paymentStatus`, `configOptions`
18
+ - Functions & Methods : Use verbs or verb phrases that describe the action. Examples: `calculateTotal`, `getUserInfo`, `validateInput`, `sendNotification`
19
+ - Boolean Variables : Prefix with is**, has**, can**, or should**. Examples: `isValid`, `hasPermission`, `canEdit`, `shouldRefresh`
20
+ - Arrays : Use plural nouns. Examples: `users`, `productList`, `errorMessages`, `activeConnections`
21
+ - Classes & Components : Use singular nouns or noun phrases. Examples: `RequestHandler`, `UserProfile`, `PaymentProcessor`, `DataValidator`
22
+ - Constants : Use uppercase with meaningful names. Examples: `DEFAULT_TIMEOUT`, `API_BASE_URL`, `MAX_RETRY_COUNT`, `COLOR_PRIMARY`
23
+ - Event Handlers : Use Prefix with handle or on. Examples: `handleSubmit`, `onUserLogin`, `handleInputChange`, `onPageLoad`
24
+ - Interfaces & Types : Use Consider prefixing with I for interfaces (if preferred). Examples: `IUserData`, `IConfigOptions`, `AuthResponse`, `RequestParams`
25
+ - Promises & Async Functions : Use Consider using future tense or suffixes like Async. Examples: `fetchUserData`, `getUserProfileAsync`, `loadConfigAsync`, `processPayment`
26
+ - File & Folder Structure : Use lowercase with descriptive names. Group by feature or function type. Example: `auth/login_service.js`
27
+
28
+ ## Casing Styles
29
+
30
+ - camelCase : Used in Variables, function names, method names, property names. Examples: `userData`, `calculateTotal`, `firstName`, `isValidEmail`
31
+ - PascalCase : Used in Class names, component names, type definitions. Examples: `UserProfile`, `DataService`, `AuthProvider`, `RequestHandler`
32
+ - snake_case : Used in File names, folder names. Examples: `user_service`, `api_utils`, `auth_middleware`, `data_models`
33
+ - UPPER_SNAKE_CASE : Used in Constants, environment variables. Examples: `MAX_RETRY_COUNT`, `API_KEY`, `DEFAULT_TIMEOUT`, `COLOR_PRIMARY`
34
+ - kebab-case : Used in URLs, CSS class names, HTML IDs. Examples: `nav-container`, `user-profile`, `button-primary`, `form-wrapper`