@axis-bootstrap/cli 0.1.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 (38) hide show
  1. package/README.md +90 -0
  2. package/package.json +42 -0
  3. package/src/commands/audit.js +53 -0
  4. package/src/commands/cleanup.js +42 -0
  5. package/src/commands/doctor.js +137 -0
  6. package/src/commands/init.js +297 -0
  7. package/src/commands/link.js +31 -0
  8. package/src/commands/spdd.js +139 -0
  9. package/src/commands/state.js +21 -0
  10. package/src/index.js +113 -0
  11. package/src/lib/copy.js +19 -0
  12. package/src/lib/detect.js +70 -0
  13. package/src/lib/i18n.js +147 -0
  14. package/src/lib/paths.js +45 -0
  15. package/src/lib/ui.js +29 -0
  16. package/templates/CANVAS.md +48 -0
  17. package/templates/CONVENTIONS.md +43 -0
  18. package/templates/INSTRUCTIONS.md +49 -0
  19. package/templates/STATE.md +27 -0
  20. package/templates/bootstrap-skill/PLANNER.md +221 -0
  21. package/templates/bootstrap-skill/PROMPT-TEMPLATE.md +128 -0
  22. package/templates/bootstrap-skill/SKILL.md +56 -0
  23. package/templates/bootstrap-skill/references/CANVAS-REASONS.md +111 -0
  24. package/templates/bootstrap-skill/references/PATTERNS.md +372 -0
  25. package/templates/bootstrap-skill/references/PHASE-1-DISCOVERY.md +120 -0
  26. package/templates/bootstrap-skill/references/PHASE-2-SPEC.md +250 -0
  27. package/templates/bootstrap-skill/references/PHASE-3-HARNESS.md +331 -0
  28. package/templates/bootstrap-skill/references/PHASE-4-MEMORY.md +187 -0
  29. package/templates/bootstrap-skill/references/PHASE-5-VALIDATION.md +194 -0
  30. package/templates/bootstrap-skill/references/QUICKSTART.md +144 -0
  31. package/templates/bootstrap-skill/references/TEMPLATES.md +602 -0
  32. package/templates/bootstrap-skill/references/UNIVERSAL-MAP.md +216 -0
  33. package/templates/settings.json +29 -0
  34. package/templates/setup-ide-links.sh +33 -0
  35. package/templates/skills/abstraction-first.md +55 -0
  36. package/templates/skills/alignment.md +53 -0
  37. package/templates/skills/iterative-review.md +55 -0
  38. package/templates/skills/story-decompose.md +54 -0
@@ -0,0 +1,49 @@
1
+ # {{PROJECT_NAME}} — AI Instructions
2
+
3
+ > Single source of truth for AI agents. All IDE-specific files (CLAUDE.md, AGENTS.md, etc.) symlink here.
4
+
5
+ ## Purpose
6
+
7
+ {{PROJECT_PURPOSE}}
8
+
9
+ ## Stack
10
+
11
+ - {{STACK}}
12
+
13
+ ## How to Run
14
+
15
+ ```bash
16
+ # fill in
17
+ ```
18
+
19
+ ## Architecture
20
+
21
+ | Component | Responsibility |
22
+ | --------- | -------------- |
23
+ | `src/` | Application source |
24
+ | `tests/` | Tests |
25
+
26
+ ## Design Principles
27
+
28
+ 1. Single Source of Truth — content lives in `.ai/`, never duplicated
29
+ 2. Progressive Disclosure — load only what is needed
30
+ 3. Spec-Driven — REASONS Canvas precedes code generation
31
+ 4. Harness-first — `.claude/settings.json` and hooks define behavior, not the prompt
32
+
33
+ ## Available Skills
34
+
35
+ | Skill | When to use |
36
+ | ----- | ----------- |
37
+ | (none yet — add skills under `.ai/skills/<name>/SKILL.md`) | |
38
+
39
+ ## Conventions
40
+
41
+ - Update `STATE.md` at end of every session with relevant changes
42
+ - Update spec before code when requirements change
43
+ - See [CONVENTIONS.md](CONVENTIONS.md) for the maintenance protocol
44
+
45
+ ## Key Documents
46
+
47
+ - [CONVENTIONS.md](CONVENTIONS.md) — how to maintain this structure
48
+ - [docs/STATE.md](docs/STATE.md) — current playbook
49
+ - [docs/canvases/](docs/canvases/) — REASONS Canvases (one per feature)
@@ -0,0 +1,27 @@
1
+ # STATE — {{PROJECT_NAME}} Playbook
2
+
3
+ > Curated memory. Read at session start. Update at session end. Curate (do not just append).
4
+
5
+ ## Active Decisions
6
+
7
+ - (none yet)
8
+
9
+ ## In Progress
10
+
11
+ - (none yet)
12
+
13
+ ## Blockers
14
+
15
+ - (none)
16
+
17
+ ## Deferred Ideas
18
+
19
+ - (none)
20
+
21
+ ## Lessons Learned
22
+
23
+ - (none yet — add non-obvious insights only)
24
+
25
+ ## TODOs
26
+
27
+ - [ ] First feature: scaffold a Canvas via `axis spdd canvas <slug>`
@@ -0,0 +1,221 @@
1
+ # Bootstrap Planner — Phase Orchestration
2
+
3
+ This document describes the **execution state** of the bootstrap. The agent consults it as a state machine: each phase has an input, an output, and a gate before advancing.
4
+
5
+ ---
6
+
7
+ ## Orchestration Principles
8
+
9
+ 1. **Sequential and blocking** — do not start Phase N+1 without confirming Phase N's gate with the user
10
+ 2. **Each phase is atomic** — if something in Phase 2 indicates Phase 1 was wrong, **go back** to Phase 1, do not fix inline
11
+ 3. **Stateful** — keep a record of what was decided in each phase (write to `.ai/docs/STATE.md` in the target project once Phase 4 creates the file; until then, keep in session memory)
12
+ 4. **Never silence the user** — present summaries before each gate; wait for explicit approval
13
+
14
+ ---
15
+
16
+ ## Initial State
17
+
18
+ When the skill is invoked, the agent checks:
19
+
20
+ - Does `.ai/INSTRUCTIONS.md` exist in the target project? → **Mode:** audit (skip to Phase 5)
21
+ - Does a readable `CLAUDE.md` or `AGENTS.md` exist? → **Mode:** migration (reduced Phase 1 — extract context from existing file)
22
+ - Empty folder or just code? → **Mode:** full bootstrap (all 5 phases)
23
+
24
+ Ask the user which mode applies if detection is ambiguous.
25
+
26
+ ---
27
+
28
+ ## Phase 1 — Discovery
29
+
30
+ **Loads:** [references/PHASE-1-DISCOVERY.md](references/PHASE-1-DISCOVERY.md)
31
+
32
+ **Input:** target project + user intent
33
+
34
+ **Expected output:**
35
+
36
+ - Project type identified (software / content / research / business / legal / educational / other)
37
+ - Main stack or tools (if applicable)
38
+ - 3-7 candidate domains to become skills
39
+ - Critical constraints (compliance, deadline, team, preferred IDE)
40
+ - Output quality criteria (proof-of-concept vs production)
41
+
42
+ **Exit gate:**
43
+
44
+ > Present structured summary in ~10 bullets. Ask literal confirmation: *"Is this correct and complete? Anything to add before proceeding?"*
45
+
46
+ **Do not advance until receiving "yes" or applied corrections.**
47
+
48
+ ---
49
+
50
+ ## Phase 1.5 — SPDD Pipeline *(optional, recommended for complex projects)*
51
+
52
+ **When to apply:** project with non-trivial business logic, multiple domain entities, or existing codebase to understand before speccing.
53
+
54
+ **Trigger:** user says "analyze before speccing", project has >2 interacting entities, or complexity is evaluated as Large/Complex by Pattern #4.
55
+
56
+ **Pipeline (each step has its own exit gate):**
57
+
58
+ | # | Skill | Produces (REASONS Canvas section) | Why this order |
59
+ | - | ----- | --------------------------------- | -------------- |
60
+ | 1 | [`story-decompose`](../../story-decompose/SKILL.md) | **R** — INVEST stories with G/W/T ACs + DoD | Cannot align on what is undefined |
61
+ | 2 | [`alignment`](../../alignment/SKILL.md) | **O** scope lock + **N** Norms + **S₂** Safeguards | Cannot design without governance bounds |
62
+ | 3 | [`abstraction-first`](../../abstraction-first/SKILL.md) | **E** Entities + **A** Approach + **S₁** System structure | Cannot generate code without object design |
63
+
64
+ The artifact produced is the **REASONS Canvas** ([references/CANVAS-REASONS.md](references/CANVAS-REASONS.md)) — single page per feature. If it doesn't fit, return to step 1 and split smaller.
65
+
66
+ **Exit gate:**
67
+
68
+ > Present the filled Canvas (all 7 dimensions: R/E/A/S₁/O/N/S₂). Ask: *"Does this capture the feature? Any AC, entity, norm, or invariant I missed?"* Advance to Phase 2 only after confirmation.
69
+
70
+ **Note on `iterative-review`:** runs **after** code is generated (post-Phase 5). See Phase 6.
71
+
72
+ ---
73
+
74
+ ## Phase 2 — Spec Layer
75
+
76
+ **Loads:** [references/PHASE-2-SPEC.md](references/PHASE-2-SPEC.md) + [references/TEMPLATES.md](references/TEMPLATES.md)
77
+
78
+ **Input:** Phase 1 output
79
+
80
+ **Generation in this order:**
81
+
82
+ 1. `mkdir -p .ai/{skills,rules,docs}` in target project
83
+ 2. `INSTRUCTIONS.md` (100-180 lines) using template adapted to type
84
+ 3. Skill skeletons (one SKILL.md per identified domain, without references/ yet)
85
+ 4. 3-7 initial rules with appropriate `applyTo` (omit if non-technical — use protocols)
86
+ 5. Doc stubs: `architecture.md`, `database-schema.md` (if software), `glossary.md` (if specialized domain)
87
+
88
+ **Exit gate:**
89
+
90
+ > List all files created with 1-line purpose each. Show line counts. Ask confirmation: *"This is the minimal Spec Layer. Any critical domain I missed? Any file that doesn't make sense for this project?"*
91
+
92
+ ---
93
+
94
+ ## Phase 3 — Harness Layer
95
+
96
+ **Loads:** [references/PHASE-3-HARNESS.md](references/PHASE-3-HARNESS.md) + [references/TEMPLATES.md](references/TEMPLATES.md)
97
+
98
+ **Input:** Phase 2 confirmed + project type
99
+
100
+ **Critical decisions:**
101
+
102
+ - **Lint/format hooks:** only if software with available formatter
103
+ - **Destructive blocking hook:** **always** (universal, low cost, high value)
104
+ - **Stop hook for tests:** only if software with test runner
105
+ - **Sub-agents:** always enable `Explore`; others per scope
106
+ - **Symlinks by IDE:** only for IDEs the user declared using
107
+
108
+ **Generation:**
109
+
110
+ 1. `.claude/settings.json` (or equivalent) versioned, with appropriate permission profile
111
+ 2. `scripts/` with hooks (`format-file.sh`, `validate-bash.sh`, `run-tests-if-changed.sh` — only applicable ones)
112
+ 3. Symlinks via `setup-ide-links.sh` adapted to declared IDEs
113
+ 4. (Optional) `.gitignore` adjusted
114
+
115
+ **Exit gate:**
116
+
117
+ > Show `settings.json`, list of installed hooks, and symlink tree. Smoke test: *"I'll run `ls -la` to confirm the symlinks. May I?"* After confirmation, execute and show output.
118
+
119
+ ---
120
+
121
+ ## Phase 4 — Memory Layer
122
+
123
+ **Loads:** [references/PHASE-4-MEMORY.md](references/PHASE-4-MEMORY.md)
124
+
125
+ **Input:** Phases 2 and 3 confirmed
126
+
127
+ **Generation:**
128
+
129
+ 1. `.ai/docs/STATE.md` with sections: Active Decisions, In Progress, Blockers, Deferred Ideas, Lessons Learned, TODOs
130
+ 2. `.ai/CONVENTIONS.md` with symlink map and maintenance rules
131
+
132
+ **Exit gate:**
133
+
134
+ > Show generated content. Ask: *"Are there decisions already made, current blockers, or important context to record now before the first real session?"* Update `STATE.md` with what the user provides.
135
+
136
+ ---
137
+
138
+ ## Phase 5 — Validation
139
+
140
+ **Loads:** [references/PHASE-5-VALIDATION.md](references/PHASE-5-VALIDATION.md)
141
+
142
+ **Input:** Phases 1-4 complete
143
+
144
+ **Execution:**
145
+
146
+ 1. Run quality gates checklist (12-15 items)
147
+ 2. Calculate metrics (lines in INSTRUCTIONS, average SKILL.md size, rules count)
148
+ 3. Automated smoke tests (symlinks resolve, hooks execute)
149
+ 4. Generate handoff: list of files created + suggested next steps
150
+
151
+ **Final gate:**
152
+
153
+ > Present completed bootstrap report. List 3-5 actions suggested for the user to do next (e.g., "Create the first detailed skill for domain X", "Configure CI to validate symlinks").
154
+
155
+ ---
156
+
157
+ ## Phase 6 — Iterative Review *(post-bootstrap, per feature)*
158
+
159
+ **When to apply:** triggered after code is generated from a REASONS Canvas, OR when a code review reveals drift between code and Canvas.
160
+
161
+ **Loads:** [`iterative-review`](../../iterative-review/SKILL.md)
162
+
163
+ **Two tracks:**
164
+
165
+ - **Track A — Logic correction** (behavior wrong): update Canvas first → regenerate affected Operations → verify
166
+ - **Track B — Refactoring** (no behavior change): refactor code → sync Canvas back → verify tests
167
+
168
+ **Exit gate:**
169
+
170
+ > Diff confined to Canvas Structure section? All ACs verified with concrete values? STATE.md updated with new patterns/decisions?
171
+
172
+ **This phase is recurring** — every feature post-bootstrap re-enters Phase 1.5 → 6 cycle. Bootstrap (Phases 1-5) runs once; SPDD pipeline runs per feature.
173
+
174
+ ---
175
+
176
+ ## Recovery
177
+
178
+ If a phase fails (user rejects output, contradictory information arises):
179
+
180
+ - **In Phase 1-2:** review questions, adjust summary, regenerate
181
+ - **In Phase 3:** if stack changed, regenerate `settings.json` and hooks; symlinks are reversible (`rm` + recreate)
182
+ - **In Phase 4-5:** rarely requires going back; usually a targeted correction in `STATE.md` or `CONVENTIONS.md`
183
+
184
+ **Never destroy the user's work.** Before overwriting an existing file, make a backup (`.bak`) or ask for confirmation.
185
+
186
+ ---
187
+
188
+ ## Frequent Decision Map
189
+
190
+ | Phase question | Default answer |
191
+ | ---------------------------------------- | --------------------------------------------------------------------------- |
192
+ | Unknown type in Phase 1 | Treat as "other" and use UNIVERSAL-MAP to infer |
193
+ | Stack not in TEMPLATES.md | Use Node.js template as base and adapt — log as follow-up |
194
+ | User doesn't know which skills to create | Suggest 3 based on described domain + 1 universal quality skill (lint/test) |
195
+ | User doesn't use any specific IDE | Create only root symlinks (CLAUDE.md, AGENTS.md) and `.agents/` |
196
+ | Non-technical project | Partially skip Phase 3 (hooks); keep destructive blocking + permissions |
197
+
198
+ ---
199
+
200
+ ## Expected Final State
201
+
202
+ At the end, the target project has:
203
+
204
+ ```text
205
+ target-project/
206
+ ├── .ai/
207
+ │ ├── INSTRUCTIONS.md
208
+ │ ├── CONVENTIONS.md
209
+ │ ├── skills/ (3-7 skills with minimal SKILL.md)
210
+ │ ├── rules/ (3-7 rules — if applicable)
211
+ │ └── docs/
212
+ │ ├── architecture.md (if software)
213
+ └── STATE.md
214
+ ├── .claude/ (symlinks)
215
+ ├── .cursor/, .agents/, .github/ (per declared IDEs)
216
+ ├── CLAUDE.md, AGENTS.md (symlinks)
217
+ ├── .claude/settings.json (versioned)
218
+ └── scripts/ (hooks — if software)
219
+ ```
220
+
221
+ Expected complete structure in [PROMPT-TEMPLATE.md](PROMPT-TEMPLATE.md).
@@ -0,0 +1,128 @@
1
+ # Prompt Template — Output Contract
2
+
3
+ This is the **contract** of what a successful bootstrap delivers. Use as reference when generating and as the basis for validation in Phase 5.
4
+
5
+ ---
6
+
7
+ ## Expected Final Structure
8
+
9
+ ```text
10
+ target-project/
11
+ ├── .ai/ ← SINGLE SOURCE
12
+ │ ├── INSTRUCTIONS.md (100-180 lines)
13
+ │ ├── CONVENTIONS.md (map + rules)
14
+ │ ├── skills/
15
+ │ │ ├── <skill-1>/SKILL.md (40-60 lines)
16
+ │ │ ├── <skill-2>/SKILL.md
17
+ │ │ └── ... (3-7 skills)
18
+ │ ├── rules/ (3-7 rules — if applicable)
19
+ │ │ ├── code-style.md
20
+ │ │ ├── architecture-patterns.md
21
+ │ │ └── ...
22
+ │ └── docs/
23
+ │ ├── architecture.md (if software)
24
+ │ ├── database-schema.md (if software)
25
+ │ ├── glossary.md (if specialized domain)
26
+ │ └── STATE.md (memory layer — curated playbook)
27
+
28
+ ├── CLAUDE.md → .ai/INSTRUCTIONS.md
29
+ ├── AGENTS.md → .ai/INSTRUCTIONS.md
30
+
31
+ ├── .claude/ (if Claude Code declared)
32
+ │ ├── CLAUDE.md → ../.ai/INSTRUCTIONS.md
33
+ │ ├── rules → ../.ai/rules
34
+ │ ├── skills → ../.ai/skills
35
+ │ └── settings.json (versioned)
36
+
37
+ ├── .cursor/, .agents/, .github/ (per declared IDEs)
38
+
39
+ ├── scripts/ (if software)
40
+ │ ├── format-file.sh
41
+ │ ├── validate-bash.sh
42
+ │ └── run-tests-if-changed.sh
43
+
44
+ └── setup-ide-links.sh (idempotent)
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Minimum Content per File
50
+
51
+ ### `.ai/INSTRUCTIONS.md`
52
+
53
+ Order (consultation frequency, not logical importance):
54
+
55
+ 1. What the project does (1-2 sentences)
56
+ 2. Stack or tools (with versions)
57
+ 3. How to run / how to start
58
+ 4. Architecture in table (components + responsibility)
59
+ 5. Design principles (3-7 bullets with rationale)
60
+ 6. Code conventions (summary — details in rules)
61
+ 7. Available skills (table with when to use)
62
+ 8. Links to docs and references
63
+
64
+ **Size:** 100-180 lines. Below 100 is superficial; above 200 loses focus.
65
+
66
+ ### `.ai/skills/<skill>/SKILL.md`
67
+
68
+ ```markdown
69
+ ---
70
+ name: <skill-name>
71
+ description: <2-4 lines mentioning domain terms that act as triggers>
72
+ ---
73
+
74
+ # Skill Title
75
+
76
+ <Purpose in 1-2 sentences.>
77
+
78
+ ## When to Use
79
+ - <Scenario 1>
80
+ - <Scenario 2>
81
+ - <Scenario 3>
82
+
83
+ ## Quick Summary
84
+ <Dense table or bullets>
85
+
86
+ ## References
87
+ - [GUIDE.md](references/GUIDE.md) — <purpose>
88
+ - [REFERENCE.md](references/REFERENCE.md) — <purpose>
89
+ ```
90
+
91
+ **Size:** 40-60 lines. Description: 2-4 lines, written in third person, with trigger terms.
92
+
93
+ ### `.ai/CONVENTIONS.md`
94
+
95
+ - Symlink map
96
+ - Rules for the agent (where to create files, what never to do)
97
+ - Knowledge Verification Chain
98
+ - How to add new IDE (3-4 lines of `ln -s`)
99
+ - Templates pointer (link to TEMPLATES.md or local copy)
100
+
101
+ ---
102
+
103
+ ## Handoff to User
104
+
105
+ ```markdown
106
+ ## Bootstrap Complete
107
+
108
+ ### What was created
109
+ - N files in .ai/
110
+ - N skills initialized: <list>
111
+ - N rules: <list>
112
+ - N stubs in docs/
113
+ - Memory layer with STATE, CONVENTIONS
114
+ - N symlinks distributing to <IDEs>
115
+ - N hooks in settings.json
116
+
117
+ ### Metrics
118
+ - INSTRUCTIONS.md: N lines (target 100-180) ✓
119
+ - SKILL.md average: N lines (target 40-60) ✓
120
+ - Symlinks: all resolve ✓
121
+ - Smoke tests: pass ✓
122
+
123
+ ### Suggested next steps (3-5)
124
+ 1. Detail the first priority skill — populate references/GUIDE.md in <skill>
125
+ 2. Validate settings.json with the team
126
+ 3. Configure CI to verify symlink resolution
127
+ 4. Test invocation by another IDE (multi-tool smoke test)
128
+ ```
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: axis-bootstrap
3
+ description: Bootstrap any project — software or non-technical — with a complete Spec + Harness + Memory structure for AI-augmented work. Harness-first: permissions, hooks, and symlinks are configured before prompt optimization. Use when starting a new project from scratch, when adopting AI-augmented workflows in an existing project, when migrating from a monolithic CLAUDE.md to a structured framework, or when auditing a project for missing AI infrastructure. Also handles quick-start path (5 minutes). Trigger terms: bootstrap, initialize project, AI setup, .ai structure, CLAUDE.md, AGENTS.md, multi-IDE, skills, harness, spec-driven, progressive disclosure, axis, axis-bootstrap, failure attribution, ACE, memory playbook.
4
+ ---
5
+
6
+ # AXIS Bootstrap
7
+
8
+ Executable spec for bootstrapping projects with complete AI infrastructure. Orchestrates the creation of three layers (Spec, Harness, Memory) in sequential phases with explicit gates. **Harness is the priority — not the prompt.**
9
+
10
+ ## When to Use
11
+
12
+ - New project — wants solid AI-collaboration foundation
13
+ - Existing project without structured `.ai/`, or migration from monolithic `CLAUDE.md`
14
+ - Auditing gaps in Spec/Harness/Memory; standardizing multiple projects
15
+ - Quick start: 5-minute path (see `references/QUICKSTART.md`)
16
+
17
+ ## Summary Flow
18
+
19
+ | Phase | Focus | Exit Gate |
20
+ | ----- | ----- | --------- |
21
+ | **1 — Discovery** | Interview to understand the project | Summary confirmed by user |
22
+ | **1.5 — SPDD Pipeline** *(optional)* | `story-decompose` → `alignment` → `abstraction-first` produce REASONS Canvas | All 7 dimensions (R/E/A/S₁/O/N/S₂) filled and confirmed |
23
+ | **2 — Spec Layer** | Generate INSTRUCTIONS, skills, rules, docs | `.ai/` structure populated and validated |
24
+ | **3 — Harness Layer** | Configure settings, hooks, failure attribution, symlinks | Permissions and automation in effect |
25
+ | **4 — Memory Layer** | Create STATE (playbook), CONVENTIONS | Curated memory ready for first session |
26
+ | **5 — Validation** | Quality gates, k-trial smoke test, handoff | Bootstrap delivered |
27
+ | **6 — Iterative Review** *(per feature, post-bootstrap)* | `iterative-review` keeps Canvas ⇄ code in sync | Diff scoped, ACs green, STATE updated |
28
+
29
+ Detailed orchestration in [PLANNER.md](PLANNER.md). Final output contract in [PROMPT-TEMPLATE.md](PROMPT-TEMPLATE.md).
30
+
31
+ ## Execution Principles
32
+
33
+ 1. **Harness before prompts** — settings.json and hooks take precedence
34
+ 2. **Do not skip phases** — each depends on validation of the previous one
35
+ 3. **Do not fabricate** — if information is missing, ask (Knowledge Verification Chain)
36
+ 4. **Confirm before generating** — show the phase plan, wait for approval
37
+ 5. **Use templates** — do not invent formats; they live in `references/TEMPLATES.md`
38
+
39
+ ## References
40
+
41
+ - [PLANNER.md](PLANNER.md) — phase orchestration and gate rules
42
+ - [PROMPT-TEMPLATE.md](PROMPT-TEMPLATE.md) — expected final structure of the bootstrapped project
43
+ - [references/QUICKSTART.md](references/QUICKSTART.md) — 5-minute path
44
+ - [references/PHASE-1-DISCOVERY.md](references/PHASE-1-DISCOVERY.md) — interview and decision tree
45
+ - [references/PHASE-2-SPEC.md](references/PHASE-2-SPEC.md) — Spec Layer generation
46
+ - [references/PHASE-3-HARNESS.md](references/PHASE-3-HARNESS.md) — Harness Layer configuration + failure attribution
47
+ - [references/PHASE-4-MEMORY.md](references/PHASE-4-MEMORY.md) — Memory Layer initialization + ACE principles
48
+ - [references/PHASE-5-VALIDATION.md](references/PHASE-5-VALIDATION.md) — quality gates and handoff
49
+ - [references/TEMPLATES.md](references/TEMPLATES.md) — all copy-paste templates
50
+ - [references/PATTERNS.md](references/PATTERNS.md) — technical patterns (PD, KVC, ACE, k-trial)
51
+ - [references/CANVAS-REASONS.md](references/CANVAS-REASONS.md) — REASONS Canvas template (SPDD artifact)
52
+ - [references/UNIVERSAL-MAP.md](references/UNIVERSAL-MAP.md) — technical ↔ non-technical mapping
53
+
54
+ ## Final Validation (summary)
55
+
56
+ `.ai/` populated · INSTRUCTIONS 100-180 lines · SKILL.md ≤ 60 · `settings.json` versioned · symlinks resolve · `STATE.md` curated · handoff delivered. Full checklist in [references/PHASE-5-VALIDATION.md](references/PHASE-5-VALIDATION.md).
@@ -0,0 +1,111 @@
1
+ # REASONS Canvas — SPDD Artifact Template
2
+
3
+ > Single-page spec produced collaboratively (PO + dev + AI) before code generation. Aligned with [Martin Fowler — Structured Prompt-Driven Development](https://martinfowler.com/articles/structured-prompt-driven). Filled by the AXIS SPDD pipeline (`story-decompose` → `alignment` → `abstraction-first` → generate → `iterative-review`).
4
+
5
+ ## Why a Canvas (not a long doc)
6
+
7
+ Long specs create the illusion of work (Spec Kit issue #75). The Canvas enforces a single page per feature — if it doesn't fit, the feature is too big and must be re-decomposed via `story-decompose`.
8
+
9
+ ## The seven dimensions (R-E-A-S-O-N-S)
10
+
11
+ | Letter | Dimension | Layer | Filled by | Purpose |
12
+ | ------- | ------------------ | ---------- | ------------------------ | -------------------------------------------------------- |
13
+ | **R** | Requirements | Abstract | `story-decompose` | INVEST story + Given/When/Then ACs + DoD |
14
+ | **E** | Entities | Abstract | `abstraction-first` | Domain nouns, relationships, single responsibility |
15
+ | **A** | Approach (Strategy)| Abstract | `abstraction-first` | High-level strategy to satisfy R |
16
+ | **S₁** | System structure | Abstract | `abstraction-first` | Components, layer boundaries, file tree |
17
+ | **O** | Operations | Specific | `alignment` + dev | Concrete, testable steps / endpoints / methods |
18
+ | **N** | Norms | Governance | `alignment` | Engineering standards (naming, logging, defensive coding) |
19
+ | **S₂** | Safeguards | Governance | `alignment` | Non-negotiable invariants (correctness, perf, security) |
20
+
21
+ > **Layered reading:**
22
+ > - **Abstract (R, E, A, S₁)** = intent + design. *What* and *with what shape*.
23
+ > - **Specific (O)** = execution. *How*, step-by-step.
24
+ > - **Governance (N, S₂)** = boundaries. *What must always hold*.
25
+
26
+ ## Canvas template
27
+
28
+ ````markdown
29
+ # Canvas — <feature name>
30
+
31
+ ## R — Requirements
32
+ **Story:** As a <role>, I want <capability>, so that <value>.
33
+ **ACs (Given/When/Then):**
34
+ - Given <context>, When <action>, Then <expected with concrete numbers>
35
+ - Given …, When …, Then …
36
+ **Definition of Done:**
37
+ - [ ] All ACs verified with automated tests
38
+ - [ ] <other DoD criteria>
39
+
40
+ ## E — Entities
41
+ - **<EntityA>** — single responsibility: <…>; relates to <EntityB> via <…>
42
+ - **<EntityB>** — …
43
+
44
+ ## A — Approach (strategy)
45
+ <1-3 sentences on the strategy. e.g. "Compute pricing via Strategy pattern keyed on plan type, dispatched from PricingService. Use existing repository for persistence — no schema change.">
46
+
47
+ ## S₁ — System structure
48
+ **Layers touched:** Controller → Service → Repository → Domain
49
+ **Components:**
50
+ - `PricingService` (new) — orchestrates strategy lookup and computation
51
+ - `PricingStrategy` (interface) — Standard / Premium implementations
52
+ **File tree (closed scope):**
53
+ ```
54
+ src/
55
+ ├── domain/<Entity>.ts (new)
56
+ ├── application/<Service>.ts (modified)
57
+ └── infrastructure/<Repo>.ts (new)
58
+ tests/
59
+ └── application/<Service>.spec.ts (new)
60
+ ```
61
+
62
+ ## O — Operations
63
+ - [ ] `PricingService.calculate(input)`: input → output, references AC #1, #3
64
+ - [ ] `StandardStrategy.apply(usage)`: …
65
+ - [ ] HTTP endpoint `POST /pricing/quote`: returns 200 with body schema X
66
+
67
+ ## N — Norms
68
+ - Naming: `<Entity>Service`, `<Entity>Repository` — no abbreviations
69
+ - Logging: structured JSON with `correlationId` on every Service entry/exit
70
+ - Errors: throw `DomainError` for business rule violations, never return null
71
+ - Tests: AAA, no shared mutable fixtures
72
+
73
+ ## S₂ — Safeguards (invariants)
74
+ - Bill total is always non-negative
75
+ - No PII in logs
76
+ - Latency p95 < 200ms for `/pricing/quote`
77
+ - DROP/TRUNCATE never executed without explicit confirmation
78
+ ````
79
+
80
+ ## Canvas lifecycle
81
+
82
+ ```text
83
+ 1. story-decompose → fills R (one Canvas per INVEST story)
84
+ 2. alignment → fills O (scope lock) + N + S₂
85
+ 3. abstraction-first → fills E + A + S₁
86
+ 4. (code generation) → uses O as direct prompt; checks N + S₂ on every step
87
+ 5. iterative-review → updates Canvas (Track A) or syncs Canvas to code (Track B)
88
+ ```
89
+
90
+ ## Validation gates
91
+
92
+ - [ ] All seven dimensions present (no `TBD`)
93
+ - [ ] R has ≥2 ACs with concrete numeric values
94
+ - [ ] E entities each have a single, stated responsibility
95
+ - [ ] A names a concrete strategy (not "we'll figure it out")
96
+ - [ ] S₁ file tree is **closed** — no wildcards
97
+ - [ ] O references AC numbers from R (traceability)
98
+ - [ ] N has ≥3 standards (naming + observability + at least one more)
99
+ - [ ] S₂ has ≥1 invariant (otherwise no test target)
100
+
101
+ ## Storage
102
+
103
+ - One Canvas per feature, lives in `.ai/docs/canvases/<feature-slug>.md`
104
+ - When complete + merged, move under `.ai/docs/canvases/done/` (kept for traceability)
105
+ - The active Canvas is referenced from `STATE.md` → In Progress
106
+
107
+ ## Relation to STATE.md
108
+
109
+ - Canvas captures **one feature** (closed scope, eventually archived)
110
+ - STATE captures **project-level continuity** (active decisions, blockers)
111
+ - Deferrals from Canvas → flow into STATE → seed next Canvas