gsdd-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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +528 -0
  3. package/agents/DISTILLATION.md +306 -0
  4. package/agents/README.md +53 -0
  5. package/agents/debugger.md +82 -0
  6. package/agents/executor.md +394 -0
  7. package/agents/integration-checker.md +318 -0
  8. package/agents/mapper.md +103 -0
  9. package/agents/planner.md +296 -0
  10. package/agents/researcher.md +84 -0
  11. package/agents/roadmapper.md +296 -0
  12. package/agents/synthesizer.md +236 -0
  13. package/agents/verifier.md +337 -0
  14. package/bin/adapters/agents.mjs +33 -0
  15. package/bin/adapters/claude.mjs +145 -0
  16. package/bin/adapters/codex.mjs +58 -0
  17. package/bin/adapters/index.mjs +20 -0
  18. package/bin/adapters/opencode.mjs +237 -0
  19. package/bin/gsdd.mjs +102 -0
  20. package/bin/lib/cli-utils.mjs +28 -0
  21. package/bin/lib/health.mjs +248 -0
  22. package/bin/lib/init.mjs +379 -0
  23. package/bin/lib/manifest.mjs +134 -0
  24. package/bin/lib/models.mjs +379 -0
  25. package/bin/lib/phase.mjs +237 -0
  26. package/bin/lib/rendering.mjs +95 -0
  27. package/bin/lib/templates.mjs +207 -0
  28. package/distilled/DESIGN.md +1286 -0
  29. package/distilled/README.md +169 -0
  30. package/distilled/SKILL.md +85 -0
  31. package/distilled/templates/agents.block.md +90 -0
  32. package/distilled/templates/agents.md +13 -0
  33. package/distilled/templates/auth-matrix.md +78 -0
  34. package/distilled/templates/codebase/architecture.md +110 -0
  35. package/distilled/templates/codebase/concerns.md +95 -0
  36. package/distilled/templates/codebase/conventions.md +193 -0
  37. package/distilled/templates/codebase/stack.md +96 -0
  38. package/distilled/templates/delegates/mapper-arch.md +26 -0
  39. package/distilled/templates/delegates/mapper-concerns.md +27 -0
  40. package/distilled/templates/delegates/mapper-quality.md +28 -0
  41. package/distilled/templates/delegates/mapper-tech.md +25 -0
  42. package/distilled/templates/delegates/plan-checker.md +55 -0
  43. package/distilled/templates/delegates/researcher-architecture.md +30 -0
  44. package/distilled/templates/delegates/researcher-features.md +30 -0
  45. package/distilled/templates/delegates/researcher-pitfalls.md +30 -0
  46. package/distilled/templates/delegates/researcher-stack.md +30 -0
  47. package/distilled/templates/delegates/researcher-synthesizer.md +31 -0
  48. package/distilled/templates/research/architecture.md +57 -0
  49. package/distilled/templates/research/features.md +23 -0
  50. package/distilled/templates/research/pitfalls.md +46 -0
  51. package/distilled/templates/research/stack.md +45 -0
  52. package/distilled/templates/research/summary.md +67 -0
  53. package/distilled/templates/roadmap.md +62 -0
  54. package/distilled/templates/spec.md +110 -0
  55. package/distilled/workflows/audit-milestone.md +220 -0
  56. package/distilled/workflows/execute.md +270 -0
  57. package/distilled/workflows/map-codebase.md +246 -0
  58. package/distilled/workflows/new-project.md +418 -0
  59. package/distilled/workflows/pause.md +121 -0
  60. package/distilled/workflows/plan.md +383 -0
  61. package/distilled/workflows/progress.md +199 -0
  62. package/distilled/workflows/quick.md +187 -0
  63. package/distilled/workflows/resume.md +152 -0
  64. package/distilled/workflows/verify.md +307 -0
  65. package/package.json +45 -0
@@ -0,0 +1,169 @@
1
+ # GSDD (Get Shit Done Distilled)
2
+
3
+ Lightweight Spec-Driven Development (SDD) for AI-assisted engineering.
4
+
5
+ Distilled from GSD (Get Shit Done): keep rigor and leverage, drop ceremony.
6
+
7
+ ## What This Is
8
+
9
+ GSDD is a small set of workflow sources plus a CLI (`gsdd`) that:
10
+ - scaffolds a project planning workspace (`.planning/`)
11
+ - generates portable workflow entrypoints as skills (`.agents/skills/gsdd-*/SKILL.md`)
12
+ - optionally generates tool-specific adapters for runtimes that need extra native surfaces (root `AGENTS.md`, Claude skills + plan-command alias + native agents, OpenCode commands + native agents)
13
+
14
+ ## Quick Start
15
+
16
+ Run in your project root:
17
+ ```bash
18
+ npx gsdd-cli init
19
+ ```
20
+
21
+ Optional adapters:
22
+ ```bash
23
+ npx gsdd-cli init --tools claude
24
+ npx gsdd-cli init --tools opencode
25
+ npx gsdd-cli init --tools codex
26
+ npx gsdd-cli init --tools agents
27
+ npx gsdd-cli init --tools all
28
+ ```
29
+
30
+ Notes:
31
+ - `gsdd init` always generates open-standard skills at `.agents/skills/gsdd-*`. This is also the primary Codex CLI surface.
32
+ - `--tools claude` also generates native agents at `.claude/agents/gsdd-*.md` and a compatibility plan command alias at `.claude/commands/gsdd-plan.md`.
33
+ - `--tools opencode` also generates native agents at `.opencode/agents/gsdd-*.md`.
34
+ - `--tools codex` generates `.codex/agents/gsdd-plan-checker.toml`; the portable `.agents/skills/gsdd-plan/` surface remains the Codex entry path.
35
+ - Root `AGENTS.md` is only written when explicitly requested (`--tools agents` or `--tools all`).
36
+
37
+ ## The Workflow
38
+
39
+ ```
40
+ gsdd init -> bootstrap (create .planning/, copy templates, generate skills/adapters)
41
+ /gsdd:new-project -> .planning/SPEC.md + .planning/ROADMAP.md (questioning + codebase audit + research)
42
+ /gsdd:plan N -> phases/N/PLAN.md (task breakdown + research)
43
+ /gsdd:execute N -> code changes (plan execution with quality gates)
44
+ /gsdd:verify N -> VERIFICATION.md (goal-backward validation)
45
+ ... repeat plan/execute/verify per phase ...
46
+ /gsdd:quick -> .planning/quick/NNN/ (sub-hour task outside phases)
47
+ /gsdd:pause -> .planning/.continue-here.md (session checkpoint)
48
+ /gsdd:resume -> restore context, route to next action
49
+ /gsdd:progress -> show status, route to next action
50
+ ```
51
+
52
+ ## Current Status (updated 2026-03-20)
53
+
54
+ | Workflow | Status | Notes |
55
+ |----------|--------|-------|
56
+ | `new-project.md` | [OK] Defined, source-audited | Covers greenfield + brownfield + milestone context |
57
+ | `plan.md` | [OK] Defined, source-audited | Portable workflow defines the planner contract and supports independent plan checking through generated native adapters |
58
+ | `execute.md` | [OK] Source-audited | Mandatory read enforcement, auth-gate routing, deviation-rule examples, and substantive summary quality gate |
59
+ | `verify.md` | [OK] Source-audited | 5 gap closures against hardened verifier role contract: grouped-gap guidance, orphan detection, frontmatter enforcement, verification basis emphasis, requirements coverage chain |
60
+ | `audit-milestone.md` | [OK] Defined, source-audited | Aggregates phase verification, cross-phase integration audit, auth protection checks, requirement reconciliation, and orphan detection into `MILESTONE-AUDIT.md` |
61
+ | `quick.md` | [OK] | Quick-work lane for sub-hour tasks outside the phase cycle (D11) |
62
+ | `pause.md` | [OK] Source-audited | Session checkpoint writer with conversational handoff (D12) |
63
+ | `resume.md` | [OK] Source-audited | Session context restorer with priority-ordered routing (D12) |
64
+ | `progress.md` | [OK] Source-audited | Read-only status reporter with 6 named route branches, recent work, between-milestones detection (D12) |
65
+ | `map-codebase.md` | [OK] Defined, source-audited | Standalone codebase mapping/refresh |
66
+
67
+ Architecture notes:
68
+ - `bin/gsdd.mjs` remains the thin generator entrypoint, while vendor-specific rendering lives in adapter modules.
69
+ - Codex CLI uses the always-generated `.agents/skills/gsdd-*` surface as its entry path and can add a native `.codex/agents/gsdd-plan-checker.toml` checker agent.
70
+ - Portable lifecycle contracts now align to the roadmap template status grammar: `[ ]`, `[-]`, `[x]`.
71
+ - Phase verification and milestone integration audit are treated as separate concerns.
72
+ - Canonical role contracts use bounded sections, typed output examples, and checklist-driven completion where those structures materially improve downstream reliability.
73
+
74
+ ## Init Workflow Agent Count (by config)
75
+
76
+ | Mode | Mappers | Researchers | Synthesizer | Total |
77
+ |------|---------|-------------|-------------|-------|
78
+ | Brownfield, first run, research balanced/deep | 4 | 4 | 1 | 9 |
79
+ | Brownfield, first run, research fast | 4 | 4 | 0 (inline) | 8 |
80
+ | Brownfield, subsequent run, research balanced/deep | 0 (maps exist) | 4 | 1 | 5 |
81
+ | Greenfield, research balanced/deep | 0 | 4 | 1 | 5 |
82
+ | Greenfield, research fast | 0 | 4 | 0 (inline) | 4 |
83
+ | Any, no research | 0-4 | 0 | 0 | 0-4 |
84
+
85
+ Note: `parallelization: false` keeps the same mapper/researcher set but runs them sequentially.
86
+
87
+ ## What Gets Created (Project Output)
88
+
89
+ ```
90
+ .planning/
91
+ SPEC.md
92
+ ROADMAP.md
93
+ config.json
94
+ templates/ # copied from distilled/templates/
95
+ phases/ # phase plans and summaries
96
+ research/ # optional research outputs
97
+ .agents/skills/
98
+ gsdd-new-project/SKILL.md
99
+ gsdd-plan/SKILL.md
100
+ gsdd-execute/SKILL.md
101
+ gsdd-verify/SKILL.md
102
+ gsdd-audit-milestone/SKILL.md
103
+ gsdd-quick/SKILL.md
104
+ gsdd-pause/SKILL.md
105
+ gsdd-resume/SKILL.md
106
+ gsdd-progress/SKILL.md
107
+ gsdd-map-codebase/SKILL.md
108
+ .claude/agents/
109
+ gsdd-plan-checker.md # native-capable checker agent generated from the active plan-checker contract
110
+ .claude/commands/
111
+ gsdd-plan.md # compatibility alias to the Claude skill-primary plan entry
112
+ .claude/skills/
113
+ gsdd-plan/SKILL.md # Claude-native skill-primary planner -> checker surface
114
+ .opencode/agents/
115
+ gsdd-plan-checker.md # native-capable checker agent generated from the active plan-checker contract
116
+ .opencode/commands/
117
+ gsdd-plan.md # OpenCode-native specialized planner -> checker command surface
118
+ .codex/agents/
119
+ gsdd-plan-checker.toml # Codex-native checker agent (read-only, high reasoning effort)
120
+ .planning/
121
+ quick/ # quick task directories and LOG.md
122
+ .continue-here.md # session checkpoint (created by pause)
123
+ ```
124
+
125
+ ## Files In This Framework
126
+
127
+ ```
128
+ distilled/
129
+ DESIGN.md # design decisions and rationale (28 decisions, evidence-backed)
130
+ SKILL.md # primary entry point (plain markdown)
131
+ workflows/
132
+ new-project.md
133
+ map-codebase.md
134
+ plan.md
135
+ progress.md
136
+ execute.md
137
+ verify.md
138
+ audit-milestone.md
139
+ quick.md
140
+ pause.md
141
+ resume.md
142
+ templates/
143
+ spec.md
144
+ roadmap.md
145
+ agents.md # full AGENTS.md template (for tool adapters)
146
+ agents.block.md # bounded block payload for root AGENTS.md insertion
147
+ delegates/ # delegate instruction files (copied to .planning/templates/delegates/)
148
+ mapper-tech.md
149
+ mapper-arch.md
150
+ mapper-quality.md
151
+ mapper-concerns.md
152
+ plan-checker.md
153
+ researcher-stack.md
154
+ researcher-features.md
155
+ researcher-architecture.md
156
+ researcher-pitfalls.md
157
+ researcher-synthesizer.md
158
+ research/
159
+ stack.md
160
+ features.md
161
+ architecture.md
162
+ pitfalls.md
163
+ summary.md
164
+ codebase/
165
+ stack.md
166
+ architecture.md
167
+ conventions.md
168
+ concerns.md
169
+ ```
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: GSDD (Spec-Driven Development)
3
+ description: Disciplined, lightweight workflow for AI-assisted development. Spec first, then build, then verify.
4
+ ---
5
+
6
+ <role>
7
+ You are an AI agent following the GSDD workflow. You are a disciplined engineer, not a code generator.
8
+ Your mandate: understand the problem deeply, specify what "done" looks like, implement with precision, and verify with rigor.
9
+ </role>
10
+
11
+ <principles>
12
+ 1. Spec first: do not write code without a written spec that defines "done".
13
+ 2. Clean commits: group changes logically following repo conventions. Do not bundle unrelated changes.
14
+ 3. Verify everything: verify observable success criteria, not vibes.
15
+ 4. Research when unsure: verify current docs and patterns before choosing an approach.
16
+ 5. Honest reporting: a clear failure report beats a false pass.
17
+ </principles>
18
+
19
+ <workflow>
20
+ The loop is:
21
+
22
+ ```
23
+ init -> [plan -> execute -> verify] x N phases -> done
24
+ ```
25
+
26
+ Read only the file for the phase you are in:
27
+ - new-project: `workflows/new-project.md`
28
+ - plan: `workflows/plan.md`
29
+ - execute: `workflows/execute.md`
30
+ - verify: `workflows/verify.md`
31
+ - quick: `workflows/quick.md`
32
+ </workflow>
33
+
34
+ <governance>
35
+ Mandatory:
36
+ - Read before you write. If `.planning/` exists, read `.planning/SPEC.md`, `.planning/ROADMAP.md`, `.planning/config.json`.
37
+ - Stay in scope. Implement only what the current phase plan describes.
38
+ - Never hallucinate. Confirm paths and APIs from repo or docs before use.
39
+ - Research-first when unfamiliar. Log evidence, then plan.
40
+ - Exists -> Substantive -> Wired gate before claiming done.
41
+ </governance>
42
+
43
+ <project_structure>
44
+ GSDD uses `.planning/` as the durable workspace:
45
+
46
+ ```
47
+ .planning/
48
+ SPEC.md
49
+ ROADMAP.md
50
+ config.json
51
+ templates/
52
+ phases/
53
+ research/
54
+ ```
55
+ </project_structure>
56
+
57
+ <adapters>
58
+ Recommended: generate adapters with `gsdd`:
59
+
60
+ ```bash
61
+ npx gsdd-cli init
62
+ npx gsdd-cli init --tools claude
63
+ npx gsdd-cli init --tools agents
64
+ ```
65
+
66
+ Behavior:
67
+ - Always: generates open-standard skills at `.agents/skills/gsdd-*/SKILL.md` by embedding `distilled/workflows/*.md`. This is also the primary Codex CLI surface.
68
+ - Optional: generates tool adapters (root `AGENTS.md`, Claude `.claude/skills` + `.claude/commands` alias + `.claude/agents`, OpenCode `.opencode/commands` + `.opencode/agents`).
69
+ - Deprecated compatibility: `--tools codex` does not generate `.codex/AGENTS.md`; Codex CLI should use the default skills directly.
70
+ - Root `AGENTS.md` is only written when explicitly requested (so we do not pollute existing user governance).
71
+ </adapters>
72
+
73
+ <templates>
74
+ Use templates from `.planning/templates/` (copied from `distilled/templates/`) when producing planning artifacts.
75
+
76
+ Core:
77
+ - `.planning/templates/spec.md` -> `.planning/SPEC.md`
78
+ - `.planning/templates/roadmap.md` -> `.planning/ROADMAP.md`
79
+
80
+ Research:
81
+ - `.planning/templates/research/*.md` -> `.planning/research/*.md`
82
+
83
+ Brownfield codebase mapping:
84
+ - `.planning/templates/codebase/*.md` -> `.planning/codebase/*.md`
85
+ </templates>
@@ -0,0 +1,90 @@
1
+ ## GSDD Governance (Generated)
2
+
3
+ This block is managed by `gsdd`. Do not edit inside the block directly.
4
+ Edit the source template in the GSDD framework instead.
5
+
6
+ ### What This Project Uses
7
+ - Framework: GSDD (Spec-Driven Development)
8
+ - Planning dir: `.planning/` (specs, roadmaps, plans, research, templates)
9
+ - Lifecycle: `bootstrap (gsdd init) -> new-project -> [plan -> execute -> verify] x N -> audit-milestone` for roadmap work
10
+ - Supporting workflows: quick (sub-hour tasks), map-codebase (codebase analysis), pause/resume (session management), progress (status query)
11
+
12
+ ### Rules You MUST Follow
13
+
14
+ 1. Never Skip The Workflow
15
+ - Roadmap work should follow: plan -> execute -> verify.
16
+ - Direct user requests do NOT need to be forced into a phase or plan unless the user explicitly wants roadmap tracking.
17
+ - Before coding roadmap work: read `.planning/SPEC.md`, `.planning/ROADMAP.md`, and the relevant phase plan if one exists.
18
+ - After coding: verify against the relevant success criteria before claiming done.
19
+
20
+ 2. Read Before You Write
21
+ - If `.planning/` exists, read in order:
22
+ - `.planning/SPEC.md`
23
+ - `.planning/ROADMAP.md`
24
+ - `.planning/config.json`
25
+ - The relevant phase plan in `.planning/phases/` when the work is roadmap-scoped
26
+ - If `.planning/` does not exist, the project has not been bootstrapped. Run `gsdd init`, then run the new-project workflow (`.agents/skills/gsdd-new-project/SKILL.md`).
27
+
28
+ 3. Stay In Scope (Zero Deviation)
29
+ - Implement ONLY what the approved plan or direct user request specifies.
30
+ - If you notice unrelated improvements, do not implement them. Record them as a TODO for a future phase.
31
+
32
+ Priority order when instructions conflict:
33
+ - Developer explicit instruction (highest)
34
+ - Current approved plan or direct task scope
35
+ - `.planning/SPEC.md`
36
+ - General best practices (lowest)
37
+
38
+ 4. Version Control Protocol
39
+ - Treat `.planning/config.json` -> `gitProtocol` as advisory guidance, not a mandatory naming template.
40
+ - Follow the existing repo or team git conventions first.
41
+ - Do not mention phase, plan, or task IDs in commit or PR names unless explicitly requested.
42
+ - Tests must pass before committing.
43
+
44
+ 5. Verify Your Own Work (Exists -> Substantive -> Wired)
45
+ Before reporting "done", verify each deliverable:
46
+ - Exists: artifact is present where the plan says it should be
47
+ - Substantive: real content/code, not placeholders or TODOs
48
+ - Wired: connected to the system (imported, called, rendered, tested)
49
+
50
+ 6. Research Before Unfamiliar Domains
51
+ If you are not confident about a domain/library/pattern:
52
+ - Stop and research first (docs + existing code).
53
+ - Do not assume training data is current.
54
+ - Cite sources in `.planning/research/` (or `.internal-research/` for framework work).
55
+
56
+ 7. Never Hallucinate Paths Or APIs
57
+ - Use only file paths you've confirmed exist.
58
+ - Use only APIs verified in docs or source.
59
+
60
+ 8. Adapter Architecture Rule
61
+ - Do not pollute core workflows (`distilled/workflows/*.md`) with vendor-specific syntax.
62
+ - Tool-specific adapters are generated in `bin/` (generators, not converters).
63
+
64
+ 9. Anti-YOLO
65
+ - Do not delete or rewrite code unless explicitly asked.
66
+ - If asked for analysis, answer first; propose changes separately.
67
+
68
+ ### Where The Workflows Live
69
+ - Primary lifecycle:
70
+ - `.agents/skills/gsdd-new-project/SKILL.md` — project initialization (spec + roadmap)
71
+ - `.agents/skills/gsdd-plan/SKILL.md` — phase planning with optional independent checking
72
+ - `.agents/skills/gsdd-execute/SKILL.md` — plan execution with quality gates
73
+ - `.agents/skills/gsdd-verify/SKILL.md` — phase goal-backward verification
74
+ - `.agents/skills/gsdd-audit-milestone/SKILL.md` — milestone integration audit
75
+ - Supporting workflows:
76
+ - `.agents/skills/gsdd-quick/SKILL.md` — sub-hour tasks outside the phase cycle
77
+ - `.agents/skills/gsdd-map-codebase/SKILL.md` — codebase analysis and refresh
78
+ - `.agents/skills/gsdd-pause/SKILL.md` — session checkpoint
79
+ - `.agents/skills/gsdd-resume/SKILL.md` — session context restore and routing
80
+ - `.agents/skills/gsdd-progress/SKILL.md` — read-only status and next-action routing
81
+
82
+ ### How To Invoke Workflows
83
+
84
+ How you run these workflows depends on your tool:
85
+
86
+ - **Claude Code / OpenCode:** Use slash commands — `/gsdd-new-project`, `/gsdd-plan`, `/gsdd-execute`, etc.
87
+ - **Codex CLI:** Use skill references — `$gsdd-new-project`, `$gsdd-plan`, `$gsdd-execute`, etc.
88
+ - **All other tools (Cursor, Copilot, Gemini, any AI agent):** Open the SKILL.md file listed above and follow its instructions. This AGENTS.md governance block keeps the agent aligned with GSDD discipline.
89
+
90
+ Start with the new-project workflow to produce `.planning/SPEC.md` and `.planning/ROADMAP.md`.
@@ -0,0 +1,13 @@
1
+ # AGENTS.md - GSDD Governance
2
+
3
+ This file is generated by `gsdd` when requested for runtimes that use AGENTS.md governance surfaces.
4
+ It provides the universal governance layer for agents that support the AGENTS.md convention.
5
+
6
+ See also:
7
+ - Skills (preferred workflow entrypoints): `.agents/skills/gsdd-*/SKILL.md`
8
+ - Planning workspace: `.planning/`
9
+
10
+ <!-- BEGIN GSDD -->
11
+ {{GSDD_BLOCK}}
12
+ <!-- END GSDD -->
13
+
@@ -0,0 +1,78 @@
1
+ # Authorization Matrix Template
2
+
3
+ > OWASP-style authorization matrix for systematic auth verification.
4
+ > Create `.planning/AUTH_MATRIX.md` using this template when your project has multiple user roles or protected resources.
5
+
6
+ ## When to Create This Matrix
7
+
8
+ Create an authorization matrix when your project has:
9
+ - Multiple user roles (e.g., anonymous, user, admin, owner)
10
+ - Protected resources that vary by role
11
+ - Ownership-scoped data (users can only access their own records)
12
+ - Admin or operator surfaces that must be restricted
13
+
14
+ Skip this matrix for single-role projects or projects with no auth requirements.
15
+
16
+ ## Matrix Format
17
+
18
+ Use the OWASP pivot format: rows are resources, columns are roles, cells are permissions.
19
+
20
+ ### Permission Values
21
+
22
+ | Value | Meaning |
23
+ |-------|---------|
24
+ | ALLOW | Role can perform this action on any matching resource |
25
+ | DENY | Role must be explicitly rejected (not just "no route") |
26
+ | OWN | Role can perform this action only on resources they own |
27
+ | N/A | Action does not apply to this resource |
28
+
29
+ ### Matrix Table
30
+
31
+ ```markdown
32
+ | Resource | Action | anonymous | user | admin |
33
+ |----------|--------|-----------|------|-------|
34
+ | /login | POST | ALLOW | ALLOW| ALLOW |
35
+ | /profile | GET | DENY | OWN | ALLOW |
36
+ | /profile | PUT | DENY | OWN | ALLOW |
37
+ | /users | GET | DENY | DENY | ALLOW |
38
+ | /users | DELETE | DENY | DENY | ALLOW |
39
+ | /posts | GET | ALLOW | ALLOW| ALLOW |
40
+ | /posts | POST | DENY | ALLOW| ALLOW |
41
+ | /posts | DELETE | DENY | OWN | ALLOW |
42
+ ```
43
+
44
+ Adapt the table to your project's actual resources, actions, and roles. Add or remove columns as needed.
45
+
46
+ ## Sensitive Surfaces
47
+
48
+ The following resource categories MUST have matrix coverage when they exist in your project:
49
+
50
+ - **User-scoped data** (profiles, settings, personal records) — require OWN or DENY
51
+ - **Admin surfaces** (user management, system config, audit logs) — require DENY for non-admin roles
52
+ - **Financial data** (billing, payments, subscriptions) — require explicit DENY or OWN
53
+ - **Destructive actions** (delete, bulk operations, account removal) — require explicit role gates
54
+ - **API keys and credentials** — require DENY for non-owner roles
55
+
56
+ If a sensitive surface exists in your codebase but is missing from the matrix, the integration checker's narrative auth check (Step 4) will still flag it — Step 4 runs unconditionally regardless of whether this matrix exists. Step 4a only verifies cells that are already in the matrix.
57
+
58
+ ## How the Integration Checker Uses This Matrix
59
+
60
+ During milestone audits, the integration checker (Step 4a) will:
61
+
62
+ 1. Parse each row of the matrix table(s)
63
+ 2. For each cell (resource x role x expected permission):
64
+ - **ALLOW**: Verify the role can access the resource (no auth gate blocks it)
65
+ - **DENY**: Verify explicit rejection exists (middleware, guard, or policy denies access)
66
+ - **OWN**: Verify ownership check is enforced (not just auth, but scoped to the user's records)
67
+ 3. Report each cell as:
68
+ - **VERIFIED**: Implementation matches the matrix expectation
69
+ - **MISMATCH**: Implementation contradicts the matrix (e.g., DENY expected but no guard found)
70
+ - **UNTESTED**: Cannot determine from static analysis (e.g., dynamic policy evaluation)
71
+
72
+ The narrative auth check (Step 4) always runs regardless of whether this matrix exists.
73
+
74
+ ## File Location
75
+
76
+ Save your project's authorization matrix as `.planning/AUTH_MATRIX.md`.
77
+
78
+ The integration checker will automatically detect and consume it when present. No configuration needed.
@@ -0,0 +1,110 @@
1
+ # Codebase Architecture
2
+
3
+ **Analysis Date:** [YYYY-MM-DD]
4
+
5
+ <guidelines>
6
+ - This document is durable intent: boundaries, layering, entrypoints, and change-routing rules.
7
+ - Do NOT write a static directory tree. It rots. Instead: reference a few canonical entrypoints and show "where changes go".
8
+ - Every layer/abstraction must include concrete file paths.
9
+ - Include "where to add new code" rules. This prevents downstream agents from scattering logic across random files.
10
+ </guidelines>
11
+
12
+ ## Pattern Overview
13
+
14
+ Overall:
15
+ - [Pattern name]
16
+
17
+ Key characteristics:
18
+ - [Characteristic 1]
19
+ - [Characteristic 2]
20
+ - [Characteristic 3]
21
+
22
+ ## Layers (Boundaries)
23
+
24
+ Layer: [Layer name]
25
+ - Purpose: [What this layer does]
26
+ - Location: `[path(s)]`
27
+ - Owns: [What it is responsible for]
28
+ - Does NOT own: [Explicit non-responsibilities]
29
+ - Depends on: [What it uses]
30
+ - Used by: [What uses it]
31
+
32
+ ## Entry Points
33
+
34
+ Entrypoint: [Name]
35
+ - Location: `[path]`
36
+ - Triggers: [What invokes it]
37
+ - Responsibilities: [What it does]
38
+
39
+ ## Data Flow (One Or Two Canonical Flows)
40
+
41
+ Flow: [Name]
42
+ 1. [Step 1]
43
+ 2. [Step 2]
44
+ 3. [Step 3]
45
+
46
+ State management:
47
+ - [How state is handled]
48
+
49
+ ## Key Abstractions
50
+
51
+ Abstraction: [Name]
52
+ - Purpose: [What it represents]
53
+ - Examples: `[file paths]`
54
+ - Pattern: [Pattern used]
55
+
56
+ ## Error Handling Strategy
57
+
58
+ Strategy:
59
+ - [Approach]
60
+ - Examples: `[file paths]`
61
+
62
+ ## Cross-Cutting Concerns
63
+
64
+ Logging:
65
+ - [Approach] - examples: `[file paths]`
66
+
67
+ Validation:
68
+ - [Approach] - examples: `[file paths]`
69
+
70
+ Authentication/Authorization:
71
+ - [Approach] - examples: `[file paths]`
72
+
73
+ ## Change Routing (Where To Add New Code)
74
+
75
+ When making a change, follow these rules:
76
+
77
+ | Change type | Add/modify here | Do NOT do this | Example paths |
78
+ |---|---|---|---|
79
+ | New API endpoint / handler | [file or folder pattern] | [anti-pattern] | `[paths]` |
80
+ | New domain capability / business rule | [location] | [anti-pattern] | `[paths]` |
81
+ | New UI page / screen | [location] | [anti-pattern] | `[paths]` |
82
+ | New background job / worker | [location] | [anti-pattern] | `[paths]` |
83
+ | DB schema change / migration | [location] | [anti-pattern] | `[paths]` |
84
+ | New external integration | [location] | [anti-pattern] | `[paths]` |
85
+ | Adding a new module/package | [location] | [anti-pattern] | `[paths]` |
86
+
87
+ <good_examples>
88
+ Example (good):
89
+ - "New routes live in `src/server/routes/*.ts` and are registered in `src/server/app.ts`. Business rules never go in route handlers; they live in `src/domain/*`. See `src/server/routes/users.ts` and `src/domain/user/createUser.ts`."
90
+
91
+ Example (bad):
92
+ - "Add routes wherever it makes sense."
93
+ </good_examples>
94
+
95
+ ## Golden Files Per Layer
96
+
97
+ For each architectural layer, identify the single most-instructive file using inbound import frequency as the signal: the most-imported file in a layer is the most stable and most understood.
98
+
99
+ | Layer | Golden File | Why |
100
+ |-------|-------------|-----|
101
+ | [Layer name] | `[path/to/file.ts]` | [Why it's the most-imported / most-instructive for this layer] |
102
+ | [Layer name] | `[path/to/file.ts]` | [Why] |
103
+ | [Layer name] | `[path/to/file.ts]` | [Why] |
104
+
105
+ To find the most-imported file in a layer: grep for imports of each candidate file and count occurrences. The highest count is the golden file.
106
+
107
+ ---
108
+
109
+ *Architecture analysis: [date]*
110
+
@@ -0,0 +1,95 @@
1
+ # Codebase Concerns
2
+
3
+ **Analysis Date:** [YYYY-MM-DD]
4
+
5
+ <guidelines>
6
+ - Every concern must include concrete file paths.
7
+ - Be specific with measurements (e.g., "p95 500ms") not adjectives ("slow").
8
+ - Include reproduction steps for bugs, and "safe change" advice for fragile areas.
9
+ - This document is about risk and leverage: what breaks, where, and how to change safely.
10
+ </guidelines>
11
+
12
+ ## Tech Debt
13
+
14
+ Area/component: [Name]
15
+ - Issue: [What's the shortcut/workaround]
16
+ - Files: `[file paths]`
17
+ - Impact: [What breaks or degrades]
18
+ - Fix approach: [How to address it]
19
+
20
+ ## Known Bugs
21
+
22
+ Bug: [Description]
23
+ - Symptoms: [What happens]
24
+ - Files: `[file paths]`
25
+ - Trigger: [How to reproduce]
26
+ - Workaround: [If any]
27
+
28
+ ## Security Considerations
29
+
30
+ Area: [Name]
31
+ - Risk: [What could go wrong]
32
+ - Files: `[file paths]`
33
+ - Current mitigation: [What's in place]
34
+ - Recommendations: [What should be added]
35
+
36
+ ## Performance Bottlenecks
37
+
38
+ Operation: [Name]
39
+ - Problem: [What is slow]
40
+ - Files: `[file paths]`
41
+ - Measurement: [numbers, if known]
42
+ - Suspected cause: [why]
43
+ - Improvement path: [how]
44
+
45
+ ## Fragile Areas
46
+
47
+ Component/module: [Name]
48
+ - Files: `[file paths]`
49
+ - Why fragile: [what makes it break easily]
50
+ - Safe modification: [how to change safely]
51
+ - Test coverage: [gaps]
52
+
53
+ ## Dependency Risks
54
+
55
+ Dependency: [Package/service]
56
+ - Risk: [what is wrong]
57
+ - Impact: [what breaks]
58
+ - Mitigation: [what to do]
59
+
60
+ ## Missing Critical Features (If Any)
61
+
62
+ Feature gap: [Name]
63
+ - Problem: [what is missing]
64
+ - Blocks: [what can't be done]
65
+
66
+ ## Test Coverage Gaps
67
+
68
+ Untested area: [Name]
69
+ - What's not tested: [specific functionality]
70
+ - Files: `[file paths]`
71
+ - Risk: [what could break unnoticed]
72
+ - Priority: [High/Medium/Low]
73
+
74
+ <good_examples>
75
+ Example (good):
76
+ - "Auth refresh tokens are stored unencrypted in `src/auth/tokenStore.ts` and logged in `src/auth/logger.ts` (risk: credential leakage). Fix: remove token logging and encrypt at rest. Repro: enable debug logging and observe tokens in logs."
77
+ - "Checkout endpoint p95 is 1.8s in staging due to N+1 queries in `src/db/orders.ts` (see `getOrdersForUser`). Fix: batch query and add integration test asserting query count."
78
+ </good_examples>
79
+
80
+ ## Downstream Impact Ranking
81
+
82
+ Rank the top 3 concerns by how much future work they block. Use the Change Routing table in ARCHITECTURE.md as reference: concerns that block multiple change-routing rows rank highest.
83
+
84
+ | Rank | Concern | Blocks | Severity | Fix effort |
85
+ |------|---------|--------|----------|------------|
86
+ | 1 | [Concern name] | [Which change types from ARCHITECTURE.md this blocks] | critical/moderate/minor | [small/medium/large] |
87
+ | 2 | [Concern name] | [Blocks] | [Severity] | [Effort] |
88
+ | 3 | [Concern name] | [Blocks] | [Severity] | [Effort] |
89
+
90
+ Ranking heuristic: a concern that blocks 3 change-routing rows ranks above one that blocks 1, even if the latter is more severe in isolation.
91
+
92
+ ---
93
+
94
+ *Concerns audit: [date]*
95
+