nextjs-hackathon-stack 0.1.35 → 0.1.36
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.
- package/dist/index.js +33 -14
- package/package.json +1 -1
- package/template/.cursor/agents/backend.md +6 -3
- package/template/.cursor/agents/business-intelligence.md +5 -3
- package/template/.cursor/agents/code-reviewer.md +3 -3
- package/template/.cursor/agents/frontend.md +6 -3
- package/template/.cursor/agents/security-researcher.md +1 -1
- package/template/.cursor/agents/technical-lead.md +8 -4
- package/template/.cursor/agents/test-qa.md +17 -11
- package/template/.cursor/memory/architecture-snapshot.md +78 -1
- package/template/.cursor/rules/architecture.mdc +1 -0
- package/template/.cursor/rules/coding-standards.mdc +4 -4
- package/template/.cursor/rules/forms.mdc +2 -0
- package/template/.cursor/rules/general.mdc +2 -3
- package/template/.cursor/rules/supabase.mdc +1 -1
- package/template/.cursor/rules/testing.mdc +7 -5
- package/template/.cursor/skills/build-feature/SKILL.md +199 -0
- package/template/.cursor/skills/create-api-route/SKILL.md +1 -1
- package/template/.cursor/skills/discover-feature/SKILL.md +111 -0
- package/template/.cursor/skills/memory/SKILL.md +208 -0
- package/template/.cursor/skills/review-branch/SKILL.md +1 -1
- package/template/.cursor/skills/security-audit/SKILL.md +1 -1
- package/template/.cursor/skills/security-audit/references/audit-steps.md +1 -1
- package/template/AGENTS.md +29 -1
- package/template/CLAUDE.md +19 -7
- package/template/README.md +201 -2
- package/template/drizzle.config.ts +1 -1
- package/template/src/features/todos/components/todo-list.tsx +1 -1
- package/template/src/shared/__tests__/schema.test.ts +1 -1
- package/template/src/shared/db/index.ts +4 -1
- package/template/src/shared/db/profiles.schema.ts +15 -0
- package/template/src/shared/db/schema.ts +2 -29
- package/template/src/shared/db/todos.schema.ts +16 -0
- package/template/vitest.config.ts +4 -4
- package/template/.cursor/skills/create-feature/SKILL.md +0 -136
- /package/template/.cursor/skills/{create-feature → build-feature}/references/server-action-test-template.md +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-feature
|
|
3
|
+
description: Plan and implement a new feature following TDD — tech-lead planning, backend + frontend in parallel, review gate, and memory sync. Run in a fresh conversation after /discover-feature. Triggers: 'build feature', 'implement feature', 'start building', 'build from requirements'. NOT for: bug fixes, refactors, or API-only routes (use /create-api-route).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build Feature Skill
|
|
7
|
+
|
|
8
|
+
> **Invoke as:** `/build-feature @.requirements/<feature-name>.md`
|
|
9
|
+
> Run in **Agent mode** in a **fresh conversation** (not the same one where you ran `/discover-feature`).
|
|
10
|
+
|
|
11
|
+
## IMPORTANT: Fresh Conversation Required
|
|
12
|
+
|
|
13
|
+
If this conversation already contains requirements gathering, **start a new conversation** first. Reusing the same context risks hitting the token limit mid-implementation.
|
|
14
|
+
|
|
15
|
+
If context usage exceeds 60% at any point, stop and tell the user to continue in a new conversation referencing the current step.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Process
|
|
20
|
+
|
|
21
|
+
### 1. Read the Requirements
|
|
22
|
+
|
|
23
|
+
Read `.requirements/<feature-name>.md`. Confirm the spec exists and has acceptance criteria before proceeding. If no spec exists, tell the user to run `/discover-feature <description>` first.
|
|
24
|
+
|
|
25
|
+
### 2. Load Architecture Context via MCP Memory
|
|
26
|
+
|
|
27
|
+
Load project context with targeted queries (token-efficient):
|
|
28
|
+
|
|
29
|
+
1. Read `package.json` to get the project name (`<project-name>`)
|
|
30
|
+
2. `search_memory` with `tags: ["project:<project-name>", "domain:ui"]` — installed shadcn/ui components
|
|
31
|
+
3. `search_memory` with `tags: ["project:<project-name>", "domain:database"]` — existing schema
|
|
32
|
+
4. `search_memory` with `tags: ["project:<project-name>", "domain:features"]` — existing features and paths
|
|
33
|
+
5. `search_memory` with `tags: ["project:<project-name>", "domain:patterns"]` — canonical pattern references
|
|
34
|
+
6. `search_memory` with `tags: ["project:<project-name>", "domain:rules"]` — active lint/TS rules
|
|
35
|
+
|
|
36
|
+
**Fallback**: if memory service is unavailable or returns no results, read `.cursor/memory/architecture-snapshot.md` directly.
|
|
37
|
+
|
|
38
|
+
**Also read `eslint.config.ts` and `tsconfig.json`** to confirm active rules and compiler flags before writing any code.
|
|
39
|
+
|
|
40
|
+
**Dependency pre-flight:**
|
|
41
|
+
```bash
|
|
42
|
+
pnpm ls drizzle-orm # Confirm installed version
|
|
43
|
+
pnpm typecheck # Confirm baseline passes — fix pre-existing errors first
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Planning (Tech Lead)
|
|
47
|
+
|
|
48
|
+
Before any code is written, produce a technical plan and get user approval.
|
|
49
|
+
|
|
50
|
+
Using the requirements + MCP memory context:
|
|
51
|
+
|
|
52
|
+
1. **Map acceptance criteria to technical tasks** — one task per agent, scoped to a single concern:
|
|
53
|
+
- Backend tasks: schema changes, Server Actions, queries, RLS policies
|
|
54
|
+
- Frontend tasks: components, pages, hooks, shadcn installs
|
|
55
|
+
- Shared: Zod schemas, type definitions
|
|
56
|
+
|
|
57
|
+
2. **Plan the test structure**:
|
|
58
|
+
- List which test files will be created
|
|
59
|
+
- One `describe` block per acceptance criterion
|
|
60
|
+
- Which mocks are needed (`makeSupabaseMock`, HTTP mocks, etc.)
|
|
61
|
+
- Which edge cases map to which criteria
|
|
62
|
+
|
|
63
|
+
3. **Identify reuse**:
|
|
64
|
+
- Which canonical patterns to copy (from MCP memory results)
|
|
65
|
+
- Which shadcn components are already installed vs need installing
|
|
66
|
+
- Which shared utilities apply (`formFieldText`, `firstZodIssueMessage`, etc.)
|
|
67
|
+
|
|
68
|
+
4. **Present the plan to the user** and wait for approval before proceeding to Step 4.
|
|
69
|
+
|
|
70
|
+
> Present as a brief summary: what backend will do, what frontend will do, which tests will be written, any risks or decisions that need user input.
|
|
71
|
+
|
|
72
|
+
### 4. Create Feature Structure
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
src/features/<feature-name>/
|
|
76
|
+
├── components/
|
|
77
|
+
├── actions/
|
|
78
|
+
├── queries/
|
|
79
|
+
├── hooks/
|
|
80
|
+
├── api/
|
|
81
|
+
├── lib/
|
|
82
|
+
└── __tests__/
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 5. Pre-Test Setup
|
|
86
|
+
|
|
87
|
+
Update `vitest.config.ts` to exclude files that cannot be meaningfully tested in jsdom:
|
|
88
|
+
- Drizzle schema file(s) (`src/shared/db/*.schema.ts`)
|
|
89
|
+
- Pure type-only files
|
|
90
|
+
- Portal/browser-API-dependent UI wrappers (e.g., `src/shared/components/ui/sonner.tsx`)
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// vitest.config.ts — add to coverage.exclude before writing tests
|
|
94
|
+
exclude: [
|
|
95
|
+
"src/shared/db/*.schema.ts",
|
|
96
|
+
"src/shared/components/ui/sonner.tsx",
|
|
97
|
+
]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 6. TDD: RED Phase
|
|
101
|
+
|
|
102
|
+
Write ALL test files first — zero implementation code at this stage:
|
|
103
|
+
- `__tests__/<component>.test.tsx` — component tests
|
|
104
|
+
- `__tests__/use-<feature>.test.ts` — hook tests (if applicable)
|
|
105
|
+
- `__tests__/<action>.action.test.ts` — action tests (see `references/server-action-test-template.md`)
|
|
106
|
+
- `__tests__/<feature>.queries.test.ts` — query tests
|
|
107
|
+
|
|
108
|
+
Import mock helpers from `@/shared/test-utils/supabase-mock` — do not inline mock chains.
|
|
109
|
+
|
|
110
|
+
**Coverage guidance:** Threshold is 95% statements/functions/lines and 90% branches. Use `/* v8 ignore next */` for genuinely unreachable defensive branches.
|
|
111
|
+
|
|
112
|
+
**For standard CRUD features**: write tests and implementation per module (queries test+impl → actions test+impl → UI test+impl) instead of strict all-RED-then-all-GREEN.
|
|
113
|
+
|
|
114
|
+
**BLOCKING GATE — do not proceed until this passes:**
|
|
115
|
+
Run `pnpm test:unit` and paste the output. All new tests must **FAIL** (red). If any new test passes without implementation, the test is wrong — fix it before continuing.
|
|
116
|
+
|
|
117
|
+
### 7. TDD: GREEN Phase
|
|
118
|
+
|
|
119
|
+
Launch **@backend and @frontend in parallel** — they work on independent files:
|
|
120
|
+
|
|
121
|
+
| @backend handles | @frontend handles |
|
|
122
|
+
|-----------------|-------------------|
|
|
123
|
+
| `actions/` | `components/` |
|
|
124
|
+
| `queries/` | `page.tsx` |
|
|
125
|
+
| `schema.ts` changes | shadcn component installs |
|
|
126
|
+
| RLS policies | Loading/empty states |
|
|
127
|
+
|
|
128
|
+
Do NOT serialize these — they touch different files.
|
|
129
|
+
|
|
130
|
+
**Do NOT run intermediate verification between sub-tasks.** Complete all GREEN phase work, then run a single verification pass in Step 9.
|
|
131
|
+
|
|
132
|
+
**BLOCKING GATE — do not proceed until this passes:**
|
|
133
|
+
Run `pnpm test:unit` and paste the output. All tests must **PASS** (green).
|
|
134
|
+
|
|
135
|
+
### 8. Refactor
|
|
136
|
+
|
|
137
|
+
Clean up while keeping tests green.
|
|
138
|
+
|
|
139
|
+
### 9. Verify & Self-Check
|
|
140
|
+
|
|
141
|
+
Run all three **together** (single pass) and paste output:
|
|
142
|
+
```bash
|
|
143
|
+
pnpm test:coverage # Must meet thresholds: 95% statements/functions/lines, 90% branches
|
|
144
|
+
pnpm lint # Must pass with 0 warnings
|
|
145
|
+
pnpm typecheck # Must pass with 0 errors
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If issues are found, fix **all** of them, then run the full trio again once.
|
|
149
|
+
|
|
150
|
+
Before moving to the review gate, verify manually:
|
|
151
|
+
- [ ] No `any` types: `grep -r ": any" src/features/<feature>/`
|
|
152
|
+
- [ ] No `eslint-disable` comments
|
|
153
|
+
- [ ] All UI text in Spanish, all `it()`/`describe()` text in English
|
|
154
|
+
- [ ] No file over 200 lines
|
|
155
|
+
- [ ] No function over 20 lines
|
|
156
|
+
- [ ] AAA pattern (`// Arrange`, `// Act`, `// Assert`) in every test
|
|
157
|
+
- [ ] `ActionResult` returned from every Server Action mutation
|
|
158
|
+
- [ ] Toast feedback (`toast.success` / `toast.error`) for every mutation
|
|
159
|
+
- [ ] RLS policies written for every new table
|
|
160
|
+
|
|
161
|
+
### 10. Review Gate
|
|
162
|
+
|
|
163
|
+
Run @code-reviewer and @security-researcher **in parallel** on the changed files. Fix any findings before marking the feature complete.
|
|
164
|
+
|
|
165
|
+
This step is not optional. The feature is not done until both reviewers pass.
|
|
166
|
+
|
|
167
|
+
> **Note for time-critical work:** if the user explicitly says to skip the review gate, you may proceed — but flag the skipped step so it can be done as a follow-up.
|
|
168
|
+
|
|
169
|
+
### 11. Update Architecture Snapshot & MCP Memory
|
|
170
|
+
|
|
171
|
+
Update `.cursor/memory/architecture-snapshot.md`:
|
|
172
|
+
- Add new DB tables to the schema table
|
|
173
|
+
- Add new shadcn components to the installed list
|
|
174
|
+
- Add the new feature to the Existing Features table
|
|
175
|
+
- Add any new canonical pattern references that differ from existing ones
|
|
176
|
+
|
|
177
|
+
Then run `/memory sync` to persist all changes to MCP memory so future sessions load context efficiently.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Common Issues
|
|
182
|
+
|
|
183
|
+
| Problem | Cause | Fix |
|
|
184
|
+
|---------|-------|-----|
|
|
185
|
+
| MCP memory returns no results | Memory not synced yet | Run `/memory sync` first, then retry |
|
|
186
|
+
| Test passes without implementation (RED fails) | Test asserts on falsy/default values | Ensure the test expects a specific truthy result that only a real implementation can produce |
|
|
187
|
+
| `pnpm typecheck` fails on schema file | Schema imported in test without mock | Add the schema file to `coverage.exclude` in `vitest.config.ts` |
|
|
188
|
+
| Context exceeds 60% mid-build | Feature too large for one conversation | Stop, note the current step, start a new conversation referencing it |
|
|
189
|
+
| `lint-staged` blocks commit | ESLint warnings treated as errors | Fix all warnings; never use `eslint-disable` inline — fix the code |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Guardrails
|
|
194
|
+
- NEVER start implementation before the user approves the plan (Step 3)
|
|
195
|
+
- NEVER start implementation before the RED gate is confirmed with actual test output
|
|
196
|
+
- Coverage threshold: 95% statements/functions/lines, 90% branches
|
|
197
|
+
- Follow `features/* → shared/*` dependency direction
|
|
198
|
+
- RLS is mandatory for every new table — not a post-step
|
|
199
|
+
- Write lint-compliant code from the start — read the Strict Rules Reference before the first line of code
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: create-api-route
|
|
3
|
-
description: Create a new Next.js API route with validation, auth, and tests. Use when adding API endpoints to a feature.
|
|
3
|
+
description: Create a new Next.js API route with Zod validation, auth check, and TDD tests. Use when adding API endpoints to a feature. Triggers: 'create API route', 'add endpoint', 'new route handler', 'API endpoint'. NOT for: Server Actions (those go in features/*/actions/).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Create API Route Skill
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: discover-feature
|
|
3
|
+
description: Run the requirements discovery process for a new feature. Produces a functional issue in .requirements/<feature-name>.md. Use this in Conversation 1, then start a new conversation and run /build-feature. Triggers: 'new feature', 'define requirements', 'discover feature', 'I want to build'. NOT for: already-defined features (use /build-feature directly).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Discover Feature Skill
|
|
7
|
+
|
|
8
|
+
> **Invoke as:** `/discover-feature <feature-description>`
|
|
9
|
+
> Run in **Agent mode**. After this skill completes, **start a new conversation** before running `/build-feature`.
|
|
10
|
+
|
|
11
|
+
## IMPORTANT: Token Budget
|
|
12
|
+
|
|
13
|
+
This conversation is for requirements only. Do NOT start implementation here. When done, start a fresh conversation to keep the implementation context clean.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Process
|
|
18
|
+
|
|
19
|
+
### 1. Load Existing Features via MCP Memory
|
|
20
|
+
|
|
21
|
+
1. Read `package.json` to get the project name (`<project-name>`)
|
|
22
|
+
2. Call `search_memory` with `tags: ["project:<project-name>", "domain:features"]` to understand existing features and their relationships to the new request
|
|
23
|
+
3. **Fallback**: if memory service is unavailable, read `.cursor/memory/architecture-snapshot.md` → "Existing Features" section
|
|
24
|
+
|
|
25
|
+
### 2. Discovery Questions
|
|
26
|
+
|
|
27
|
+
Ask ALL of the following before writing anything. Cover at minimum questions 1–3 + any relevant ones from 4–8.
|
|
28
|
+
|
|
29
|
+
1. **Problem & audience** — "What problem does this solve? Who experiences it?"
|
|
30
|
+
2. **User flows** — "Walk me through the happy path. What happens on error?"
|
|
31
|
+
3. **Edge cases & constraints** — "What are the limits? What should NOT happen?"
|
|
32
|
+
4. **Field constraints** — "What are the length limits, allowed formats, required vs optional fields?"
|
|
33
|
+
5. **Volume & scale** — "How many records are expected? Do you need search or pagination?"
|
|
34
|
+
6. **File/upload specifics** — (if applicable) "What file types and size limits are allowed?"
|
|
35
|
+
7. **Privacy & access** — "Who can see this data? Is it per-user or shared?"
|
|
36
|
+
8. **Relationship to existing features** — (informed by MCP memory results) "Does this link to `<existing feature>`?"
|
|
37
|
+
9. **Confirm understanding** — Restate what you heard and ask for approval before writing
|
|
38
|
+
|
|
39
|
+
If the user says "just do it" without answering, document all assumptions explicitly in an `## Assumptions` section at the top of the spec.
|
|
40
|
+
|
|
41
|
+
Only after the user confirms your understanding should you produce the functional issue.
|
|
42
|
+
|
|
43
|
+
### 3. Write Functional Issue
|
|
44
|
+
|
|
45
|
+
Create `.requirements/<feature-name>.md` using this format:
|
|
46
|
+
|
|
47
|
+
```markdown
|
|
48
|
+
## Feature: [Feature Name]
|
|
49
|
+
|
|
50
|
+
### User Story
|
|
51
|
+
As a [user type], I want [goal] so that [reason].
|
|
52
|
+
|
|
53
|
+
### Acceptance Criteria
|
|
54
|
+
- [ ] AC1: When [user does X], they see [Y]
|
|
55
|
+
- [ ] AC2: When [error condition], user sees [message/state]
|
|
56
|
+
- [ ] AC3: [Edge case]: [expected outcome]
|
|
57
|
+
|
|
58
|
+
### Functional Test Cases
|
|
59
|
+
- [ ] TC1 (AC1): User does X → sees Y (happy path)
|
|
60
|
+
- [ ] TC2 (AC2): User triggers error → sees error message
|
|
61
|
+
- [ ] TC3 (AC3): Edge case behavior visible to user
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Rules for this format:**
|
|
65
|
+
- Acceptance criteria in plain functional language — no code, no implementation details
|
|
66
|
+
- Test cases describe what the **user sees**, not system internals
|
|
67
|
+
- Every acceptance criterion maps to at least one test case
|
|
68
|
+
- No mention of database tables, API calls, component names, or file paths
|
|
69
|
+
- Write requirements in the user's language; IDs (`AC1`, `TC1`) and technical terms stay in English
|
|
70
|
+
|
|
71
|
+
### 4. Store Requirement in MCP Memory
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
store_memory({
|
|
75
|
+
content: "Requirement: <feature-name> — <one-line summary of what the feature does and key acceptance criteria>",
|
|
76
|
+
metadata: {
|
|
77
|
+
type: "architecture",
|
|
78
|
+
tags: ["project:<project-name>", "domain:features", "category:requirement", "feature:<feature-name>", "status:pending-snapshot"]
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 5. Hand Off
|
|
84
|
+
|
|
85
|
+
Tell the user:
|
|
86
|
+
|
|
87
|
+
> Requirements written to `.requirements/<feature-name>.md`.
|
|
88
|
+
>
|
|
89
|
+
> **Next step**: Start a new conversation and run:
|
|
90
|
+
> ```
|
|
91
|
+
> /build-feature @.requirements/<feature-name>.md
|
|
92
|
+
> ```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Common Issues
|
|
97
|
+
|
|
98
|
+
| Problem | Cause | Fix |
|
|
99
|
+
|---------|-------|-----|
|
|
100
|
+
| User says "just do it" without answering | Wants to skip discovery | Document all assumptions in an `## Assumptions` section at the top of the spec |
|
|
101
|
+
| MCP memory unavailable | Service not running or not installed | Fall back to reading `.cursor/memory/architecture-snapshot.md` directly |
|
|
102
|
+
| Feature overlaps with existing one | Missed relationship check in Step 1 | Re-query MCP with `domain:features`, clarify scope with user before writing spec |
|
|
103
|
+
| User changes requirements mid-discovery | Evolving understanding | Update the spec before handing off; don't start `/build-feature` with stale requirements |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Guardrails
|
|
108
|
+
- Always ask questions before writing — never assume requirements
|
|
109
|
+
- Do NOT start any implementation in this conversation
|
|
110
|
+
- Document all assumptions explicitly if the user skips questions
|
|
111
|
+
- Hand off to `/build-feature` in a fresh conversation — never chain them in the same conversation
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory
|
|
3
|
+
description: Sync architecture-snapshot.md with MCP memory service and recall project knowledge semantically. Use when starting a new session, after completing a feature, or to search project context efficiently. Triggers: 'memory sync', 'memory recall', 'memory update', 'sync architecture', 'search project knowledge', 'what components are installed'.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Memory Skill
|
|
7
|
+
|
|
8
|
+
> **Invoke as:** `/memory sync`, `/memory recall "query"`, `/memory update`
|
|
9
|
+
|
|
10
|
+
## Preflight Check
|
|
11
|
+
|
|
12
|
+
Before running any subcommand, verify the memory service is running:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
retrieve_memory({ query: "test", n_results: 1 })
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If this fails, tell the user: "Memory service is unavailable. Run `pip install mcp-memory-service` and ensure the `memory` binary is in PATH (check `.cursor/mcp.json`)."
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## `/memory sync` — Snapshot → MCP
|
|
23
|
+
|
|
24
|
+
Parses `architecture-snapshot.md` into individual entries and stores each in MCP memory. Run this after scaffolding a new project or after `/memory update`.
|
|
25
|
+
|
|
26
|
+
### Steps
|
|
27
|
+
|
|
28
|
+
1. Read `package.json` — get `name` field as `<project-name>`
|
|
29
|
+
2. Read `.cursor/memory/architecture-snapshot.md`
|
|
30
|
+
3. For each section, parse into individual entries and call `store_memory`:
|
|
31
|
+
|
|
32
|
+
**Installed shadcn/ui Components** (one memory for the full list):
|
|
33
|
+
```
|
|
34
|
+
store_memory({
|
|
35
|
+
content: "Installed shadcn/ui components: button, card, input, label, spinner",
|
|
36
|
+
metadata: {
|
|
37
|
+
type: "architecture",
|
|
38
|
+
tags: ["project:<project-name>", "domain:ui", "category:components"]
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**DB Schema** (one memory per table row):
|
|
44
|
+
```
|
|
45
|
+
store_memory({
|
|
46
|
+
content: "DB table: profiles — columns: id (uuid PK), email (text unique), createdAt, updatedAt",
|
|
47
|
+
metadata: {
|
|
48
|
+
type: "architecture",
|
|
49
|
+
tags: ["project:<project-name>", "domain:database", "category:schema", "table:profiles"]
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Existing Features** (one memory per feature row):
|
|
55
|
+
```
|
|
56
|
+
store_memory({
|
|
57
|
+
content: "Feature: auth — path: src/features/auth/ — Login/logout, cookie-based sessions via Supabase",
|
|
58
|
+
metadata: {
|
|
59
|
+
type: "architecture",
|
|
60
|
+
tags: ["project:<project-name>", "domain:features", "category:feature", "feature:auth"]
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Canonical Pattern References** (one memory per pattern row):
|
|
66
|
+
```
|
|
67
|
+
store_memory({
|
|
68
|
+
content: "Canonical pattern: Server Action — file: src/features/todos/actions/todos.action.ts",
|
|
69
|
+
metadata: {
|
|
70
|
+
type: "architecture",
|
|
71
|
+
tags: ["project:<project-name>", "domain:patterns", "category:pattern", "pattern:server-action"]
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Key Rules** (one memory per bullet):
|
|
77
|
+
```
|
|
78
|
+
store_memory({
|
|
79
|
+
content: "Rule: Runtime queries use Supabase client only — Drizzle is schema/migrations only",
|
|
80
|
+
metadata: {
|
|
81
|
+
type: "architecture",
|
|
82
|
+
tags: ["project:<project-name>", "domain:rules", "category:rule"]
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Shared Utilities** (one memory per utility row):
|
|
88
|
+
```
|
|
89
|
+
store_memory({
|
|
90
|
+
content: "Utility: formFieldText(formData, key) — location: src/shared/lib/form-utils.ts — Safe FormData text extraction, avoids no-base-to-string lint error",
|
|
91
|
+
metadata: {
|
|
92
|
+
type: "architecture",
|
|
93
|
+
tags: ["project:<project-name>", "domain:shared", "category:utility"]
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Strict Rules Reference** (one memory per `###` sub-heading group):
|
|
99
|
+
```
|
|
100
|
+
store_memory({
|
|
101
|
+
content: "TypeScript strict rules: noUncheckedIndexedAccess (guard arr[i]), exactOptionalPropertyTypes (omit key instead of undefined), noImplicitReturns (explicit return in all branches), noUnusedLocals/noUnusedParameters (prefix unused with _), useUnknownInCatchVariables (narrow with instanceof Error)",
|
|
102
|
+
metadata: {
|
|
103
|
+
type: "architecture",
|
|
104
|
+
tags: ["project:<project-name>", "domain:rules", "category:lint-rule", "subcategory:typescript"]
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
4. After all entries are stored, call:
|
|
110
|
+
```
|
|
111
|
+
trigger_consolidation({ time_horizon: "daily", immediate: true })
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
5. Report: "Stored N memories for project `<project-name>`. Consolidation triggered."
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## `/memory recall "query"` — Semantic Search
|
|
119
|
+
|
|
120
|
+
Use to find project context without reading the full snapshot.
|
|
121
|
+
|
|
122
|
+
### Steps
|
|
123
|
+
|
|
124
|
+
1. Read `package.json` — get `<project-name>`
|
|
125
|
+
2. Call broad semantic search:
|
|
126
|
+
```
|
|
127
|
+
retrieve_memory({ query: "<user-query>", n_results: 10 })
|
|
128
|
+
```
|
|
129
|
+
3. If results are too broad, narrow with tags:
|
|
130
|
+
```
|
|
131
|
+
search_memory({
|
|
132
|
+
query: "<user-query>",
|
|
133
|
+
tags: ["project:<project-name>"],
|
|
134
|
+
limit: 5,
|
|
135
|
+
min_score: 0.6
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
4. Present results as a summary. If no results found, tell the user to run `/memory sync` first.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## `/memory update` — MCP → Snapshot
|
|
143
|
+
|
|
144
|
+
Merges new entries (tagged `status:pending-snapshot`) back into `architecture-snapshot.md`. Run after agents store new knowledge via `store_memory`.
|
|
145
|
+
|
|
146
|
+
### Steps
|
|
147
|
+
|
|
148
|
+
1. Read `package.json` — get `<project-name>`
|
|
149
|
+
2. Search for pending entries:
|
|
150
|
+
```
|
|
151
|
+
search_memory({
|
|
152
|
+
query: "new pending architecture update",
|
|
153
|
+
tags: ["project:<project-name>", "status:pending-snapshot"],
|
|
154
|
+
limit: 50
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
3. For each result, determine the target section from the `domain` and `category` tags:
|
|
158
|
+
- `domain:ui` → "Installed shadcn/ui Components"
|
|
159
|
+
- `domain:database` → "DB Schema"
|
|
160
|
+
- `domain:features` → "Existing Features"
|
|
161
|
+
- `domain:patterns` → "Canonical Pattern References"
|
|
162
|
+
- `domain:rules` + `category:rule` → "Key Rules"
|
|
163
|
+
- `domain:shared` → "Shared Utilities"
|
|
164
|
+
4. Read `.cursor/memory/architecture-snapshot.md` and merge new entries into the correct sections
|
|
165
|
+
5. Write the updated snapshot
|
|
166
|
+
6. Re-store each processed memory WITHOUT the `status:pending-snapshot` tag:
|
|
167
|
+
```
|
|
168
|
+
store_memory({
|
|
169
|
+
content: "<same content>",
|
|
170
|
+
metadata: {
|
|
171
|
+
type: "architecture",
|
|
172
|
+
tags: ["project:<project-name>", "domain:...", "category:..."]
|
|
173
|
+
// pending-snapshot tag removed
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
7. Call `trigger_consolidation({ time_horizon: "daily", immediate: true })`
|
|
178
|
+
8. Report: "Merged N entries into architecture-snapshot.md."
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Tag Schema Reference
|
|
183
|
+
|
|
184
|
+
All memories must include `type: "architecture"` and `project:<project-name>`. Use lowercase with hyphens for multi-word values.
|
|
185
|
+
|
|
186
|
+
| Snapshot Section | Required Tags | Optional Tags |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| shadcn Components | `domain:ui`, `category:components` | — |
|
|
189
|
+
| DB Schema | `domain:database`, `category:schema` | `table:<name>` |
|
|
190
|
+
| Existing Features | `domain:features`, `category:feature` | `feature:<name>` |
|
|
191
|
+
| Canonical Patterns | `domain:patterns`, `category:pattern` | `pattern:<type>` |
|
|
192
|
+
| Key Rules | `domain:rules`, `category:rule` | — |
|
|
193
|
+
| Shared Utilities | `domain:shared`, `category:utility` | — |
|
|
194
|
+
| Strict Rules (TS) | `domain:rules`, `category:lint-rule` | `subcategory:typescript` |
|
|
195
|
+
| Strict Rules (ESLint) | `domain:rules`, `category:lint-rule` | `subcategory:eslint` |
|
|
196
|
+
|
|
197
|
+
When storing **new** architecture knowledge (e.g., after `/build-feature`), add `status:pending-snapshot` so `/memory update` can sync it back.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Guardrails
|
|
202
|
+
|
|
203
|
+
- NEVER store secrets, API keys, `.env` values, or credentials in memory
|
|
204
|
+
- ALWAYS scope memories with `project:<project-name>` to prevent cross-project pollution
|
|
205
|
+
- ALWAYS use `type: "architecture"` for snapshot-derived memories
|
|
206
|
+
- Keep individual memory content under 300 words for effective semantic retrieval
|
|
207
|
+
- The snapshot file (`.cursor/memory/architecture-snapshot.md`) is the source of truth — MCP memory is a search index
|
|
208
|
+
- If the memory service is unavailable, agents fall back to reading the snapshot file directly
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review-branch
|
|
3
|
-
description: Review current branch changes against develop
|
|
3
|
+
description: Review current branch changes against develop — runs full code quality, testing, architecture, and security checklist. Triggers: 'review branch', 'review my changes', 'check branch quality', 'review PR'.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: security-audit
|
|
3
|
-
description: Run a security audit on the codebase
|
|
3
|
+
description: Run a full security audit on the codebase — checks OWASP Top 10, RLS policies, hardcoded secrets, auth coverage, input validation, XSS vectors, and security headers. Triggers: 'security audit', 'audit security', 'check vulnerabilities', 'scan for secrets', 'check RLS'.
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ grep -r "password\s*=" src/ --include="*.ts"
|
|
|
16
16
|
Check `.env.example` has no real values.
|
|
17
17
|
|
|
18
18
|
### 3. RLS Verification
|
|
19
|
-
For each table in `src/shared/db
|
|
19
|
+
For each table in `src/shared/db/*.schema.ts`:
|
|
20
20
|
- Confirm RLS is enabled in Supabase dashboard
|
|
21
21
|
- Confirm explicit policies exist
|
|
22
22
|
|
package/template/AGENTS.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# Agent Routing
|
|
2
|
+
|
|
3
|
+
Use the specialist agents in `.cursor/agents/` for focused tasks:
|
|
4
|
+
|
|
5
|
+
| Agent | Use when |
|
|
6
|
+
|-------|----------|
|
|
7
|
+
| `@technical-lead` | Default entry point — task breakdown, architecture decisions, orchestration |
|
|
8
|
+
| `@backend` | Server Actions, Drizzle schema, Supabase RLS, API routes, migrations |
|
|
9
|
+
| `@frontend` | React components, shadcn/ui, Tailwind, pages, form UI |
|
|
10
|
+
| `@test-qa` | TDD workflow, test writing, coverage gaps, mock setup |
|
|
11
|
+
| `@code-reviewer` | Branch/PR review — readonly, fast model |
|
|
12
|
+
| `@security-researcher` | Security audit, vulnerability check, auth review — readonly |
|
|
13
|
+
| `@business-intelligence` | Requirements discovery, user stories, acceptance criteria — readonly |
|
|
14
|
+
|
|
15
|
+
# Feature Development Workflow
|
|
16
|
+
|
|
17
|
+
**New feature** (2 conversations):
|
|
18
|
+
```
|
|
19
|
+
Conversation 1: /discover-feature <description> → writes .requirements/<name>.md
|
|
20
|
+
Conversation 2 (fresh): /build-feature @.requirements/<name>.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Bug fix:** `@test-qa` (reproduce) → `@backend`/`@frontend` (fix) → `@code-reviewer`
|
|
24
|
+
|
|
25
|
+
**Refactor:** `@technical-lead` (plan) → `@backend`/`@frontend` (implement) → `@test-qa` (verify) → `@code-reviewer`
|
|
26
|
+
|
|
27
|
+
**API endpoint only:** `/create-api-route` → `@code-reviewer`
|
|
28
|
+
|
|
1
29
|
<!-- BEGIN:nextjs-agent-rules -->
|
|
2
30
|
|
|
3
31
|
# Next.js: ALWAYS read docs before coding
|
|
@@ -23,7 +51,7 @@ Read `.env.example` for the full list. Key vars:
|
|
|
23
51
|
# Migrations
|
|
24
52
|
|
|
25
53
|
Migration files in `src/shared/db/migrations/` are auto-generated. NEVER create, edit, or delete them directly.
|
|
26
|
-
- Edit schema: `src/shared/db
|
|
54
|
+
- Edit schema: `src/shared/db/*.schema.ts` (one file per table)
|
|
27
55
|
- Generate migration: `pnpm db:generate`
|
|
28
56
|
- Apply migration: `pnpm db:migrate`
|
|
29
57
|
- Push schema (dev only): `pnpm db:push`
|
package/template/CLAUDE.md
CHANGED
|
@@ -19,25 +19,25 @@ Read these rules when working on related files:
|
|
|
19
19
|
|
|
20
20
|
This project uses specialist agents in `.claude/agents/`. Follow the technical-lead workflow:
|
|
21
21
|
|
|
22
|
-
- **New feature**:
|
|
22
|
+
- **New feature**: `/discover-feature` (Conversation 1) → `/build-feature` (Conversation 2, fresh)
|
|
23
23
|
- **Bug fix**: reproduce with failing test (`test-qa`) → fix (`backend`/`frontend`) → review (`code-reviewer`)
|
|
24
24
|
- **Refactor**: plan (`technical-lead`) → implement (`backend`/`frontend`) → verify (`test-qa`) → review (`code-reviewer`)
|
|
25
25
|
|
|
26
26
|
## Recommended: 2-Conversation Workflow for New Features
|
|
27
27
|
|
|
28
|
-
Split new feature work across two conversations to avoid context exhaustion
|
|
28
|
+
Split new feature work across two conversations to avoid context exhaustion:
|
|
29
29
|
|
|
30
|
-
**Conversation 1 — Requirements** (
|
|
30
|
+
**Conversation 1 — Requirements** (Agent mode)
|
|
31
31
|
```
|
|
32
|
-
|
|
32
|
+
/discover-feature <description> → discovery questions → writes .requirements/<name>.md
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
**Conversation 2 —
|
|
35
|
+
**Conversation 2 — Build** (Agent mode, fresh conversation)
|
|
36
36
|
```
|
|
37
|
-
/
|
|
37
|
+
/build-feature @.requirements/<name>.md → planning → TDD pipeline → review → memory sync
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
The `/
|
|
40
|
+
The `/build-feature` skill reads the requirements file directly and runs the full pipeline — tech-lead planning, TDD implementation (backend + frontend in parallel), review gate, and memory sync. This keeps each conversation well under 60% context usage.
|
|
41
41
|
|
|
42
42
|
# File Naming
|
|
43
43
|
|
|
@@ -56,4 +56,16 @@ If not installed automatically during scaffolding:
|
|
|
56
56
|
pip install mcp-memory-service
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
## Memory Skill
|
|
60
|
+
|
|
61
|
+
Use `/memory` to sync and query project knowledge:
|
|
62
|
+
|
|
63
|
+
- `/memory sync` — Parse `architecture-snapshot.md` and store each entry in MCP memory (run after scaffolding; `/build-feature` runs this automatically at the end of each feature)
|
|
64
|
+
- `/memory recall "query"` — Semantic search across stored memories (avoids reading the full snapshot)
|
|
65
|
+
- `/memory update` — Merge `status:pending-snapshot` memories back into the snapshot file
|
|
66
|
+
|
|
67
|
+
## How Agents Use Memory
|
|
68
|
+
|
|
69
|
+
All agents (`technical-lead`, `frontend`, `backend`, `business-intelligence`, `test-qa`) load context via targeted `search_memory` calls instead of reading the full snapshot. Each agent queries only the domains it needs, saving tokens. If the memory service is unavailable, agents fall back to reading `.cursor/memory/architecture-snapshot.md` directly.
|
|
70
|
+
|
|
59
71
|
# Maintenance Notes
|