macca-method 1.0.0 → 2.0.0

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 (56) hide show
  1. package/.agents/legacy-payloads.json +22 -0
  2. package/{skills-lock.json → .agents/macca-lock.json} +4 -2
  3. package/.agents/macca-managed-skills.txt +4 -2
  4. package/.agents/skills/_shared/references/additional-skills.md +30 -0
  5. package/.agents/skills/_shared/references/brainstorm-session.md +42 -11
  6. package/.agents/skills/_shared/references/config-mutation.md +25 -0
  7. package/.agents/skills/_shared/references/finding-format.md +25 -0
  8. package/.agents/skills/_shared/references/fix-mode.md +39 -0
  9. package/.agents/skills/_shared/references/human-loop.md +3 -1
  10. package/.agents/skills/_shared/references/implementation-principles.md +19 -0
  11. package/.agents/skills/_shared/references/invocation-policy.md +39 -0
  12. package/.agents/skills/_shared/references/language-config.md +15 -0
  13. package/.agents/skills/_shared/references/output-ownership.md +4 -2
  14. package/.agents/skills/_shared/references/runtime-config.md +7 -168
  15. package/.agents/skills/_shared/references/skill-catalog.md +34 -0
  16. package/.agents/skills/_shared/scripts/validate-skills.py +106 -4
  17. package/.agents/skills/add-feature/SKILL.md +10 -7
  18. package/.agents/skills/brainstorm-api/SKILL.md +49 -194
  19. package/.agents/skills/brainstorm-api/assets/api.template.md +147 -0
  20. package/.agents/skills/brainstorm-architecture/SKILL.md +22 -127
  21. package/.agents/skills/brainstorm-architecture/assets/architecture.template.md +135 -0
  22. package/.agents/skills/brainstorm-prd/SKILL.md +19 -102
  23. package/.agents/skills/brainstorm-prd/assets/PRD.template.md +106 -0
  24. package/.agents/skills/brainstorm-rules/SKILL.md +17 -151
  25. package/.agents/skills/brainstorm-rules/assets/rules.template.md +127 -0
  26. package/.agents/skills/brainstorm-schema/SKILL.md +49 -115
  27. package/.agents/skills/brainstorm-schema/assets/schema.template.md +109 -0
  28. package/.agents/skills/brainstorm-styleguide/SKILL.md +19 -134
  29. package/.agents/skills/brainstorm-styleguide/assets/StyleGuide.template.md +147 -0
  30. package/.agents/skills/brainstorm-task/SKILL.md +22 -107
  31. package/.agents/skills/brainstorm-task/assets/Task.template.md +113 -0
  32. package/.agents/skills/bug-fix/SKILL.md +45 -54
  33. package/.agents/skills/code-review/SKILL.md +26 -19
  34. package/.agents/skills/code-review/references/review-checklist.md +24 -26
  35. package/.agents/skills/developer/SKILL.md +25 -39
  36. package/.agents/skills/developer/references/close-phase.md +25 -0
  37. package/.agents/skills/developer/references/execute-task.md +69 -0
  38. package/.agents/skills/developer/references/onboarding.md +47 -0
  39. package/.agents/skills/help/SKILL.md +12 -13
  40. package/.agents/skills/meet/SKILL.md +168 -0
  41. package/.agents/skills/quick-dev/SKILL.md +209 -0
  42. package/.agents/skills/release-readiness/SKILL.md +149 -0
  43. package/.agents/skills/spec-audit/SKILL.md +37 -22
  44. package/.agents/skills/spec-compliance/SKILL.md +41 -40
  45. package/.agents/skills/spec-init/SKILL.md +29 -14
  46. package/README.md +253 -170
  47. package/bin/macca-method.js +785 -91
  48. package/flow.webp +0 -0
  49. package/image-macca-method.webp +0 -0
  50. package/package.json +13 -6
  51. package/scripts/run-skill-validator.js +24 -0
  52. package/scripts/test-install.js +398 -0
  53. package/scripts/test-upgrade-legacy.js +107 -0
  54. package/scripts/validate-skill-behavior.js +124 -0
  55. package/.agents/skills/developer/references/execution-workflow.md +0 -322
  56. package/.agents/skills/rapat/SKILL.md +0 -172
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  name: brainstorm-rules
3
- description: Interview users and generate `rules.md` (Coding Standards / Code Constitution). Use before coding to define coding rules and AI behavior guidance.
4
- persona: "Fachri"
5
- persona_role: "Tech Lead"
3
+ description: Interviews users and generates `rules.md` for coding, security, dependency, testing, AI behavior, and conditional operational conventions. Use only when the user explicitly requests repository-wide implementation rules.
4
+ compatibility: Requires the complete MACCA-METHOD collection with sibling _shared resources and workspace file access.
5
+ metadata:
6
+ persona: "Fachri"
7
+ persona-role: "Tech Lead"
6
8
  ---
7
9
 
8
10
  # Brainstorm Rules
@@ -43,11 +45,13 @@ This skill generates **rules.md**: a "code constitution" so AI works consistentl
43
45
  - `project-context/api.md` — auth contract, rate limiting, abuse controls
44
46
 
45
47
  3. **Shared Runtime Setup** — before the interview:
46
- - Read `../_shared/references/runtime-config.md`.
48
+ - Read `../_shared/references/language-config.md`.
49
+ - Read `../_shared/references/config-mutation.md`.
47
50
  - Read `../_shared/references/brainstorm-session.md`.
51
+ - Read `../_shared/references/scope-rules.md`.
48
52
  - Use `languagePreferences.communication.normalized` for chat.
49
53
  - Use `languagePreferences.documents.normalized` for the final `project-context/rules.md`.
50
- - Apply `brainstormPreferences.discussionMode` and `brainstormPreferences.recommendations` using the shared session policy.
54
+ - Apply `brainstormPreferences.discussionMode`, `recommendations`, and `discoveryDepth` using the shared session policy.
51
55
  - For this skill: announce that there are 7 topics, ask for pacing (one by one / three at once / all at once), and ask for recommendation preference if it is not already stored.
52
56
 
53
57
  4. Run the interview in the selected mode. Wait for the answer before continuing.
@@ -108,6 +112,11 @@ This skill generates **rules.md**: a "code constitution" so AI works consistentl
108
112
  - CORS: which origins are allowed?
109
113
  - Secret scanning: pre-commit hooks?
110
114
  - Align with decisions in `architecture.md`, `schema.md`, `api.md` — no contradictions.
115
+ - If architecture defines observability: structured log levels, correlation IDs, redaction, sampling, and forbidden sensitive fields
116
+ - If schema defines migrations: naming, compatibility, destructive-change approval, transaction/backfill, and validation conventions
117
+ - If architecture uses feature flags: naming, default/fail-safe value, owner, expiry/cleanup, and test matrix
118
+ - If generators are used: which generated files may be edited and how regeneration is validated
119
+ - If runtime credentials are managed: rotation and revocation expectations
111
120
 
112
121
  ### 5. AI Behavior Rules
113
122
  **Ask:** *"Are there special rules for AI? When should it ask first instead of assuming?"*
@@ -142,154 +151,11 @@ This skill generates **rules.md**: a "code constitution" so AI works consistentl
142
151
  - Minimum coverage percentage?
143
152
  - Test requirement: mandatory for every new feature?
144
153
 
145
- ## Output Format (rules.md)
154
+ ## rules.md Output
146
155
 
147
- ````markdown
148
- # Coding Standards (Rules)
156
+ After discovery is complete and immediately before generating `project-context/rules.md`, read `assets/rules.template.md`.
149
157
 
150
- ## Document Role
151
- - **Source of Truth:** Coding standards, AI behavior constraints, and implementation security rules
152
- - **Primary Owner:** `brainstorm-rules`
153
- - **Out of Scope:** Product scope decisions, schema design, endpoint payload contracts, and task sequencing
154
-
155
- ---
156
-
157
- ## 1. AI Persona & Tech Stack
158
- > You are an expert developer in: [TypeScript, React, Next.js 14 App Router, Prisma, PostgreSQL, TanStack Query, Zustand].
159
-
160
- **Prioritize:**
161
- - [Preferred patterns]
162
-
163
- **Avoid:**
164
- - [Patterns to avoid]
165
-
166
- ---
167
-
168
- ## 2. Naming Conventions
169
- | Type | Convention | Example |
170
- |------|------------|---------|
171
- | Variables & Functions | camelCase | `getUserData`, `isLoading` |
172
- | React Components | PascalCase | `UserCard`, `LoginForm` |
173
- | Files & Folders | kebab-case | `user-card.tsx`, `auth/` |
174
- | Global Constants | UPPER_CASE | `MAX_RETRIES`, `API_URL` |
175
- | Event Handlers | `handle` prefix | `handleSubmit`, `handleClick` |
176
- | Boolean | `is/has/can` prefix | `isLoading`, `hasError` |
177
- | Database Tables | snake_case, plural | `users`, `product_categories` |
178
-
179
- ---
180
-
181
- ## 3. Code Style & Quality
182
- - **TypeScript:** Strict mode enabled. Avoid `any` and `enum` (use `as const`).
183
- - **Console.log:** Forbidden in production. Use a proper logger.
184
- - **Error Handling:** `try-catch` required for async operations. Use early returns (guard clauses).
185
- - **Else after return:** FORBIDDEN — use the early return pattern.
186
- - **Import order:** builtin → external → internal → relative → types
187
- - **Max function length:** [X lines]
188
- - **Comments:** [JSDoc required / minimal]
189
- - **Dependency ladder:** Reuse existing code first, then standard library, native platform, installed dependencies, and only then add new dependencies.
190
- - **Intentional simplification:** Mark with a `tradeoff:` comment that states the ceiling and upgrade trigger.
191
- - **Never simplify:** trust-boundary validation, data-loss protection, accessibility basics, or explicitly requested behavior.
192
-
193
- ```typescript
194
- // ✅ CORRECT — early return
195
- function processUser(user: User | null) {
196
- if (!user) return null;
197
- if (!user.isActive) return null;
198
- return doSomething(user);
199
- }
200
-
201
- // ❌ WRONG — deep nesting
202
- function processUser(user: User | null) {
203
- if (user) {
204
- if (user.isActive) {
205
- return doSomething(user);
206
- }
207
- }
208
- }
209
- ```
210
-
211
- ---
212
-
213
- ## 4. Security Rules
214
- > **MANDATORY:** Before writing code involving user input, auth, file upload, or database access — check at least these 4 items and explain them briefly: input validation, secret/token protection, safe queries, and access control.
215
-
216
- - **Token Storage:** Store JWTs in **httpOnly cookies**, NOT localStorage.
217
- - **Input Sanitization:** Validate and sanitize all input before processing (use Zod/Joi).
218
- - **Environment Variables:** Never hardcode secrets. All env vars must exist in `.env.example`.
219
- - **Query Security:** Always use parameterized queries or an ORM. NEVER concatenate user input into SQL.
220
- - **XSS:** Avoid `dangerouslySetInnerHTML`. If required, sanitize with DOMPurify.
221
- - **CORS:** Approved origins: [origin list]. Never use `*` in production.
222
- - **Dependencies:** Run `npm audit` before every release. Block HIGH severity.
223
-
224
- ---
225
-
226
- ## 5. AI Behavior Rules
227
- - **Comment Language:** [Indonesian / English]
228
- - **Error Messages (user-facing):** [Indonesian / English]
229
- - **When Ambiguous:** Ask the user first; do not assume.
230
- - **When Errors Happen:** Analyze error logs first. Do not guess.
231
- - **New Package Installation:** Ask permission first; state the reason.
232
- - **Out-of-Scope Modifications:** Forbidden without confirmation.
233
- - **Complex Implementations:** Show a plan/rationale before implementing.
234
-
235
- ## Rule Priority
236
- - **Priority Order:** Security → correctness → data protection → consistency → maintainability → convenience
237
- - If two rules seem to conflict, choose the higher-priority rule and note the trade-off.
238
- - If a local exception is needed, mark it clearly with a `tradeoff:` comment and explain the upgrade trigger.
239
-
240
- ---
241
-
242
- ## 6. Git Workflow
243
- **Conventional Commits** — required for all commits.
244
-
245
- | Type | When |
246
- |------|------|
247
- | `feat:` | New feature |
248
- | `fix:` | Bug fix |
249
- | `chore:` | Maintenance (update deps, config) |
250
- | `docs:` | Documentation changes |
251
- | `refactor:` | Code restructuring without feature/bug change |
252
- | `style:` | Formatting (no logic changes) |
253
- | `test:` | Add or fix tests |
254
- | `perf:` | Performance improvement |
255
- | `ci:` | CI/CD config changes |
256
-
257
- **Example:** `feat(auth): add Google OAuth login`
258
-
259
- **Branch naming:**
260
- - `feature/[feature-name]`
261
- - `fix/[bug-name]`
262
- - `chore/[task-name]`
263
-
264
- ---
265
-
266
- ## 7. Linter, Formatter & Testing
267
- - **ESLint:** v9 (flat config — `eslint.config.js`). Rules: `eslint:recommended`, `@typescript-eslint/recommended`.
268
- - **Prettier:** `semi: false`, `singleQuote: true`, `tabWidth: 2`, `printWidth: 80`.
269
- - **.editorconfig:** `charset=utf-8`, `end_of_line=lf`, `insert_final_newline=true`.
270
- - **Test Framework:** [Jest / Vitest / Playwright]
271
- - **Minimum Coverage:** [X%]
272
- - **Test Requirement:** Yes — every new function/endpoint must have tests (TDD: write the test before implementation).
273
-
274
- ---
275
-
276
- ## [FORBIDDEN]
277
-
278
- > Check this list before writing any code. Violating even one item = code rejected.
279
-
280
- | # | Forbidden | Why |
281
- |---|-----------|-----|
282
- | F-01 | NEVER use `any` (TypeScript) | Destroys type safety |
283
- | F-02 | NEVER hardcode secrets, URLs, or config — use env vars | Security & portability |
284
- | F-03 | NEVER concatenate user input into SQL/query — use parameterized queries/ORM | SQL Injection |
285
- | F-04 | NEVER store tokens in localStorage — use httpOnly cookies | XSS vulnerability |
286
- | F-05 | NEVER use `console.log` / `print` in production code | Info leaks, noise |
287
- | [F-06+] | [Project-specific prohibition from topics 1–7] | [Reason] |
288
-
289
- ## Assumptions & Exceptions
290
- - [Assumption about team workflow or tooling]
291
- - [Temporary exception with owner / review trigger]
292
- ````
158
+ Adapt only sections that are applicable and preserve every required contract from the interview. Do not load the template during early discovery.
293
159
 
294
160
  ---
295
161
 
@@ -0,0 +1,127 @@
1
+ # Coding Standards (Rules)
2
+
3
+ ## Document Role
4
+ - **Source of Truth:** Coding standards, AI behavior constraints, and implementation security rules
5
+ - **Primary Owner:** `brainstorm-rules`
6
+ - **Out of Scope:** Product scope decisions, schema design, endpoint payload contracts, and task sequencing
7
+
8
+ ---
9
+
10
+ ## 1. AI Persona & Tech Stack
11
+ > You are an expert developer in: [stack confirmed by architecture and user].
12
+
13
+ **Prioritize:**
14
+ - [Preferred patterns]
15
+
16
+ **Avoid:**
17
+ - [Patterns to avoid]
18
+
19
+ ---
20
+
21
+ ## 2. Naming Conventions
22
+ | Type | Convention | Example |
23
+ |------|------------|---------|
24
+ | [Project symbol type] | [confirmed convention] | [stack-native example] |
25
+ | Files & Folders | [confirmed convention] | [example] |
26
+ | Persisted entities/fields | [datastore-native convention] | [example] |
27
+
28
+ ---
29
+
30
+ ## 3. Code Style & Quality
31
+ - **Language-specific rules:** [rules confirmed for the selected language; omit inapplicable TypeScript examples]
32
+ - **Production diagnostics:** [confirmed logging/telemetry rule]
33
+ - **Error Handling:** [stack-native strategy confirmed by the project]
34
+ - **Control flow:** [confirmed readability rule]
35
+ - **Import/dependency order:** [confirmed convention if applicable]
36
+ - **Max function length:** [X lines]
37
+ - **Comments:** [JSDoc required / minimal]
38
+ - **Dependency ladder:** Reuse existing code first, then standard library, native platform, installed dependencies, and only then add new dependencies.
39
+ - **Intentional simplification:** Mark with a `tradeoff:` comment that states the ceiling and upgrade trigger.
40
+ - **Never simplify:** trust-boundary validation, data-loss protection, accessibility basics, or explicitly requested behavior.
41
+
42
+ Add a language-specific example only when it communicates a confirmed rule better than prose.
43
+
44
+ ---
45
+
46
+ ## 4. Security Rules
47
+ > **MANDATORY:** Before writing code involving user input, auth, file upload, or database access — check at least these 4 items and explain them briefly: input validation, secret/token protection, safe queries, and access control.
48
+
49
+ - **Token/Session Storage:** [project-specific decision; do not assume JWT or browser cookies]
50
+ - **Input Validation:** Validate untrusted input with [existing project mechanism].
51
+ - **Secret/Configuration Storage:** [project/platform-specific mechanism]
52
+ - **Injection Prevention:** [safe query, shell, template, and parser rules relevant to this stack]
53
+ - **Client Rendering Security:** [XSS/content rule only if the project renders untrusted content]
54
+ - **Cross-Origin/Network Policy:** [only if the project exposes a network surface]
55
+ - **Dependencies:** Run the project's available dependency audit before release when network policy permits. Block [agreed threshold].
56
+
57
+ ### Conditional Operational Rules
58
+ - **Structured Logging:** [only when architecture defines observability]
59
+ - **Migration Conventions:** [only when schema evolution applies]
60
+ - **Feature Flag Lifecycle:** [only when architecture selects flags]
61
+ - **Generated Code:** [editable/regenerate policy when applicable]
62
+ - **Secret Rotation:** [when runtime credentials apply]
63
+
64
+ ---
65
+
66
+ ## 5. AI Behavior Rules
67
+ - **Comment Language:** [Indonesian / English]
68
+ - **Error Messages (user-facing):** [Indonesian / English]
69
+ - **When Ambiguous:** Ask the user first; do not assume.
70
+ - **When Errors Happen:** Analyze error logs first. Do not guess.
71
+ - **New Package Installation:** Ask permission first; state the reason.
72
+ - **Out-of-Scope Modifications:** Forbidden without confirmation.
73
+ - **Complex Implementations:** Show a plan/rationale before implementing.
74
+
75
+ ## Rule Priority
76
+ - **Priority Order:** Security → correctness → data protection → consistency → maintainability → convenience
77
+ - If two rules seem to conflict, choose the higher-priority rule and note the trade-off.
78
+ - If a local exception is needed, mark it clearly with a `tradeoff:` comment and explain the upgrade trigger.
79
+
80
+ ---
81
+
82
+ ## 6. Git Workflow
83
+ **Commit format:** [confirmed workflow; omit this table if Conventional Commits was not selected].
84
+
85
+ | Type | When |
86
+ |------|------|
87
+ | `feat:` | New feature |
88
+ | `fix:` | Bug fix |
89
+ | `chore:` | Maintenance (update deps, config) |
90
+ | `docs:` | Documentation changes |
91
+ | `refactor:` | Code restructuring without feature/bug change |
92
+ | `style:` | Formatting (no logic changes) |
93
+ | `test:` | Add or fix tests |
94
+ | `perf:` | Performance improvement |
95
+ | `ci:` | CI/CD config changes |
96
+
97
+ **Example:** `feat(auth): add Google OAuth login`
98
+
99
+ **Branch naming:**
100
+ - `feature/[feature-name]`
101
+ - `fix/[bug-name]`
102
+ - `chore/[task-name]`
103
+
104
+ ---
105
+
106
+ ## 7. Linter, Formatter & Testing
107
+ - **Linter:** [existing tool/version/config; omit if none].
108
+ - **Formatter:** [existing tool/options; omit if none].
109
+ - **Editor settings:** [existing settings; omit if none].
110
+ - **Test Framework:** [existing project framework]
111
+ - **Minimum Coverage:** [X%]
112
+ - **Test Requirement:** [project policy: test-first, test-with-change, or another explicit workflow].
113
+
114
+ ---
115
+
116
+ ## [FORBIDDEN]
117
+
118
+ > Check this list before writing any code. Violating even one item = code rejected.
119
+
120
+ | # | Forbidden | Why |
121
+ |---|-----------|-----|
122
+ | F-01 | Never hardcode or expose secrets | Security |
123
+ | F-02+ | [Confirmed stack/project-specific prohibition] | [Reason] |
124
+
125
+ ## Assumptions & Exceptions
126
+ - [Assumption about team workflow or tooling]
127
+ - [Temporary exception with owner / review trigger]
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  name: brainstorm-schema
3
- description: Interview users and generate `schema.md` (Data Model / Database Schema). Use after `architecture.md` is complete.
4
- persona: "Fachri"
5
- persona_role: "Tech Lead"
3
+ description: Interviews users and generates `schema.md` for relational, document, key-value, graph, event-store, or mixed persistence, including evolution and recovery. Use only when the user explicitly requests data-model design after architecture.
4
+ compatibility: Requires the complete MACCA-METHOD collection with sibling _shared resources and workspace file access.
5
+ metadata:
6
+ persona: "Fachri"
7
+ persona-role: "Tech Lead"
6
8
  ---
7
9
 
8
10
  # Brainstorm Schema
@@ -34,12 +36,13 @@ You are **@Fachri — Tech Lead**, a **Senior Database Architect** who designs e
34
36
 
35
37
  Before any interview:
36
38
 
37
- 1. Read `../_shared/references/runtime-config.md`.
38
- 2. Read `../_shared/references/brainstorm-session.md`.
39
- 3. Read `../_shared/references/scope-rules.md`.
39
+ 1. Read `../_shared/references/language-config.md`.
40
+ 2. Read `../_shared/references/config-mutation.md`.
41
+ 3. Read `../_shared/references/brainstorm-session.md`.
42
+ 4. Read `../_shared/references/scope-rules.md`.
40
43
  4. Use `languagePreferences.communication.normalized` for chat.
41
44
  5. Use `languagePreferences.documents.normalized` for the final `project-context/schema.md`.
42
- 6. Apply `brainstormPreferences.discussionMode` and `brainstormPreferences.recommendations` using the shared session policy.
45
+ 6. Apply `brainstormPreferences.discussionMode`, `recommendations`, and `discoveryDepth` using the shared session policy.
43
46
 
44
47
  ---
45
48
 
@@ -53,7 +56,7 @@ Before any interview:
53
56
 
54
57
  3. If `.agents/developer-config.json` exists and `developerPreferences.scope = "frontend"`, DO NOT create `schema.md`. Explain that database and schema work is outside the current scope, and that backend dependencies should be documented only through the `api.md` consumer contract.
55
58
 
56
- 4. Run the shared runtime setup above. For this skill, ask whether to cover the 5 global topics one by one or three at once, then apply the stored or chosen recommendation preference.
59
+ 4. Run the shared runtime setup above and apply all three pacing modes from the shared session policy. If preferences are saved, announce and proceed without another confirmation.
57
60
 
58
61
  5. Run the interview in the chosen mode. Wait for answers.
59
62
 
@@ -65,137 +68,68 @@ Before any interview:
65
68
 
66
69
  ## Interview Topics (5 Topics — All Required)
67
70
 
68
- Ask all five topics using the chosen pacing mode for global topics.
71
+ Ask all five topics using the chosen pacing mode. First classify the persistence model from `architecture.md` as relational, document, key-value, graph, event store, or mixed. Adapt terminology and output to that model.
69
72
 
70
73
  ### 1. Database Conventions
71
74
  *"Before tables, let's align on conventions. Any preferences?"*
72
75
 
73
76
  Collect:
74
- - **ID strategy:** UUID, auto-increment, CUID?
75
- - **Table naming:** plural snake_case (`users`, `products`) or singular?
76
- - **Audit fields:** Should all tables have `created_at`, `updated_at`? Set by app or DB trigger?
77
- - **Soft delete:** Use `deleted_at` (soft delete) or hard delete?
77
+ - **Identity strategy:** primary key, document ID, aggregate/stream ID, graph ID, or key format?
78
+ - **Naming:** datastore-native naming for tables, collections, keys, node labels, streams, and fields?
79
+ - **Audit/version metadata:** timestamps, version/revision, event metadata, or none?
80
+ - **Deletion/retention:** hard delete, soft delete, tombstone, archival, compaction, or immutable events?
78
81
  - **Timestamp:** UTC or local timezone?
79
82
  - **Retention:** How long is data stored? Any anonymization or archival schedule?
80
83
 
81
- ### 2. Table List
82
- *"What tables or collections are needed?"*
84
+ ### 2. Entity/Storage List
85
+ *"What tables, collections, aggregates, nodes, or stores are needed?"*
83
86
 
84
- Collect:
85
- - All table names
86
- - Short description of each table's purpose
87
- - Any junction/pivot tables for many-to-many relationships?
87
+ Collect by persistence model:
88
+ - **Relational:** tables and junction tables
89
+ - **Document:** collections, document roots, and embedded subdocuments
90
+ - **Key-value:** key spaces, key format, and value shape
91
+ - **Graph:** node labels, edge types, and key properties
92
+ - **Event store:** aggregates, stream names, event types, and projections
93
+ - **All modes:** purpose, ownership boundary, and source requirement for each structure
94
+ - **Multi-tenant systems only:** tenant key/boundary, isolation enforcement, cross-tenant constraints, export/deletion, and partition strategy
88
95
 
89
- ### 3. Columns & Data Types
90
- *"For each table, list the columns and data types."*
96
+ ### 3. Fields & Data Types
97
+ *"For each data structure, list fields and datastore-native data types."*
91
98
 
92
- Collect per table:
93
- - Column names and types (VARCHAR, INTEGER, UUID, TEXT, BOOLEAN, TIMESTAMP, DECIMAL, ENUM, JSONB)
94
- - Constraints (NOT NULL, UNIQUE, DEFAULT, PRIMARY KEY)
99
+ Collect per datastore-native structure:
100
+ - Field names and datastore-native types
101
+ - Validation/constraints appropriate to the selected model
95
102
  - Which columns contain sensitive data/PII?
96
103
  - For sensitive columns: hash, encrypt, mask, or plain text?
97
104
  - Any intentionally denormalized columns (intentionally duplicated)?
105
+ - Expected record/document/event volume, growth rate, payload size, and retention horizon where material
98
106
 
99
- ### 4. Relationships
100
- *"What relationships exist between the tables: one-to-one, one-to-many, many-to-many?"*
107
+ ### 4. Relationships and Data Placement
108
+ *"What relationships exist, and should related data use foreign keys, references, embedding, edges, or another datastore-native pattern?"*
101
109
 
102
110
  Collect:
103
- - Relationship type
104
- - Which table stores the foreign key?
105
- - Delete rules (CASCADE, SET NULL, RESTRICT)?
111
+ - **Relational:** cardinality, foreign-key owner, and cascade/set-null/restrict behavior
112
+ - **Document:** embedding vs references, document growth, and update atomicity
113
+ - **Key-value:** key composition, lookup direction, and secondary-index needs
114
+ - **Graph:** edge direction/cardinality and traversal boundaries
115
+ - **Event store:** aggregate boundaries, stream correlation, projection consistency, and event evolution
116
+ - **All modes:** delete/retention behavior and cross-structure consistency
117
+ - Concurrency model: transaction boundary, optimistic version, lock/contention policy, duplicate update protection, or equivalent
106
118
 
107
119
  ### 5. Indexes & Performance
108
- *"Which columns are often used in `WHERE`, `ORDER BY`, or `JOIN` clauses? What should be indexed?"*
120
+ *"Which access patterns, filters, sorts, traversals, stream reads, or lookups must be efficient? What datastore-native indexes or projections support them?"*
109
121
 
110
122
  Collect:
111
- - Columns used in WHERE/ORDER BY
112
- - Columns used in JOIN
113
- - Large tables that need composite indexes
114
-
115
- ## schema.md Output Format
116
-
117
- ````markdown
118
- # Database Schema
119
-
120
- ## Document Role
121
- - **Source of Truth:** Data model and persistence contract
122
- - **Primary Owner:** `brainstorm-schema`
123
- - **Out of Scope:** Endpoint behavior, UI rules, and code-level implementation details
124
-
125
- ## Global Conventions
126
- - **Database:** PostgreSQL / MySQL / MongoDB
127
- - **ID Strategy:** UUID / auto-increment
128
- - **Table Naming:** snake_case, plural
129
- - **Audit Fields:** `created_at`, `updated_at` in all tables, set by [app / DB trigger]
130
- - **Soft Delete:** Yes — `deleted_at` column / No — hard delete
131
- - **Timezone:** UTC
132
- - **Retention/Deletion:** [How long kept, when deleted, when anonymized/archived]
133
-
134
- ## Entity Map
135
- | Data ID | Table | Purpose | Trace to |
136
- |---------|-------|---------|----------|
137
- | DATA-01 | `[table_name]` | [short purpose] | `FEAT-01 / BR-01` |
138
- | DATA-02 | `[table_name_2]` | [short purpose] | `FEAT-01 / BR-02` |
139
-
140
- ---
141
-
142
- ## Table DATA-01: `[table_name]`
143
- > [Short description of the table purpose]
144
- > **Trace to:** [FEAT-01 / BR-01]
145
- > **PII:** Yes — contains personal data / No
146
- > **Data Protection:** [hash / encrypt / mask / none]
147
- > **Retention:** [How long it is stored / when archived or deleted]
148
-
149
- | Column | Type | Nullable | Default | Constraint | Notes |
150
- |--------|------|----------|---------|------------|-------|
151
- | id | UUID | No | gen_random_uuid() | PRIMARY KEY | |
152
- | [column] | [type] | [Yes/No] | [default] | [constraint] | [notes] |
153
- | created_at | TIMESTAMP | No | now() | | Auto-set |
154
- | updated_at | TIMESTAMP | No | now() | | Auto-update |
155
- | deleted_at | TIMESTAMP | Yes | null | | Soft delete |
156
-
157
- **Relationships:**
158
- - One-to-Many to `[other_table]` via `[foreign_key]` — on delete: CASCADE / SET NULL / RESTRICT
159
-
160
- **Indexes:**
161
- - `[column_name]` — used in WHERE/JOIN/ORDER BY
162
-
163
- ---
164
-
165
- ## Table DATA-02: `[table_name_2]`
166
- > [Description]
167
- > **Trace to:** [FEAT-01 / BR-02]
168
- > **PII:** Yes / No
169
-
170
- | Column | Type | Nullable | Default | Constraint | Notes |
171
- |--------|------|----------|---------|------------|-------|
172
- | id | UUID | No | gen_random_uuid() | PRIMARY KEY | |
173
-
174
- **Relationships:**
175
- - Many-to-One to `[other_table]` via `[foreign_key]`
176
-
177
- **Indexes:**
178
- - `[foreign_key]` — standard FK index
179
-
180
- ---
181
-
182
- ## Intentional Denormalization
183
- | Table | Denormalized Column | Reason |
184
- |-------|---------------------|--------|
185
- | [table] | [column] | [Why duplicated — for example order history] |
123
+ - Required reads/writes and expected scale
124
+ - Datastore-native indexes, projections, partitioning, traversal, or caching needed for those access patterns
125
+ - Consistency and latency expectations that constrain the design
126
+ - Schema evolution: backward/forward compatibility, migration order, backfill, validation, rollback/roll-forward, and zero-downtime constraints when migrations apply
186
127
 
187
- ## Data Protection & Retention
188
- | Table/Column | Category | Protection | Retention | Notes |
189
- |--------------|----------|------------|-----------|-------|
190
- | [users.email] | PII | [encrypt/mask/plain] | [retention rule] | [notes] |
128
+ ## schema.md Output
191
129
 
192
- ## Not Yet Modeled / Deferred
193
- - [Data area intentionally not yet modeled]
130
+ After discovery is complete and immediately before generating `project-context/schema.md`, read `assets/schema.template.md`.
194
131
 
195
- ## Assumptions & Open Questions
196
- - [Assumption about tables, relationships, or data rules]
197
- - [Question that needs user confirmation]
198
- ````
132
+ Adapt only sections that are applicable and preserve every required contract from the interview. Do not load the template during early discovery.
199
133
 
200
134
  ## After schema.md Is Created
201
135
 
@@ -0,0 +1,109 @@
1
+ # Database Schema
2
+
3
+ ## Document Role
4
+ - **Source of Truth:** Data model and persistence contract
5
+ - **Primary Owner:** `brainstorm-schema`
6
+ - **Out of Scope:** Endpoint behavior, UI rules, and code-level implementation details
7
+
8
+ ## Persistence Profile
9
+ - **Model:** Relational / Document / Key-value / Graph / Event store / Mixed
10
+ - **Identity Strategy:** [UUID / key format / aggregate ID / stream ID]
11
+ - **Naming:** [datastore-native naming rules]
12
+ - **Audit / Version Metadata:** [timestamps/version/event metadata]
13
+ - **Deletion / Retention:** [soft delete / archival / tombstone / immutable event / retention policy]
14
+ - **Timezone:** [UTC/local/N/A]
15
+
16
+ ## Entity / Storage Map
17
+ | Data ID | Structure | Type | Purpose | Trace to |
18
+ |---------|-----------|------|---------|----------|
19
+ | DATA-01 | `[name]` | Table / Collection / Key Space / Node / Stream / Aggregate | [purpose] | `FEAT-01 / BR-01` |
20
+
21
+ ## Global Data Protection
22
+ | Structure/Field | Category | Protection | Retention | Notes |
23
+ |-----------------|----------|------------|-----------|-------|
24
+ | [users.email] | PII | [encrypt/mask/plain] | [retention rule] | [notes] |
25
+
26
+ ## Scale, Tenancy & Concurrency
27
+ - **Expected Scale/Growth:** [records, payload, growth]
28
+ - **Tenant Isolation:** [N/A or enforcement model]
29
+ - **Concurrency Strategy:** [transaction/version/lock/idempotency]
30
+
31
+ ## Schema Evolution & Migration
32
+ - **Compatibility:** [backward/forward policy]
33
+ - **Migration Order:** [expand/backfill/switch/contract or equivalent]
34
+ - **Backfill & Validation:** [strategy]
35
+ - **Failure Recovery:** [rollback or roll-forward]
36
+ - **Zero-Downtime Constraint:** [if applicable]
37
+
38
+ ---
39
+
40
+ ## Relational Section (include only for relational or mixed)
41
+
42
+ ### Table DATA-01: `[table_name]`
43
+ > **Trace to:** [FEAT-01 / BR-01]
44
+ > **PII:** Yes / No
45
+ > **Retention:** [policy]
46
+
47
+ | Column | Type | Nullable | Default | Constraint | Notes |
48
+ |--------|------|----------|---------|------------|-------|
49
+ | id | UUID | No | gen_random_uuid() | PRIMARY KEY | |
50
+ | [column] | [type] | [Yes/No] | [default] | [constraint] | [notes] |
51
+
52
+ **Relationships:**
53
+ - [One-to-many / many-to-many / delete rule]
54
+
55
+ **Indexes:**
56
+ - [column/index purpose]
57
+
58
+ ---
59
+
60
+ ## Document Section (include only for document or mixed)
61
+
62
+ ### Collection DATA-01: `[collection_name]`
63
+ > **Trace to:** [FEAT-01 / BR-01]
64
+
65
+ - **Root Document Shape:** [summary]
66
+ - **Embedded vs Referenced Data:** [rule]
67
+ - **Validation:** [required/optional fields]
68
+ - **Indexes:** [fields and reason]
69
+
70
+ ---
71
+
72
+ ## Key-Value Section (include only for key-value or mixed)
73
+
74
+ ### Key Space DATA-01: `[keyspace_name]`
75
+ > **Trace to:** [FEAT-01 / BR-01]
76
+
77
+ - **Key Format:** [pattern]
78
+ - **Value Shape:** [summary]
79
+ - **Secondary Lookup / Cache Rule:** [if any]
80
+
81
+ ---
82
+
83
+ ## Graph Section (include only for graph or mixed)
84
+
85
+ ### Node / Edge DATA-01: `[node_or_edge_name]`
86
+ > **Trace to:** [FEAT-01 / BR-01]
87
+
88
+ - **Node/Edge Type:** [type]
89
+ - **Properties:** [summary]
90
+ - **Traversal / Cardinality Rules:** [rules]
91
+
92
+ ---
93
+
94
+ ## Event Store Section (include only for event-store or mixed)
95
+
96
+ ### Aggregate / Stream DATA-01: `[stream_name]`
97
+ > **Trace to:** [FEAT-01 / BR-01]
98
+
99
+ - **Aggregate Boundary:** [summary]
100
+ - **Event Types:** [list]
101
+ - **Projection / Read Model:** [summary]
102
+ - **Ordering / Versioning:** [rules]
103
+
104
+ ## Not Yet Modeled / Deferred
105
+ - [Data area intentionally not yet modeled]
106
+
107
+ ## Assumptions & Open Questions
108
+ - [Assumption about structures, relationships, or data rules]
109
+ - [Question that needs user confirmation]