magic-spec 1.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.
@@ -0,0 +1,276 @@
1
+ ---
2
+ description: Workflow for collecting SDD usage statistics and generating improvement recommendations.
3
+ ---
4
+
5
+ # Retrospective Workflow
6
+
7
+ Analyzes the usage history of the Magic SDD system and generates actionable recommendations for improving workflows, templates, and checklists. This is the system's **feedback loop** — it looks backward so the engine can move forward.
8
+
9
+ > **Scope**: SDD self-diagnosis only. Does not modify specs, plans, or tasks.
10
+ > Outputs observations and recommendations to `.design/RETROSPECTIVE.md`.
11
+
12
+ ## Two-Level System
13
+
14
+ The retrospective operates on two levels to balance thoroughness with efficiency:
15
+
16
+ | Level | Name | Trigger | Context Cost | Output |
17
+ | :--- | :--- | :--- | :--- | :--- |
18
+ | **Level 1** | Auto-snapshot | Automatic after phase completion | Minimal (~10s) | One row in Snapshots table |
19
+ | **Level 2** | Full retrospective | Manual or auto after entire plan completes | Moderate (~2–5 min) | Full analysis + recommendations |
20
+
21
+ **Level 1 — Auto-snapshot** collects numbers silently. No analysis, no recommendations, no user interruption. It creates a trail of metrics for trend analysis.
22
+
23
+ **Level 2 — Full retrospective** performs deep analysis, cross-referencing, and generates actionable recommendations. It uses snapshot history for trend comparison.
24
+
25
+ ## Agent Guidelines
26
+
27
+ **CRITICAL INSTRUCTIONS FOR AI:**
28
+
29
+ 1. **Read-Only Analysis**: This workflow reads `.design/` artifacts to gather data. It does NOT modify specs, plans, tasks, or RULES.md. The only file it writes to is `.design/RETROSPECTIVE.md`.
30
+ 2. **Auto-Init**: If `.design/` or its system files are missing, automatically trigger the Init pre-flight check (`.magic/init.md`) before proceeding.
31
+ 3. **Evidence-Based**: Every observation must reference a specific file, date, or event. No speculative claims.
32
+ 4. **Actionable Output**: Every recommendation must be concrete and implementable (e.g., "Remove checklist item X" or "Add example Y to specification.md"). Abstract advice ("improve quality") is forbidden.
33
+ 5. **Lightweight Execution**: This workflow must not consume excessive context. Read file headers and Document History tables — do not re-read entire spec bodies unless investigating a specific issue.
34
+ 6. **No Self-Modification**: This workflow recommends changes to `.magic/` files — it does not apply them. Changes to the SDD engine require explicit user approval and manual editing.
35
+ 7. **Level Awareness**: Always know which level you are executing. Level 1 (auto-snapshot) is silent and fast — no analysis, no recommendations. Level 2 (full) is thorough and interactive.
36
+ 8. **Documentation Sync**: When a recommendation is accepted and a `.magic/` workflow file is modified, you MUST also update `.magic/README.md` and `.magic/README.ru.md` to reflect the change. Documentation must always stay in sync with the engine.
37
+
38
+ ## Directory Structure
39
+
40
+ ```plaintext
41
+ .design/
42
+ ├── INDEX.md # Input: spec registry (status history)
43
+ ├── RULES.md # Input: constitution (rule additions over time)
44
+ ├── PLAN.md # Input: phase completion data
45
+ ├── RETROSPECTIVE.md # Output: observations and recommendations
46
+ ├── specifications/ # Input: spec files (version history)
47
+ │ └── *.md
48
+ └── tasks/ # Input: task execution data
49
+ ├── TASKS.md
50
+ └── phase-*.md
51
+ ```
52
+
53
+ ## Metrics Collected
54
+
55
+ The retrospective analyzes the following metric categories:
56
+
57
+ ### 📊 Workflow Efficiency
58
+
59
+ | Metric | Source | What It Reveals |
60
+ | :--- | :--- | :--- |
61
+ | Spec status transitions | INDEX.md, spec Document History | How many specs go Draft → Stable without regression to Draft |
62
+ | Average spec revisions before Stable | Spec Document History tables | Quality of initial spec authoring |
63
+ | Plan revision count | PLAN.md Document History | Stability of the planning phase |
64
+
65
+ ### 🎯 Dispatch Accuracy
66
+
67
+ | Metric | Source | What It Reveals |
68
+ | :--- | :--- | :--- |
69
+ | Number of spec files created | INDEX.md row count | Growth rate of the specification base |
70
+ | Orphaned specs (in INDEX.md but not in PLAN.md) | Cross-reference INDEX.md ↔ PLAN.md | Missed planning for existing specs |
71
+ | Specs referenced in PLAN.md but missing from INDEX.md | Cross-reference PLAN.md ↔ INDEX.md | Phantom specs in the plan |
72
+
73
+ ### ⚡ Task Execution Health
74
+
75
+ | Metric | Source | What It Reveals |
76
+ | :--- | :--- | :--- |
77
+ | Tasks completed per phase | TASKS.md summary table | Execution velocity |
78
+ | Blocked task frequency | TASKS.md + phase files | Quality of dependency planning |
79
+ | Common blocking reasons | Phase file Notes fields | Recurring bottlenecks |
80
+ | Tasks per spec (average) | TASKS.md task-to-spec mapping | Granularity of task decomposition |
81
+
82
+ ### 📜 Constitution Health
83
+
84
+ | Metric | Source | What It Reveals |
85
+ | :--- | :--- | :--- |
86
+ | RULES.md §7 entry count | RULES.md | Convention accumulation rate |
87
+ | Rules added via T1–T3 vs T4 | RULES.md Document History | How rules are actually captured (auto vs explicit) |
88
+ | Rule amendments / removals | RULES.md Document History | Constitution stability |
89
+
90
+ ### ✅ Checklist Effectiveness
91
+
92
+ | Metric | Source | What It Reveals |
93
+ | :--- | :--- | :--- |
94
+ | Checklist items that have never failed (always ✓) | Agent session history | Candidates for removal (zero signal) |
95
+ | Checklist items that frequently fail (✗) | Agent session history | Systematic weaknesses in the workflow |
96
+
97
+ ## Workflow Steps
98
+
99
+ ### Level 1: Auto-Snapshot
100
+
101
+ **Trigger**: Automatic — called by `task.md` when a phase completes (all tasks `Done`).
102
+
103
+ The agent does NOT ask the user for permission — it runs silently as part of the phase completion flow.
104
+
105
+ ```mermaid
106
+ graph TD
107
+ A["Phase complete (all tasks Done)"] --> B[Read INDEX.md — count specs by status]
108
+ B --> C[Read TASKS.md — count Done/Blocked per phase]
109
+ C --> D[Read RULES.md — count §7 entries]
110
+ D --> E[Calculate signal: 🟢 / 🟡 / 🔴]
111
+ E --> F{RETROSPECTIVE.md exists?}
112
+ F -->|Yes| G[Append row to Snapshots table]
113
+ F -->|No| H[Create RETROSPECTIVE.md with Snapshots table]
114
+ G & H --> I[Continue working — no user interruption]
115
+ ```
116
+
117
+ **Steps:**
118
+
119
+ 1. **Read INDEX.md**: Count specs by status (Draft / RFC / Stable).
120
+ 2. **Read TASKS.md**: Extract Done and Blocked counts for the completed phase.
121
+ 3. **Read RULES.md**: Count §7 entries.
122
+ 4. **Calculate signal**:
123
+ - 🟢 — 0 Blocked tasks, no orphaned specs
124
+ - 🟡 — ≤20% tasks Blocked, or minor mismatches
125
+ - 🔴 — >20% tasks Blocked, or critical mismatches
126
+ 5. **Append row** to the `## Snapshots` table in `RETROSPECTIVE.md`.
127
+
128
+ **Snapshot row format:**
129
+
130
+ ```markdown
131
+ | {YYYY-MM-DD} | Phase {N} | {D}/{R}/{S} | {Done}/{Blocked} | {count} | {🟢/🟡/🔴} |
132
+ ```
133
+
134
+ Where `D/R/S` = Draft/RFC/Stable spec counts.
135
+
136
+ ---
137
+
138
+ ### Level 2: Full Retrospective
139
+
140
+ **Trigger phrase**: *"Run retrospective"*, *"Analyze SDD"*, *"SDD health check"*
141
+
142
+ **Auto-trigger**: Runs automatically when the **entire plan** is complete (all phases, all tasks `Done`). This is the only case where a full retrospective runs without a manual command.
143
+
144
+ ```mermaid
145
+ graph TD
146
+ A[Trigger: Run Retrospective] --> B[Read INDEX.md]
147
+ B --> C[Read RULES.md Document History]
148
+ C --> D[Read PLAN.md phases + completion]
149
+ D --> E[Read TASKS.md summary table]
150
+ E --> F[Scan spec Document History tables]
151
+ F --> G[Cross-reference: INDEX ↔ PLAN ↔ TASKS]
152
+ G --> H[Compile observations]
153
+ H --> I[Generate recommendations]
154
+ I --> J[Assign severity: 🔴 Critical / 🟡 Medium / 🟢 Low / ✨ Positive]
155
+ J --> K[Read Snapshots table for trend analysis]
156
+ K --> L{RETROSPECTIVE.md exists?}
157
+ L -->|Yes| M[Append new session]
158
+ L -->|No| N[Create RETROSPECTIVE.md]
159
+ M & N --> O[Present report to user]
160
+ ```
161
+
162
+ **Steps:**
163
+
164
+ 1. **Read INDEX.md**: Count specs, note statuses, identify any without a status or version.
165
+ 2. **Read RULES.md**: Count §7 entries, scan Document History for rule additions/amendments/removals.
166
+ 3. **Read PLAN.md**: Check phase completion markers, count phases, identify unassigned specs.
167
+ 4. **Read TASKS.md**: Extract summary table (Total/Todo/In Progress/Done/Blocked per phase).
168
+ 5. **Scan spec files**: For each spec in `.design/specifications/`, read only the Document History table. Count version bumps, status transitions, and regressions (RFC → Draft).
169
+ 6. **Cross-reference**: Compare INDEX.md entries against PLAN.md spec references and TASKS.md task-to-spec mappings. Flag mismatches.
170
+ 7. **Compile observations**: Build a list of factual findings with severity:
171
+ - 🔴 **Critical** — broken references, missing files, contradictions
172
+ - 🟡 **Medium** — inefficiencies, recurring patterns worth addressing
173
+ - 🟢 **Low** — minor improvements, cosmetic suggestions
174
+ - ✨ **Positive** — things working well (reinforcement matters too)
175
+ 8. **Generate recommendations**: For each non-positive observation, propose a specific action.
176
+ 9. **Analyze trends**: Compare current metrics against the Snapshots table. Calculate deltas.
177
+ 10. **Write RETROSPECTIVE.md**: Append a new session entry (never overwrite previous sessions).
178
+ 11. **Present report**: Show the user the full session output.
179
+
180
+ ### Trigger Summary
181
+
182
+ | Trigger | Level | Behaviour |
183
+ | :--- | :--- | :--- |
184
+ | Phase completed (all tasks Done) | **Level 1** | Auto-snapshot: silent, no interruption |
185
+ | Entire plan completed (all phases Done) | **Level 2** | Full retro: auto-runs, presents report |
186
+ | Every 5th spec update | — | Suggests: *"Run retrospective?"* |
187
+ | Plan minor version bump | — | Suggests: *"Run retrospective?"* |
188
+ | Manual command | **Level 2** | Full retro: runs on demand |
189
+
190
+ ### Task Completion Checklist
191
+
192
+ ```
193
+ Retrospective Checklist — {date}
194
+
195
+ Data Integrity
196
+ ☐ INDEX.md was read and all entries counted
197
+ ☐ RULES.md Document History was scanned
198
+ ☐ PLAN.md phases and completion markers were checked
199
+ ☐ TASKS.md summary table was extracted
200
+ ☐ All spec Document History tables were scanned (headers only)
201
+
202
+ Analysis Quality
203
+ ☐ Every observation references a specific file or data point
204
+ ☐ Every recommendation is actionable (not abstract)
205
+ ☐ Severity assigned to all observations
206
+ ☐ Cross-reference check performed (INDEX ↔ PLAN ↔ TASKS)
207
+
208
+ Output
209
+ ☐ RETROSPECTIVE.md updated (appended, not overwritten)
210
+ ☐ Previous sessions preserved
211
+ ☐ Report presented to user
212
+ ```
213
+
214
+ ## Templates
215
+
216
+ ### RETROSPECTIVE.md Template
217
+
218
+ ```markdown
219
+ # SDD Retrospective
220
+
221
+ **Last Full Run:** {YYYY-MM-DD}
222
+ **Full Sessions:** {N}
223
+ **Snapshots:** {N}
224
+
225
+ ## Snapshots
226
+
227
+ Auto-collected after each phase completion. Lightweight metrics only — no analysis.
228
+
229
+ | Date | Phase | Specs (D/R/S) | Tasks (Done/Blocked) | Rules | Signal |
230
+ | :--- | :--- | :--- | :--- | :--- | :--- |
231
+ | 2026-02-20 | Phase 1 | 2/1/4 | 8/0 | 12 | 🟢 |
232
+ | 2026-02-25 | Phase 2 | 0/0/7 | 5/3 | 14 | 🟡 |
233
+
234
+ ---
235
+
236
+ ## Session {N} — {YYYY-MM-DD}
237
+
238
+ **Scope:** Full system analysis
239
+ **Specs in registry:** {count}
240
+ **Tasks total:** {count} (Done: {count}, Blocked: {count})
241
+ **RULES.md §7 entries:** {count}
242
+
243
+ ### 📊 Observations
244
+
245
+ | # | Severity | Area | Observation | Evidence |
246
+ | :--- | :--- | :--- | :--- | :--- |
247
+ | 1 | 🔴 Critical | Tasks | 3 of 8 Phase 2 tasks were Blocked | TASKS.md Phase 2 summary |
248
+ | 2 | 🟡 Medium | Specs | architecture.md went RFC → Draft → RFC → Stable (3 transitions) | architecture.md Document History |
249
+ | 3 | 🟡 Medium | Rules | All 4 rules in §7 were added via T4 (explicit). T1–T3 never triggered. | RULES.md Document History |
250
+ | 4 | 🟢 Low | Checklists | "No code in specs" has never failed in 8 checks | Session history |
251
+ | 5 | ✨ Positive | Plan | Phase 1 completed with 0 Blocked tasks | TASKS.md Phase 1 summary |
252
+ | 6 | ✨ Positive | Specs | 6 of 8 specs reached Stable without regression | INDEX.md |
253
+
254
+ ### 💡 Recommendations
255
+
256
+ | # | Refs Observation | Recommendation | Target File |
257
+ | :--- | :--- | :--- | :--- |
258
+ | R1 | #1 | Review dependency graph in PLAN.md — Phase 2 blocking rate suggests wrong task ordering | `.magic/plan.md` |
259
+ | R2 | #2 | Add "definition of done" criteria to spec template to reduce Draft ↔ RFC oscillation | `.magic/specification.md` |
260
+ | R3 | #3 | Consider simplifying T1–T3 triggers or adding examples to make them more discoverable | `.magic/specification.md` |
261
+ | R4 | #4 | Remove "No code in specs" from checklist — zero-signal item consuming agent context | `.magic/specification.md` |
262
+
263
+ ### 📈 Trends (from Snapshots)
264
+
265
+ | Metric | Previous Snapshot | Current | Δ |
266
+ | :--- | :--- | :--- | :--- |
267
+ | Specs in registry | {N} | {N} | +{N} |
268
+ | Blocked task rate | {N}% | {N}% | {±N}% |
269
+ | Signal | 🟢 | 🟡 | ↓ |
270
+
271
+ ---
272
+
273
+ ## Session {N-1} — {YYYY-MM-DD}
274
+
275
+ <!-- Previous session preserved here -->
276
+ ```
package/.magic/rule.md ADDED
@@ -0,0 +1,96 @@
1
+ ---
2
+ description: Workflow for manually adding, amending, or removing project conventions in RULES.md.
3
+ ---
4
+
5
+ # Rule Workflow
6
+
7
+ Manages `.design/RULES.md §7 Project Conventions` directly.
8
+ Use when you want to declare a convention without going through the Spec Workflow.
9
+
10
+ > Automatic rule capture during spec work (triggers T1–T4) is handled by `specification.md`.
11
+ > This workflow is for explicit, standalone rule management.
12
+
13
+ ## Agent Guidelines
14
+
15
+ 1. **Read First**: Always read `.design/RULES.md` in full before any operation.
16
+ 2. **Auto-Init**: If `.design/` or `RULES.md` is missing, automatically trigger the Init pre-flight check (`.magic/init.md`) before proceeding.
17
+ 3. **Scope**: Only §7 Project Conventions is modified here. Sections 1–6 are the universal constitution — amend them only if the user explicitly targets them.
18
+ 4. **No Silent Changes**: Always show the proposed change before writing.
19
+ 5. **Version Discipline**: Every change to RULES.md requires a version bump and a Document History row.
20
+
21
+ ## Workflow Steps
22
+
23
+ ### Adding a Convention
24
+
25
+ **Trigger phrase**: *"Add rule"*, *"Add convention"*
26
+
27
+ 1. Read `.design/RULES.md`.
28
+ 2. Parse the user's input into a clean, declarative rule statement.
29
+ 3. Propose before writing:
30
+
31
+ ```
32
+ Proposed addition to RULES.md §7:
33
+
34
+ → "All async functions must be documented with their error surface."
35
+
36
+ Version bump: 1.0.0 → 1.1.0 (minor — new convention added)
37
+
38
+ Add? (yes / adjust / cancel)
39
+ ```
40
+
41
+ 4. On approval: append to §7, bump version (`minor`), add Document History row.
42
+
43
+ ### Amending a Convention
44
+
45
+ **Trigger phrase**: *"Amend rule"*, *"Change rule"*, *"Update convention"*
46
+
47
+ 1. Read `.design/RULES.md §7`.
48
+ 2. Show the current rule and the proposed change side by side:
49
+
50
+ ```
51
+ Current: "All APIs must follow REST. GraphQL is not permitted."
52
+ Proposed: "All APIs must follow REST or GraphQL. No mixing within one service."
53
+
54
+ Version bump: 1.1.0 → 1.2.0 (minor — convention amended)
55
+
56
+ Apply? (yes / adjust / cancel)
57
+ ```
58
+
59
+ 3. On approval: replace the rule in place, bump version (`minor`), add Document History row.
60
+
61
+ ### Removing a Convention
62
+
63
+ **Trigger phrase**: *"Remove rule"*, *"Delete convention"*
64
+
65
+ 1. Show the rule to be removed and ask for explicit confirmation:
66
+
67
+ ```
68
+ Removing from RULES.md §7:
69
+ → "All APIs must follow REST. GraphQL is not permitted."
70
+
71
+ Version bump: 1.2.0 → 2.0.0 (major — convention removed)
72
+
73
+ ⚠️ This cannot be undone automatically. Confirm? (yes / cancel)
74
+ ```
75
+
76
+ 2. On approval: remove the entry, bump version (`major`), add Document History row.
77
+
78
+ ### Listing Conventions
79
+
80
+ **Trigger phrase**: *"Show rules"*, *"List conventions"*
81
+
82
+ Read and display all entries in `.design/RULES.md §7` as a numbered list.
83
+ No writes performed.
84
+
85
+ ## Task Completion Checklist
86
+
87
+ ```
88
+ Rule Workflow Checklist — {operation description}
89
+
90
+ ☐ RULES.md was read in full before any change
91
+ ☐ Only §7 was modified (unless user explicitly targeted §1–6)
92
+ ☐ Proposed change shown to user before writing
93
+ ☐ Version bumped correctly (minor for add/amend, major for remove)
94
+ ☐ Document History row added
95
+ ☐ No contradiction with existing rules in §1–6
96
+ ```
@@ -0,0 +1,88 @@
1
+ if (!(Test-Path -Path ".git")) {
2
+ Write-Host "Note: not a git repository. Proceeding with SDD initialization anyway."
3
+ }
4
+
5
+ $D = ".design"
6
+ foreach ($dir in @($D, "$D/specifications", "$D/tasks")) {
7
+ New-Item -ItemType Directory -Force -Path $dir | Out-Null
8
+ }
9
+ $Date = Get-Date -Format "yyyy-MM-dd"
10
+
11
+ $IndexPath = "$D/INDEX.md"
12
+ if (!(Test-Path $IndexPath)) {
13
+ Set-Content $IndexPath -Encoding UTF8 @"
14
+ # Specifications Registry
15
+ **Version:** 1.0.0
16
+ **Status:** Active
17
+
18
+ ## Overview
19
+ Central registry of all project specifications and their current state.
20
+
21
+ ## System Files
22
+ - [RULES.md](RULES.md) - Project constitution and standing conventions.
23
+
24
+ ## Domain Specifications
25
+ | File | Description | Status | Version |
26
+ | :--- | :--- | :--- | :--- |
27
+ <!-- Add your specifications here -->
28
+
29
+ ## Meta Information
30
+ - **Maintainer**: Core Team
31
+ - **License**: MIT
32
+ - **Last Updated**: $Date
33
+ "@
34
+ Write-Host "Created .design/INDEX.md"
35
+ }
36
+
37
+ $RulesPath = "$D/RULES.md"
38
+ if (!(Test-Path $RulesPath)) {
39
+ Set-Content $RulesPath -Encoding UTF8 @"
40
+ # Project Specification Rules
41
+ **Version:** 1.0.0
42
+ **Status:** Active
43
+
44
+ ## Overview
45
+ Constitution of the specification system for this project.
46
+ Read by the agent before every operation. Updated only via explicit triggers.
47
+
48
+ ## 1. Naming Conventions
49
+ - Spec files use lowercase kebab-case: ``api.md``, ``database-schema.md``.
50
+ - System files use uppercase: ``INDEX.md``, ``RULES.md``.
51
+ - Section names within specs are title-cased.
52
+
53
+ ## 2. Status Rules
54
+ - **Draft -> RFC**: all required sections filled, ready for review.
55
+ - **RFC -> Stable**: reviewed, approved, no open questions.
56
+ - **Any -> Deprecated**: explicitly superseded; replacement must be named.
57
+
58
+ ## 3. Versioning Rules
59
+ - patch (0.0.X): typo fixes, clarifications, no structural change.
60
+ - minor (0.X.0): new section added or existing section extended.
61
+ - major (X.0.0): structural restructure or scope change.
62
+
63
+ ## 4. Formatting Rules
64
+ - Use plaintext blocks for all directory trees.
65
+ - Use mermaid blocks for all flow and architecture diagrams.
66
+ - Do not use other diagram formats.
67
+
68
+ ## 5. Content Rules
69
+ - No implementation code (no Rust, JS, Python, SQL, etc.).
70
+ - Pseudo-code and logic flows are permitted.
71
+ - Every spec must have: Overview, Motivation, Document History.
72
+
73
+ ## 6. Relations Rules
74
+ - Every spec that depends on another must declare it in Related Specifications.
75
+ - Cross-file content duplication is not permitted — use a link instead.
76
+ - Circular dependencies must be flagged and resolved.
77
+
78
+ ## 7. Project Conventions
79
+ <!-- Populated automatically via triggers T1-T4. Do not edit manually. -->
80
+ *(No project-specific conventions defined yet.)*
81
+
82
+ ## Document History
83
+ | Version | Date | Author | Description |
84
+ | :--- | :--- | :--- | :--- |
85
+ | 1.0.0 | $Date | Agent | Initial constitution |
86
+ "@
87
+ Write-Host "Created .design/RULES.md"
88
+ }
@@ -0,0 +1,85 @@
1
+ #!/bin/bash
2
+ if [ ! -d ".git" ]; then
3
+ echo "Note: not a git repository. Proceeding with SDD initialization anyway."
4
+ fi
5
+
6
+ DESIGN_DIR=".design"
7
+ mkdir -p "$DESIGN_DIR/specifications" "$DESIGN_DIR/tasks"
8
+ DATE=$(date +%Y-%m-%d)
9
+
10
+ if [ ! -f "$DESIGN_DIR/INDEX.md" ]; then
11
+ cat <<EOF > "$DESIGN_DIR/INDEX.md"
12
+ # Specifications Registry
13
+ **Version:** 1.0.0
14
+ **Status:** Active
15
+
16
+ ## Overview
17
+ Central registry of all project specifications and their current state.
18
+
19
+ ## System Files
20
+ - [RULES.md](RULES.md) - Project constitution and standing conventions.
21
+
22
+ ## Domain Specifications
23
+ | File | Description | Status | Version |
24
+ | :--- | :--- | :--- | :--- |
25
+ <!-- Add your specifications here -->
26
+
27
+ ## Meta Information
28
+ - **Maintainer**: Core Team
29
+ - **License**: MIT
30
+ - **Last Updated**: $DATE
31
+ EOF
32
+ echo "Created .design/INDEX.md"
33
+ fi
34
+
35
+ if [ ! -f "$DESIGN_DIR/RULES.md" ]; then
36
+ cat <<EOF > "$DESIGN_DIR/RULES.md"
37
+ # Project Specification Rules
38
+ **Version:** 1.0.0
39
+ **Status:** Active
40
+
41
+ ## Overview
42
+ Constitution of the specification system for this project.
43
+ Read by the agent before every operation. Updated only via explicit triggers.
44
+
45
+ ## 1. Naming Conventions
46
+ - Spec files use lowercase kebab-case: \`api.md\`, \`database-schema.md\`.
47
+ - System files use uppercase: \`INDEX.md\`, \`RULES.md\`.
48
+ - Section names within specs are title-cased.
49
+
50
+ ## 2. Status Rules
51
+ - **Draft → RFC**: all required sections filled, ready for review.
52
+ - **RFC → Stable**: reviewed, approved, no open questions.
53
+ - **Any → Deprecated**: explicitly superseded; replacement must be named.
54
+
55
+ ## 3. Versioning Rules
56
+ - \`patch\` (0.0.X): typo fixes, clarifications — no structural change.
57
+ - \`minor\` (0.X.0): new section added or existing section extended.
58
+ - \`major\` (X.0.0): structural restructure or scope change.
59
+
60
+ ## 4. Formatting Rules
61
+ - Use \`plaintext\` blocks for all directory trees.
62
+ - Use \`mermaid\` blocks for all flow and architecture diagrams.
63
+ - Do not use other diagram formats.
64
+
65
+ ## 5. Content Rules
66
+ - No implementation code (no Rust, JS, Python, SQL, etc.).
67
+ - Pseudo-code and logic flows are permitted.
68
+ - Every spec must have: Overview, Motivation, Document History.
69
+
70
+ ## 6. Relations Rules
71
+ - Every spec that depends on another must declare it in \`Related Specifications\`.
72
+ - Cross-file content duplication is not permitted — use a link instead.
73
+ - Circular dependencies must be flagged and resolved.
74
+
75
+ ## 7. Project Conventions
76
+ <!-- Populated automatically via triggers T1-T4. Do not edit manually. -->
77
+ *(No project-specific conventions defined yet.)*
78
+
79
+ ## Document History
80
+ | Version | Date | Author | Description |
81
+ | :--- | :--- | :--- | :--- |
82
+ | 1.0.0 | $DATE | Agent | Initial constitution |
83
+ EOF
84
+ echo "Created .design/RULES.md"
85
+ fi