@luizsantiago/spec-guardrails 3.0.1

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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -0
  3. package/index.js +335 -0
  4. package/lib/archive.js +208 -0
  5. package/lib/assets.js +145 -0
  6. package/lib/brownfield.js +446 -0
  7. package/lib/config.js +293 -0
  8. package/lib/constants.js +262 -0
  9. package/lib/cursorrules.js +92 -0
  10. package/lib/delta-merge.js +248 -0
  11. package/lib/doctor.js +343 -0
  12. package/lib/download.js +133 -0
  13. package/lib/feature.js +272 -0
  14. package/lib/fs-utils.js +114 -0
  15. package/lib/gates.js +138 -0
  16. package/lib/install.js +140 -0
  17. package/lib/memory.js +34 -0
  18. package/lib/next-steps.js +50 -0
  19. package/lib/presets.js +176 -0
  20. package/lib/project-rules.js +210 -0
  21. package/lib/specs-utils.js +117 -0
  22. package/lib/token-cost.js +124 -0
  23. package/package.json +46 -0
  24. package/rules/engineering-baseline.mdc +56 -0
  25. package/scripts/_common.py +356 -0
  26. package/scripts/analyze_artifacts.py +187 -0
  27. package/scripts/check_commit.py +140 -0
  28. package/scripts/lessons.py +447 -0
  29. package/scripts/loop_plan.py +217 -0
  30. package/scripts/validate_spec.py +345 -0
  31. package/scripts/validate_state.py +385 -0
  32. package/scripts/validate_tasks.py +379 -0
  33. package/skills/agent-architecture.md +221 -0
  34. package/skills/appsec.md +83 -0
  35. package/skills/code-simplify.md +49 -0
  36. package/skills/engineering-standards.md +98 -0
  37. package/skills/git-handoff.md +213 -0
  38. package/skills/qa-strategy.md +83 -0
  39. package/skills/references/analyze.md +56 -0
  40. package/skills/references/archive.md +60 -0
  41. package/skills/references/constitution.md +66 -0
  42. package/skills/references/context-limits.md +73 -0
  43. package/skills/references/converge.md +47 -0
  44. package/skills/references/design.md +88 -0
  45. package/skills/references/discuss.md +68 -0
  46. package/skills/references/explore.md +61 -0
  47. package/skills/references/implement.md +175 -0
  48. package/skills/references/lessons.md +71 -0
  49. package/skills/references/memory.md +98 -0
  50. package/skills/references/project-init.md +62 -0
  51. package/skills/references/quick-mode.md +84 -0
  52. package/skills/references/specify.md +144 -0
  53. package/skills/references/sub-agents.md +117 -0
  54. package/skills/references/tasks.md +178 -0
  55. package/skills/references/validate.md +210 -0
  56. package/skills/security-review.md +120 -0
  57. package/skills/ship-ready.md +50 -0
  58. package/skills/task-graph-engineering.md +180 -0
  59. package/templates/GETTING_STARTED.md +61 -0
  60. package/templates/config.yaml.example +28 -0
  61. package/templates/presets/default.yaml +16 -0
  62. package/templates/presets/node-ts.yaml +22 -0
  63. package/templates/presets/python.yaml +22 -0
@@ -0,0 +1,49 @@
1
+ # Code Simplify
2
+
3
+ Lean pass to reduce complexity **without changing behavior**. Complements Execute adequacy A–D and the standing Definition of Done in `engineering-standards.md`.
4
+
5
+ **Judgment only.** `validate_state.py` does not require a simplify step. Skip with a one-line reason when unused.
6
+
7
+ ## When to Use
8
+
9
+ Load when **any** of:
10
+
11
+ - After adequacy **A–D** are green on a **Medium+** task and the diff looks denser than needed
12
+ - Owner asks to simplify, clean up, or refactor with **no behavior change**
13
+
14
+ ## When NOT to Use
15
+
16
+ Quick one-liners, first RED/GREEN of a task, or when behavior must change (that is a new task / Spec Deviation). Never load in the same working set as `appsec.md`, `qa-strategy.md`, or `ship-ready.md`.
17
+
18
+ ## Procedure
19
+
20
+ 1. **Freeze behavior** — suite / task `Gate` already green; do not start from a red tree.
21
+ 2. **Target only this task’s `Files`** — no drive-by modules.
22
+ 3. **Simplify** — naming, extract obvious duplication, drop dead code/debug; prefer clarity over cleverness.
23
+ 4. **Re-run the same `Gate`** — if anything fails, revert the simplify diff.
24
+ 5. **Commit separately** when non-trivial (`refactor(scope): …`), still Conventional Commits.
25
+
26
+ ## Anti-rationalizations
27
+
28
+ | Excuse | Response |
29
+ | --- | --- |
30
+ | "While I'm here, change the API" | Behavior change needs a task / spec — not this skill |
31
+ | "Tests will catch it later" | Re-run `Gate` before commit |
32
+ | "Bigger cleanup across the package" | Out of `Files` — Deferred Ideas in `STATE.md` |
33
+
34
+ ## Output shape
35
+
36
+ ```markdown
37
+ ## Code simplify
38
+ - Applied: yes | skipped — [reason]
39
+ - Files: [paths]
40
+ - Gate: [command] → pass
41
+ - Notes: [optional one line]
42
+ ```
43
+
44
+ ## Related
45
+
46
+ - `references/implement.md` — per-task cycle; offer this skill after A–D on Medium+
47
+ - `engineering-standards.md` — Definition of Done
48
+ - `references/context-limits.md` — at most one conditional sister
49
+ - `ship-ready.md` — launch checklist (separate trigger; never together)
@@ -0,0 +1,98 @@
1
+ # Engineering Standards
2
+
3
+ Cross-cutting engineering policies for all implementation and verification work.
4
+ Apply during **Execute** and **Verify** phases, and whenever writing or reviewing code.
5
+
6
+ ## When to Use
7
+
8
+ - Implementing features (`/loop`)
9
+ - Reviewing code (`/verify`)
10
+ - Fixing bugs, refactors, or dependency updates
11
+ - Any task that touches source code, tests, or infrastructure
12
+
13
+ ## Artifact Language
14
+
15
+ Every project artifact is written in **English**: source code, tests, comments and docstrings, commit messages, PR titles and descriptions, `.specs/` documents, and identifier names.
16
+
17
+ Chat language is a personal preference, not guardrails rule. Set it as a global rule in your agent settings if you want replies in another language.
18
+
19
+ ## Secure Coding
20
+
21
+ - **Never commit secrets** — API keys, tokens, passwords, private keys belong in env vars or secret managers.
22
+ - **Validate all inputs** — sanitize user input; use parameterized queries; avoid string concatenation in SQL.
23
+ - **Fail closed** — auth/authz errors must deny access; never fall back to permissive defaults.
24
+ - **Least privilege** — minimal scopes for tokens, IAM roles, and database users.
25
+ - **Dependencies** — prefer well-maintained packages; run audit before adding; pin versions in lockfiles.
26
+ - **Error handling** — no silent swallow; log without PII or secrets.
27
+ - **HTTPS only** — no plaintext credentials or sensitive data over HTTP.
28
+
29
+ ## Code Quality
30
+
31
+ - **Follow existing conventions** — read surrounding code before adding new patterns.
32
+ - **Surgical changes** — touch only the files the current task requires.
33
+ - **No scope creep** — good ideas outside the task go to `.specs/STATE.md` under Deferred Ideas, never into the diff.
34
+ - **Small, focused diffs** — one logical change per commit; avoid drive-by refactors.
35
+ - **DRY with judgment** — extract duplication when it improves clarity, not prematurely.
36
+ - **Explicit over clever** — readable code beats clever one-liners.
37
+ - **Types & lint** — respect TypeScript strict mode, ESLint, Prettier, or project equivalents.
38
+ - **Dead code** — remove unused imports, variables, and commented-out blocks.
39
+
40
+ ## Testing Standards
41
+
42
+ - Tests derived from acceptance criteria (see `agent-architecture.md`).
43
+ - Cover happy path, edge cases, and failure modes.
44
+ - No flaky tests — isolate external dependencies with mocks/fakes.
45
+ - Assert behavior, not implementation details (unless testing internals is intentional).
46
+ - Test names describe scenario and expected outcome in English.
47
+ - **Never weaken a test to make a gate pass** — no skipping, deleting, or loosening assertions.
48
+
49
+ ## Definition of Done (standing bar)
50
+
51
+ Project-wide readiness — **judgment**, not `validate_state.py`. Clear acceptance criteria **and**: tests for this change pass; diff stays in task `Files`; lint/types if the project has them; no secrets/PII in source or logs; no debug dumps or dead commented code; honest Gaps (never PASS with open gaps).
52
+
53
+ ## Parallel Work Guardrails
54
+
55
+ - **One writer per file** — no two agents or jobs mutate the same file in the same round (see `task-graph-engineering.md`)
56
+ - **Disjoint ownership** — parallel tasks must touch different files or modules
57
+
58
+ ## Git & PR Hygiene
59
+
60
+ ```
61
+ feat(scope): add user authentication
62
+ fix(api): handle null response from payment gateway
63
+ docs(readme): update install instructions
64
+ test(auth): add session expiry edge case
65
+ ```
66
+
67
+ Validate the message before committing:
68
+
69
+ ```bash
70
+ python3 .specs/guardrails/scripts/check_commit.py --message "feat(auth): add token refresh"
71
+ ```
72
+
73
+ Optionally wire it as a git `commit-msg` hook so the rule holds without agent involvement.
74
+
75
+ - One concern per PR when possible.
76
+ - Link to spec requirement IDs (e.g. `REQ-003`) in PR description.
77
+ - Include test evidence (file:line) for each REQ addressed — not just a summary.
78
+ - Never force-push shared branches without coordination (Tier 2).
79
+ - **Git blast radius (tiers)** — Tier 0 local work is authorized by spec/tasks approval. Tier 1 (`push`, PR) and Tier 2 (merge, deploy, force-push) require explicit owner go-ahead. See `git-handoff.md`.
80
+
81
+ ## Logging & Observability
82
+
83
+ - Structured logs where the project supports them.
84
+ - Include correlation/request IDs in server-side logs.
85
+ - No secrets, tokens, or full PII in logs.
86
+ - Metrics and traces for critical paths when infrastructure allows.
87
+
88
+ ## Related Skills
89
+
90
+ - `agent-architecture.md` — SDD hub, execution contract, gates
91
+ - `references/implement.md` — per-task execution cycle
92
+ - `security-review.md` — deep checklist for `/verify` phase
93
+ - `git-handoff.md` — git sync and session handoff for `.specs/`
94
+ - `task-graph-engineering.md` — task DAG and parallelism rules
95
+
96
+ ## Related Rules
97
+
98
+ Project rules: `.cursor/rules/engineering-baseline.mdc` (always applied in Cursor).
@@ -0,0 +1,213 @@
1
+ # Git Handoff
2
+
3
+ Version project memory and spec artifacts in git at phase boundaries and session end.
4
+ Sister skill to `agent-architecture.md` — SDD defines *what* to build; this skill defines *when and how* to persist progress in git.
5
+
6
+ ## When to Use
7
+
8
+ - End of any agent session (mandatory handoff)
9
+ - After **Specify**, **Tasks**, or **Verify** phases complete
10
+ - Before switching branches, agents, or human reviewers
11
+ - When `STATE.md` or `.specs/features/` changed materially
12
+
13
+ ## Resume: Reconcile Before Trusting STATE
14
+
15
+ The handoff snapshot can be stale. At session start, reconcile it against git — **evidence wins**:
16
+
17
+ ```bash
18
+ git branch --show-current
19
+ git status --porcelain
20
+ git log --oneline -10
21
+ ```
22
+
23
+ Compare with `tasks.md` checkboxes. If commits exist for tasks STATE lists as pending, update STATE before doing anything else. Full procedure: `references/memory.md`.
24
+
25
+ ## Sister Skills (use together)
26
+
27
+ | Skill | Role |
28
+ | --- | --- |
29
+ | `agent-architecture.md` | Process — Specify → Verify workflow |
30
+ | `engineering-standards.md` | Quality — secure coding, commit format, artifact language |
31
+ | `security-review.md` | Verification — OWASP checklist for `/verify` |
32
+ | `task-graph-engineering.md` | Topology — task DAG and parallelism |
33
+ | **`git-handoff.md`** | **Persistence — git sync for `.specs/` and handoff** |
34
+
35
+ ## What to Commit
36
+
37
+ ### Always commit (project memory)
38
+
39
+ ```
40
+ .specs/STATE.md
41
+ .specs/LESSONS.md
42
+ .specs/lessons.json
43
+ .specs/project/**/*
44
+ .specs/features/**/*
45
+ .specs/quick/**/*
46
+ .specs/guardrails/scripts/**/*
47
+ ```
48
+
49
+ Treat `.specs/` as **versioned product documentation**, not ephemeral notes. The gate scripts under `.specs/guardrails/scripts/` are committed on purpose — the team and CI run the same gates as the agent.
50
+
51
+ ### Never commit via handoff
52
+
53
+ ```
54
+ .cursor/skills/ # installed by spec-guardrails; upstream is spec-guardrails repo
55
+ .claude/skills/
56
+ .cursor/rules/ # unless team customized — then commit intentionally
57
+ node_modules/
58
+ .env, secrets, credentials
59
+ ```
60
+
61
+ ### Code commits
62
+
63
+ Follow `engineering-standards.md` — separate commits for code vs docs when possible.
64
+
65
+ ## Git Blast Radius (Tiers)
66
+
67
+ Structural gates enforce artifact quality. Git tiers enforce **what leaves the machine**.
68
+
69
+ | Tier | Auto on phase trigger | Owner go-ahead |
70
+ | --- | --- | --- |
71
+ | **0 — Local** | `feature-init`, `git checkout -b feat/NNN-slug`, commits for spec/tasks/code/STATE | — |
72
+ | **1 — Share** | — | `git push`, open/update PR |
73
+ | **2 — External** | — | merge, deploy, force-push, production data |
74
+
75
+ ### Tier 0 triggers (automatic — no ask)
76
+
77
+ | Phase complete | Git action |
78
+ | --- | --- |
79
+ | `/specify` start | `feature-init "<description>"` → folder + branch + STATE |
80
+ | Spec approved | Commit `spec.md` (+ `context.md` if Discuss ran) |
81
+ | Tasks approved | Commit `tasks.md` (+ `task-graph.md` if created) |
82
+ | Execute (each task) | Atomic code commit per task |
83
+ | Verify PASS | Commit `validation.md` |
84
+ | `/handoff` | Commit `.specs/` snapshot |
85
+ | `/archive` | Commit ROADMAP + domain spec merge |
86
+
87
+ **Quick tier:** no dedicated branch — commit on current branch.
88
+
89
+ ### Tier 1 — share (explicit once per feature)
90
+
91
+ Stop after local commits. Owner says "push" / "open PR" before:
92
+
93
+ ```bash
94
+ git push -u origin feat/003-chat-system
95
+ ```
96
+
97
+ ### Tier 2 — external (explicit per action)
98
+
99
+ Merge, deploy, tags, force-push — each needs a separate go-ahead. `ship-ready.md` documents readiness; it never authorizes push.
100
+
101
+ ## Handoff Workflow (`/handoff`)
102
+
103
+ Run at session end or phase milestone:
104
+
105
+ ### 1. Update memory
106
+
107
+ Use this structure in `.specs/STATE.md`:
108
+
109
+ ```markdown
110
+ ## Active Feature
111
+ - Feature: [name]
112
+ - Phase: [Specify|Design|Tasks|Execute|Verify]
113
+ - Branch: [branch-name]
114
+
115
+ ## Decisions (this session)
116
+ - [decision and rationale]
117
+
118
+ ## Next Step (single item)
119
+ - [ ] [one concrete action]
120
+
121
+ ## Blockers
122
+ - [open questions or dependencies]
123
+ ```
124
+
125
+ - Refresh all sections above each handoff
126
+ - Record a grounded lesson with `lessons.py add` if verification failed. Never hand-edit `LESSONS.md`.
127
+
128
+ ### 2. Validate before commit
129
+
130
+ - Run relevant tests / linters (operational harness — not self-declaration)
131
+ - Ensure no secrets in staged files
132
+ - Commit messages in **English** (Conventional Commits):
133
+ ```bash
134
+ python3 .specs/guardrails/scripts/check_commit.py --message "docs(spec): update STATE handoff for auth"
135
+ ```
136
+
137
+ ### 3. Stage and commit
138
+
139
+ ```bash
140
+ git add .specs/
141
+ git status # review — no secrets, no accidental paths
142
+ git commit -m "docs(spec): update STATE handoff for [feature]"
143
+ ```
144
+
145
+ ### 4. Do NOT auto-push (Tier 1)
146
+
147
+ Stop after commit. Owner handles `git push` and PRs (Tier 1).
148
+
149
+ ## Commit Messages by Phase
150
+
151
+ | Phase completed | Example commit |
152
+ | --- | --- |
153
+ | Specify | `docs(spec): add REQ-001 auth requirements` |
154
+ | Design | `docs(spec): design OAuth flow for auth feature` |
155
+ | Tasks | `docs(spec): task breakdown for auth feature` |
156
+ | Task graph | `docs(spec): add task graph for auth feature` |
157
+ | Verify | `docs(spec): validation report auth feature` |
158
+ | Session handoff | `docs(spec): update STATE handoff — auth in progress` |
159
+ | Lessons learned | `docs(spec): record lesson — JWT expiry edge case` |
160
+
161
+ ## Phase Boundary Rules
162
+
163
+ | Event | Git action |
164
+ | --- | --- |
165
+ | Spec approved | Commit `spec.md` (+ `context.md` when Discuss ran) |
166
+ | Tasks approved | Commit `tasks.md` (+ `task-graph.md` if created) |
167
+ | Verify passed | Commit `validation.md` after `validate_state.py` passes |
168
+ | Execute loop | Atomic code commits per task (existing Execute rules) |
169
+ | Session ends | `/handoff` — always update STATE + commit `.specs/` |
170
+
171
+ ## `.gitignore` Guidance
172
+
173
+ Ensure target projects **do not** ignore `.specs/`:
174
+
175
+ ```gitignore
176
+ # Keep .specs/ tracked — it is project memory
177
+ # DO NOT add: .specs/
178
+ ```
179
+
180
+ Agent tooling and Python bytecode stay ignored:
181
+
182
+ ```gitignore
183
+ .cursor/skills/
184
+ .claude/skills/
185
+ .specs/guardrails/scripts/__pycache__/
186
+ ```
187
+
188
+ The gate scripts themselves are committed; only their compiled bytecode is ignored.
189
+
190
+ ## Evidence-or-Zero for Handoff
191
+
192
+ A handoff is complete only when:
193
+
194
+ 1. `STATE.md` has a concrete "Next step" line
195
+ 2. `git log -1` shows the handoff commit
196
+ 3. Staged files were reviewed (no secrets)
197
+
198
+ Commit messages and every `.specs/` artifact are written in **English**.
199
+
200
+ ## Related Commands
201
+
202
+ | Command | Action |
203
+ | --- | --- |
204
+ | `/handoff` | End session — update STATE, commit `.specs/`, no push |
205
+ | `/sync-spec` | Commit current feature spec artifacts only (`spec.md`, `tasks.md`, `task-graph.md`, etc.) |
206
+ | `/verify` | After verify — commit `validation.md` (see `references/validate.md`) |
207
+
208
+ ## Related Skills
209
+
210
+ - `agent-architecture.md` — SDD hub, execution contract, gates
211
+ - `references/memory.md` — STATE semantics, decision log, reconcile protocol
212
+ - `engineering-standards.md` — commit format and blast radius
213
+ - `task-graph-engineering.md` — commit `task-graph.md` at phase boundaries
@@ -0,0 +1,83 @@
1
+ # QA Strategy
2
+
3
+ Lean product-QA pass for **Complex** work, multi-step user-facing flows, or explicit regression asks. Complements `/verify` evidence-or-zero and lean Interactive UAT — it does **not** rewrite those procedures.
4
+
5
+ **Judgment only.** `validate_state.py` does not require an `## QA` section. A skip with reason is valid. This skill does not prove product quality by itself; it focuses smoke, regression, and where bugs go.
6
+
7
+ ## When to Use
8
+
9
+ Load during `/verify` when **any** of:
10
+
11
+ - Hub tier is **Complex**
12
+ - User-facing flow with multiple observable steps (not a single static screen)
13
+ - Owner asked for regression / QA focus on this feature
14
+
15
+ If `appsec.md` also triggered: run AppSec **first**, drop it from context, **then** load this skill. Never hold AppSec and QA in the same working set.
16
+
17
+ ## When NOT to Use
18
+
19
+ Do **not** load on Quick, Simple one-file fixes, or Verify already covered by evidence-or-zero alone with no multi-step UI. Record:
20
+
21
+ `QA: skipped — no Complex tier, no multi-step UI, no explicit regression ask`
22
+
23
+ ## Relationship to Verify
24
+
25
+ | Concern | Where |
26
+ | --- | --- |
27
+ | Spec-anchored tests, sensor, evidence-or-zero, verdict | `references/validate.md` |
28
+ | OWASP checklist | `security-review.md` |
29
+ | Lean walkthrough script | `references/validate.md` § Interactive UAT |
30
+ | Smoke / regression focus / pyramid reminder | **This skill** (conditional) |
31
+
32
+ Do not duplicate the mutant catalog or UAT protocol here — link and apply.
33
+
34
+ ## Procedure
35
+
36
+ ### 1. Risk → cases
37
+
38
+ From `spec.md` REQs and the critical user path, list:
39
+
40
+ - **Smoke** — few checks that the feature’s happy path still works
41
+ - **Regression focus** — adjacent areas most likely broken by this diff
42
+ - **Edge** — only boundaries the spec actually constrains (no invented matrix)
43
+
44
+ Keep the list short. A TLC-style full coverage matrix is out of scope for this skill.
45
+
46
+ ### 2. Pyramid reminder
47
+
48
+ - **Unit** — domain rules and pure logic named by acceptance criteria
49
+ - **Integration** — API / DB / auth boundaries this feature touches
50
+ - **E2E** — at most the one critical happy path; do not E2E every REQ
51
+
52
+ Weak tests (`toBeDefined()`, empty 2xx) stay a Verify gap — see `validate.md`.
53
+
54
+ ### 3. Bug vs Gaps
55
+
56
+ | Finding | Treat as |
57
+ | --- | --- |
58
+ | Product behavior wrong vs spec / UAT | **Bug** → fix task under Execute |
59
+ | Missing `file:line`, weak assertion, sensor, open Gaps | **Verify Gap** → catalog in `validate.md` |
60
+ | Security checklist / AppSec fail | Security / AppSec path — not a QA label |
61
+
62
+ ### 4. UAT
63
+
64
+ If Complex + user-facing, follow **Interactive UAT** in `validate.md` after this QA pass (or as the last Verify step). Do not redefine severity tables here.
65
+
66
+ ## Output shape
67
+
68
+ ```markdown
69
+ ## QA
70
+ - Applied: yes | skipped — [reason]
71
+ - Smoke: [short list]
72
+ - Regression focus: [short list]
73
+ - Result: pass | fail | skipped
74
+ ```
75
+
76
+ `fail` → Gaps or fix tasks; do not leave `Verdict: PASS` while QA Result is fail (verifier judgment; not a structural gate).
77
+
78
+ ## Related
79
+
80
+ - `references/validate.md` — Verify + lean UAT; sequential AppSec → QA load rule
81
+ - `appsec.md` — conditional AppSec (run before this skill when both apply)
82
+ - `references/context-limits.md` — at most one conditional sister in context
83
+ - [Gate stability](https://github.com/luizssantiago92/spec-guardrails/blob/main/prd/gate-stability.md) — QA / UAT are non-guarantees
@@ -0,0 +1,56 @@
1
+ # Analyze
2
+
3
+ Cross-artifact consistency check before implementation.
4
+
5
+ ## When to Use
6
+
7
+ - After Tasks are drafted, before owner approves them
8
+ - After a large spec or tasks edit mid-feature
9
+ - When something "feels off" between spec, design, and tasks
10
+
11
+ ## When NOT to Use
12
+
13
+ - Before a spec exists
14
+ - Quick tier (no tasks.md)
15
+
16
+ ## Inputs
17
+
18
+ - `.specs/features/[feature]/spec.md`
19
+ - `.specs/features/[feature]/tasks.md` when present
20
+ - `.specs/features/[feature]/design.md` when present
21
+ - `.specs/STATE.md`
22
+
23
+ ## Output
24
+
25
+ Fix list in chat; update artifacts until the gate passes.
26
+
27
+ ## Procedure
28
+
29
+ 1. **Run the gate:**
30
+ ```bash
31
+ python3 .specs/guardrails/scripts/analyze_artifacts.py [feature]
32
+ npx @luizsantiago/spec-guardrails analyze-artifacts [feature]
33
+ ```
34
+ 2. **Fix every blocking error** — missing REQ coverage, orphan task Requirement IDs.
35
+ 3. **Resolve warnings** before owner approval:
36
+ - Open `[NEEDS CLARIFICATION]` markers
37
+ - STATE branch ≠ current git branch → reconcile per `memory.md`
38
+ - Empty `design.md` on Complex work → write design or drop the file
39
+ 4. **Re-run until PASS** (use `--strict` before final approval if warnings remain).
40
+
41
+ ## What the gate checks
42
+
43
+ | Check | Blocks? |
44
+ | --- | --- |
45
+ | Spec REQ without task coverage | Yes |
46
+ | Task Requirement references unknown REQ | Yes |
47
+ | Open `[NEEDS CLARIFICATION]` | Warn (`--strict` blocks) |
48
+ | STATE branch ≠ git branch | Warn |
49
+ | design.md nearly empty with tasks present | Warn |
50
+
51
+ ## Next
52
+
53
+ - PASS → present tasks to owner for approval, then `implement.md`
54
+ - Spec gaps → `specify.md`
55
+ - Architecture gaps → `design.md`
56
+ - Back → `tasks.md`
@@ -0,0 +1,60 @@
1
+ # Archive
2
+
3
+ Fold a verified feature back into long-lived project memory after Verify PASS.
4
+
5
+ ## When to Use
6
+
7
+ - `validate_state.py` passed with verdict PASS/PASSED
8
+ - Owner confirms the feature is complete
9
+ - Brownfield: delta specs need merging into domain truth
10
+
11
+ ## When NOT to Use
12
+
13
+ - Verify still failing or open Gaps
14
+ - Quick-tier work (optional — update ROADMAP only)
15
+
16
+ ## Inputs
17
+
18
+ - `.specs/features/[feature]/validation.md` (PASS)
19
+ - Feature artifacts: `spec.md`, optional `design.md`
20
+ - `.specs/project/ROADMAP.md` when present
21
+ - Domain specs under `.specs/domains/` when the project uses them
22
+
23
+ ## Output
24
+
25
+ - ROADMAP entry updated
26
+ - Optional domain spec merge (brownfield)
27
+ - STATE.md cleared for next feature
28
+ - Feature folder kept (historical record)
29
+
30
+ ## Procedure
31
+
32
+ 0. **Load project context (optional)** — `npx @luizsantiago/spec-guardrails phase-context archive` when `.specs/config.yaml` exists.
33
+ 1. **Confirm PASS** — `validate_state.py [feature]` exit 0.
34
+ 2. **Run archive CLI (Tier 0)** — merges domain truth and updates ROADMAP + STATE:
35
+ ```bash
36
+ npx @luizsantiago/spec-guardrails archive-feature [feature] [--domain <slug>]
37
+ ```
38
+ Flags: `--no-roadmap`, `--no-domain`, `--no-state` for partial runs; `--skip-verify` for recovery only.
39
+ 3. **Review domain diff** — owner approves the merged `.specs/domains/[domain]/spec.md` before Tier 1 push.
40
+ 4. **Commit** archive updates (Tier 0):
41
+ ```bash
42
+ git commit -m "docs(spec): archive 003-chat-system"
43
+ ```
44
+ 5. **Tier 1 optional** — owner may push branch / open PR separately.
45
+
46
+ ## Delta merge rules
47
+
48
+ | Section | Action |
49
+ | --- | --- |
50
+ | ADDED | Append new REQ blocks to domain spec |
51
+ | MODIFIED | Replace matching REQ blocks by ID |
52
+ | REMOVED | Delete REQ blocks listed by ID; note in ROADMAP |
53
+
54
+ Never merge without owner approval of the domain spec diff.
55
+
56
+ ## Next
57
+
58
+ - New work → `feature-init` then `specify.md`
59
+ - Push for review → owner go-ahead (Tier 1)
60
+ - Back → `validate.md`
@@ -0,0 +1,66 @@
1
+ # Constitution
2
+
3
+ Establish project governing principles that guide every phase.
4
+
5
+ ## When to Use
6
+
7
+ - First guardrails session on a new project
8
+ - Owner asks to define or refresh engineering principles
9
+ - Before the first Medium+ feature when `.specs/project/CONSTITUTION.md` is missing
10
+
11
+ ## When NOT to Use
12
+
13
+ - Per-feature decisions — use `context.md` or `design.md`
14
+ - Quick fixes with no principle impact
15
+
16
+ ## Inputs
17
+
18
+ - Owner's values (quality, testing, UX, performance, security posture)
19
+ - Existing README, ADRs, team standards
20
+ - `.specs/project/PROJECT.md` when present
21
+
22
+ ## Output
23
+
24
+ `.specs/project/CONSTITUTION.md`
25
+
26
+ ## Procedure
27
+
28
+ 1. **Interview lightly.** Ask what must never regress (tests, accessibility, latency, security).
29
+ 2. **Draft principles** as numbered, testable statements — not slogans.
30
+ 3. **Link to enforcement** — which gate or skill checks each principle (when applicable).
31
+ 4. **Get approval** before treating the constitution as binding.
32
+ 5. **Commit** with `docs(spec): add project constitution` (Tier 0).
33
+
34
+ ## Template
35
+
36
+ ```markdown
37
+ # Project Constitution
38
+
39
+ ## Principles
40
+
41
+ ### C-001: Test-first delivery
42
+ - Every feature change MUST include tests derived from acceptance criteria before merge.
43
+
44
+ ### C-002: Security baseline
45
+ - Auth and PII surfaces MUST pass OWASP review in `/verify`.
46
+
47
+ ### C-003: User-facing quality
48
+ - UI changes MUST remain accessible and consistent with existing patterns.
49
+
50
+ ## Non-Negotiables
51
+ - No secrets in git
52
+ - No skipping structural gates
53
+
54
+ ## Amendment
55
+ - Supersede with a new C-NNN entry and reference the old one — never edit history in place.
56
+ ```
57
+
58
+ ## Gate
59
+
60
+ No Python gate. Constitution compliance is checked by judgment in Specify, Design, Execute, and Verify.
61
+
62
+ ## Next
63
+
64
+ - First feature → `feature-init` then `specify.md`
65
+ - Principles constrain architecture → reference C-NNN in `design.md`
66
+ - Back → `agent-architecture.md`