@friedbotstudio/create-baseline 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.
- package/LICENSE +202 -0
- package/README.md +222 -0
- package/bin/cli.js +247 -0
- package/obj/template/.claude/agents/swarm-worker.md +52 -0
- package/obj/template/.claude/bin/LICENSE +201 -0
- package/obj/template/.claude/bin/NOTICE +48 -0
- package/obj/template/.claude/commands/approve-spec.md +29 -0
- package/obj/template/.claude/commands/approve-swarm.md +27 -0
- package/obj/template/.claude/commands/grant-commit.md +19 -0
- package/obj/template/.claude/commands/init-project.md +191 -0
- package/obj/template/.claude/hooks/artifact_template_guard.sh +141 -0
- package/obj/template/.claude/hooks/consent_gate_grant.sh +89 -0
- package/obj/template/.claude/hooks/destructive_cmd_guard.sh +42 -0
- package/obj/template/.claude/hooks/env_guard.sh +36 -0
- package/obj/template/.claude/hooks/git_commit_guard.sh +93 -0
- package/obj/template/.claude/hooks/harness_continuation.sh +121 -0
- package/obj/template/.claude/hooks/lib/__pycache__/resume_writer.cpython-314.pyc +0 -0
- package/obj/template/.claude/hooks/lib/common.sh +328 -0
- package/obj/template/.claude/hooks/lib/resume_writer.py +341 -0
- package/obj/template/.claude/hooks/lint_runner.sh +55 -0
- package/obj/template/.claude/hooks/memory_pre_compact.sh +36 -0
- package/obj/template/.claude/hooks/memory_session_start.sh +244 -0
- package/obj/template/.claude/hooks/memory_stop.sh +173 -0
- package/obj/template/.claude/hooks/plantuml_syntax_guard.sh +161 -0
- package/obj/template/.claude/hooks/process_lifecycle_guard.sh +89 -0
- package/obj/template/.claude/hooks/setup_guard.sh +50 -0
- package/obj/template/.claude/hooks/spec_approval_guard.sh +81 -0
- package/obj/template/.claude/hooks/spec_design_calls_guard.sh +183 -0
- package/obj/template/.claude/hooks/spec_diagram_presence_guard.sh +141 -0
- package/obj/template/.claude/hooks/swarm_approval_guard.sh +39 -0
- package/obj/template/.claude/hooks/swarm_boundary_guard.sh +136 -0
- package/obj/template/.claude/hooks/tdd_order_guard.sh +176 -0
- package/obj/template/.claude/hooks/test_runner.sh +75 -0
- package/obj/template/.claude/hooks/tests/fixtures/ac008_byte_equal_reference.txt +12 -0
- package/obj/template/.claude/hooks/tests/memory_session_start_test.sh +285 -0
- package/obj/template/.claude/hooks/track_guard.sh +127 -0
- package/obj/template/.claude/hooks/verify_pass_guard.sh +88 -0
- package/obj/template/.claude/memory/README.md +108 -0
- package/obj/template/.claude/memory/_pending.md +15 -0
- package/obj/template/.claude/memory/_resume.md +12 -0
- package/obj/template/.claude/memory/conventions.md +26 -0
- package/obj/template/.claude/memory/decisions.md +29 -0
- package/obj/template/.claude/memory/landmarks.md +26 -0
- package/obj/template/.claude/memory/landmines.md +27 -0
- package/obj/template/.claude/memory/libraries.md +27 -0
- package/obj/template/.claude/memory/pending-questions.md +28 -0
- package/obj/template/.claude/project.json +221 -0
- package/obj/template/.claude/settings.json +110 -0
- package/obj/template/.claude/skills/archive/SKILL.md +48 -0
- package/obj/template/.claude/skills/archive/archive.sh +145 -0
- package/obj/template/.claude/skills/audit-baseline/SKILL.md +80 -0
- package/obj/template/.claude/skills/audit-baseline/audit.sh +919 -0
- package/obj/template/.claude/skills/brd/SKILL.md +44 -0
- package/obj/template/.claude/skills/brd/template.md +83 -0
- package/obj/template/.claude/skills/chore/SKILL.md +99 -0
- package/obj/template/.claude/skills/claude-automation-recommender/LICENSE +202 -0
- package/obj/template/.claude/skills/claude-automation-recommender/NOTICE +69 -0
- package/obj/template/.claude/skills/claude-automation-recommender/SKILL.md +358 -0
- package/obj/template/.claude/skills/claude-automation-recommender/references/hooks-patterns.md +226 -0
- package/obj/template/.claude/skills/claude-automation-recommender/references/mcp-servers.md +263 -0
- package/obj/template/.claude/skills/claude-automation-recommender/references/plugins-reference.md +98 -0
- package/obj/template/.claude/skills/claude-automation-recommender/references/skills-reference.md +408 -0
- package/obj/template/.claude/skills/claude-automation-recommender/references/subagent-templates.md +181 -0
- package/obj/template/.claude/skills/code-structure/SKILL.md +204 -0
- package/obj/template/.claude/skills/commit/SKILL.md +21 -0
- package/obj/template/.claude/skills/copywriting/SKILL.md +252 -0
- package/obj/template/.claude/skills/copywriting/evals/evals.json +111 -0
- package/obj/template/.claude/skills/copywriting/references/ai-writing-detection.md +200 -0
- package/obj/template/.claude/skills/copywriting/references/copy-frameworks.md +344 -0
- package/obj/template/.claude/skills/copywriting/references/natural-transitions.md +272 -0
- package/obj/template/.claude/skills/design-ui/SKILL.md +175 -0
- package/obj/template/.claude/skills/design-ui/references/design-vs-development.md +89 -0
- package/obj/template/.claude/skills/design-ui/references/intent-table.md +64 -0
- package/obj/template/.claude/skills/design-ui/references/orchestration.md +121 -0
- package/obj/template/.claude/skills/design-ui/references/state-machine.md +125 -0
- package/obj/template/.claude/skills/document/SKILL.md +66 -0
- package/obj/template/.claude/skills/documentation/SKILL.md +50 -0
- package/obj/template/.claude/skills/harness/SKILL.md +169 -0
- package/obj/template/.claude/skills/humanizer/SKILL.md +489 -0
- package/obj/template/.claude/skills/humanizer/references/ai-writing-detection.md +208 -0
- package/obj/template/.claude/skills/impeccable/PROJECT_NOTES.md +22 -0
- package/obj/template/.claude/skills/impeccable/SKILL.md +153 -0
- package/obj/template/.claude/skills/impeccable/agents/openai.yaml +4 -0
- package/obj/template/.claude/skills/impeccable/reference/adapt.md +190 -0
- package/obj/template/.claude/skills/impeccable/reference/animate.md +173 -0
- package/obj/template/.claude/skills/impeccable/reference/audit.md +134 -0
- package/obj/template/.claude/skills/impeccable/reference/bolder.md +113 -0
- package/obj/template/.claude/skills/impeccable/reference/brand.md +104 -0
- package/obj/template/.claude/skills/impeccable/reference/clarify.md +174 -0
- package/obj/template/.claude/skills/impeccable/reference/cognitive-load.md +106 -0
- package/obj/template/.claude/skills/impeccable/reference/color-and-contrast.md +105 -0
- package/obj/template/.claude/skills/impeccable/reference/colorize.md +154 -0
- package/obj/template/.claude/skills/impeccable/reference/craft.md +138 -0
- package/obj/template/.claude/skills/impeccable/reference/critique.md +213 -0
- package/obj/template/.claude/skills/impeccable/reference/delight.md +302 -0
- package/obj/template/.claude/skills/impeccable/reference/distill.md +111 -0
- package/obj/template/.claude/skills/impeccable/reference/document.md +427 -0
- package/obj/template/.claude/skills/impeccable/reference/extract.md +70 -0
- package/obj/template/.claude/skills/impeccable/reference/harden.md +347 -0
- package/obj/template/.claude/skills/impeccable/reference/heuristics-scoring.md +234 -0
- package/obj/template/.claude/skills/impeccable/reference/interaction-design.md +195 -0
- package/obj/template/.claude/skills/impeccable/reference/layout.md +141 -0
- package/obj/template/.claude/skills/impeccable/reference/live.md +513 -0
- package/obj/template/.claude/skills/impeccable/reference/motion-design.md +99 -0
- package/obj/template/.claude/skills/impeccable/reference/onboard.md +234 -0
- package/obj/template/.claude/skills/impeccable/reference/optimize.md +258 -0
- package/obj/template/.claude/skills/impeccable/reference/overdrive.md +130 -0
- package/obj/template/.claude/skills/impeccable/reference/personas.md +178 -0
- package/obj/template/.claude/skills/impeccable/reference/polish.md +232 -0
- package/obj/template/.claude/skills/impeccable/reference/product.md +62 -0
- package/obj/template/.claude/skills/impeccable/reference/quieter.md +99 -0
- package/obj/template/.claude/skills/impeccable/reference/responsive-design.md +114 -0
- package/obj/template/.claude/skills/impeccable/reference/shape.md +136 -0
- package/obj/template/.claude/skills/impeccable/reference/spatial-design.md +100 -0
- package/obj/template/.claude/skills/impeccable/reference/teach.md +137 -0
- package/obj/template/.claude/skills/impeccable/reference/typeset.md +124 -0
- package/obj/template/.claude/skills/impeccable/reference/typography.md +159 -0
- package/obj/template/.claude/skills/impeccable/reference/ux-writing.md +107 -0
- package/obj/template/.claude/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
- package/obj/template/.claude/skills/impeccable/scripts/command-metadata.json +94 -0
- package/obj/template/.claude/skills/impeccable/scripts/design-parser.mjs +820 -0
- package/obj/template/.claude/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/obj/template/.claude/skills/impeccable/scripts/is-generated.mjs +69 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-accept.mjs +465 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-browser.js +4684 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-inject.mjs +436 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-poll.mjs +187 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-server.mjs +679 -0
- package/obj/template/.claude/skills/impeccable/scripts/live-wrap.mjs +395 -0
- package/obj/template/.claude/skills/impeccable/scripts/live.mjs +247 -0
- package/obj/template/.claude/skills/impeccable/scripts/load-context.mjs +93 -0
- package/obj/template/.claude/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/obj/template/.claude/skills/impeccable/scripts/pin.mjs +214 -0
- package/obj/template/.claude/skills/implement/SKILL.md +83 -0
- package/obj/template/.claude/skills/intake/SKILL.md +46 -0
- package/obj/template/.claude/skills/intake/template.md +61 -0
- package/obj/template/.claude/skills/integrate/SKILL.md +62 -0
- package/obj/template/.claude/skills/memory-flush/SKILL.md +172 -0
- package/obj/template/.claude/skills/memory-flush/sweep.py +286 -0
- package/obj/template/.claude/skills/memory-flush/tests/run.sh +327 -0
- package/obj/template/.claude/skills/prose/SKILL.md +119 -0
- package/obj/template/.claude/skills/rca/SKILL.md +42 -0
- package/obj/template/.claude/skills/rca/template.md +83 -0
- package/obj/template/.claude/skills/research/SKILL.md +75 -0
- package/obj/template/.claude/skills/scenario/SKILL.md +64 -0
- package/obj/template/.claude/skills/scout/SKILL.md +72 -0
- package/obj/template/.claude/skills/security/SKILL.md +75 -0
- package/obj/template/.claude/skills/simplify/SKILL.md +67 -0
- package/obj/template/.claude/skills/spec/SKILL.md +69 -0
- package/obj/template/.claude/skills/spec/template.md +274 -0
- package/obj/template/.claude/skills/spec-diagram-review/SKILL.md +81 -0
- package/obj/template/.claude/skills/spec-lint/SKILL.md +55 -0
- package/obj/template/.claude/skills/spec-lint/lint.sh +218 -0
- package/obj/template/.claude/skills/spec-render/SKILL.md +45 -0
- package/obj/template/.claude/skills/spec-render/render.sh +109 -0
- package/obj/template/.claude/skills/spec-traceability-review/SKILL.md +72 -0
- package/obj/template/.claude/skills/swarm-dispatch/SKILL.md +212 -0
- package/obj/template/.claude/skills/swarm-dispatch/swarm_merge.sh +154 -0
- package/obj/template/.claude/skills/swarm-plan/SKILL.md +90 -0
- package/obj/template/.claude/skills/swarm-plan/validate.sh +181 -0
- package/obj/template/.claude/skills/tdd/SKILL.md +100 -0
- package/obj/template/.claude/skills/technical-tutorials/SKILL.md +569 -0
- package/obj/template/.claude/skills/technical-tutorials/references/audience-context-README.md +53 -0
- package/obj/template/.claude/skills/technical-tutorials/references/audience-context.md +246 -0
- package/obj/template/.claude/skills/technical-tutorials/references/audience-example.md +175 -0
- package/obj/template/.claude/skills/technical-tutorials/references/audience-template.md +152 -0
- package/obj/template/.claude/skills/triage/SKILL.md +55 -0
- package/obj/template/.claude/skills/verify/SKILL.md +74 -0
- package/obj/template/.mcp.json +24 -0
- package/obj/template/CLAUDE.md +327 -0
- package/obj/template/docs/init/seed.md +585 -0
- package/obj/template/manifest.json +214 -0
- package/package.json +48 -0
- package/src/.mcp.template.json +24 -0
- package/src/.npmrc.template +2 -0
- package/src/CLAUDE.template.md +327 -0
- package/src/agents/swarm-worker.template.md +51 -0
- package/src/cli/conflict.js +31 -0
- package/src/cli/doctor.js +152 -0
- package/src/cli/install.js +93 -0
- package/src/cli/io.js +27 -0
- package/src/cli/manifest.js +38 -0
- package/src/cli/mcp.js +54 -0
- package/src/cli/merge.js +107 -0
- package/src/cli/plantuml.js +121 -0
- package/src/cli/util.js +10 -0
- package/src/memory/_pending.template.md +15 -0
- package/src/memory/_resume.template.md +12 -0
- package/src/memory/conventions.template.md +26 -0
- package/src/memory/decisions.template.md +29 -0
- package/src/memory/landmarks.template.md +26 -0
- package/src/memory/landmines.template.md +27 -0
- package/src/memory/libraries.template.md +27 -0
- package/src/memory/pending-questions.template.md +28 -0
- package/src/project.template.json +221 -0
- package/src/seed.template.md +585 -0
- package/src/settings.template.json +110 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scenario
|
|
3
|
+
owner: baseline
|
|
4
|
+
description: Write executable failing tests from a recipe handed to you by the main context. Used by `/tdd` Step 2 and ad-hoc when a phase needs tests-first to drive implementation. Decisions about which scenarios to cover, which categories matter, and which fixtures to use are made by the caller — this skill executes that recipe with code-structure discipline.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are executing a **decision the main context has already made**: "write these specific failing tests." You do not invent scope, expand categories, or rewrite test conventions to your taste.
|
|
8
|
+
|
|
9
|
+
# Mandatory first step
|
|
10
|
+
|
|
11
|
+
Invoke `Skill(code-structure)` before writing any test file. Test files are code; the layer/abstraction rules apply.
|
|
12
|
+
|
|
13
|
+
# Inputs the caller must provide
|
|
14
|
+
|
|
15
|
+
If any are missing, **stop and ask** — do not infer. Inference is the failure mode.
|
|
16
|
+
|
|
17
|
+
- **Recipe**: an explicit list of scenarios to write. Each entry has:
|
|
18
|
+
- `name` — `test_when_<condition>_then_<outcome>`
|
|
19
|
+
- `covers` — which spec AC or test-plan row it defends (or "regression" / "boundary" with explanation)
|
|
20
|
+
- `assertion` — what behavior it checks, in plain words
|
|
21
|
+
- `fixtures` — real fixtures to use (paths, factories, helpers)
|
|
22
|
+
- **Test target paths**: where each test file goes. The caller resolves this from `project.json → tdd.test_globs` and the source under test.
|
|
23
|
+
- **Test framework + style anchor**: a path to one or two existing tests in the project so you match imports, assertion idioms, and naming.
|
|
24
|
+
- **Out-of-scope scenarios**: the caller's explicit list of things NOT to test (this prevents you from over-producing).
|
|
25
|
+
|
|
26
|
+
# Method
|
|
27
|
+
|
|
28
|
+
1. Read the style anchor tests in full. Match imports, assertion idioms, fixture wiring, naming.
|
|
29
|
+
2. Read `MEMORY.md` at `.claude/skill-memory/scenario/` if present — accumulated test conventions for this repo (fixture locations, framework quirks, helper idioms).
|
|
30
|
+
3. For each entry in the recipe, write a test that:
|
|
31
|
+
- Uses the exact `name` the caller specified.
|
|
32
|
+
- Asserts the behavior described in `assertion`. No softer, no broader.
|
|
33
|
+
- Uses the `fixtures` provided. Real test DB, real filesystem temp dir. Mocks ONLY for: third-party HTTP APIs that can't run locally, system clock, OS randomness — each marked `# MOCK: <reason>`.
|
|
34
|
+
- Is the smallest test that demonstrates the assertion. No setup theater.
|
|
35
|
+
4. Confirm each test fails for the right reason: run the test command on the new files and grep for the new test names. Capture which ones FAIL (good — they're red, ready for `implement`) vs which ones PASS or ERROR (bad — surface to caller).
|
|
36
|
+
5. After authoring, append any new convention you discovered to `.claude/skill-memory/scenario/MEMORY.md` (file path conventions, fixture idioms, framework quirks). Do not record per-task scenario content there.
|
|
37
|
+
|
|
38
|
+
# Output
|
|
39
|
+
|
|
40
|
+
Return inline:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
# Scenarios — <slug or task id>
|
|
44
|
+
|
|
45
|
+
## Written
|
|
46
|
+
- <test_file_path>
|
|
47
|
+
- <test_name> — covers <recipe.covers> — RED | PASS_UNEXPECTEDLY | ERROR
|
|
48
|
+
|
|
49
|
+
## Did NOT write
|
|
50
|
+
- <recipe entry skipped> — reason
|
|
51
|
+
|
|
52
|
+
## Open questions for the caller
|
|
53
|
+
- <a question that the recipe didn't answer and you couldn't safely guess>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
# Constraints
|
|
57
|
+
|
|
58
|
+
- **You receive a recipe; you do not author scenario lists.** If the caller says "write tests for the auth flow" without listing scenarios, stop and ask for the recipe. Do not improvise.
|
|
59
|
+
- **Never write stub tests** (bodies that are `pass` or `assert true`).
|
|
60
|
+
- **Never write implementation code.** Tests only.
|
|
61
|
+
- **Never write a test file that won't be collectable.** If the source module doesn't exist yet, use `pytest.importorskip` / dynamic import / equivalent so the test loads and fails with a clear error.
|
|
62
|
+
- **Never modify other tests** to make yours pass.
|
|
63
|
+
- **Never approve specs or write to `docs/specs/`.**
|
|
64
|
+
- **Memory writes only to `.claude/skill-memory/scenario/`.** Test files go to project paths.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scout
|
|
3
|
+
owner: baseline
|
|
4
|
+
description: Workflow Phase 2 — Codebase Scouting and Constraint Discovery. Maps the relevant slice of the codebase for a given task. Produces a scout report at `docs/scout/<slug>.md` naming the files, modules, and patterns the proposed work touches or constrains. Executes in main context with full conversation visibility — no agent delegation.
|
|
5
|
+
argument-hint: "[optional: specific path to scope the scout]"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are mapping the slice of the codebase that matters for the current task — no more, no less. The scout report is consumed downstream by `/research` and `/spec`.
|
|
9
|
+
|
|
10
|
+
# Prereqs
|
|
11
|
+
|
|
12
|
+
- `.claude/state/workflow.json` exists.
|
|
13
|
+
- `intake` is in `completed` OR in `exceptions`. If neither, stop and direct the user to invoke `intake`.
|
|
14
|
+
|
|
15
|
+
# Inputs
|
|
16
|
+
|
|
17
|
+
- The intake document at `docs/intake/<slug>.md` — read **Problem** and **Goal** first; they define scope.
|
|
18
|
+
- The BRD at `docs/brd/<slug>.md` if present — In/Out scope lists.
|
|
19
|
+
- The codebase at the project root.
|
|
20
|
+
- Optional argument: a specific path to scope the scout.
|
|
21
|
+
|
|
22
|
+
If no intake exists (ad-hoc invocation), fall back to the parent task description and note in the report that the scout ran without a structured intake.
|
|
23
|
+
|
|
24
|
+
# Method
|
|
25
|
+
|
|
26
|
+
1. **Identify the nouns and verbs in the task.** Each is a search anchor.
|
|
27
|
+
2. **For each anchor:**
|
|
28
|
+
- `rg` (or `grep -r`) for the exact term, filtered to source directories.
|
|
29
|
+
- Read the top 3–5 hits with surrounding context.
|
|
30
|
+
- Follow imports/callers one hop out. Do not recurse further.
|
|
31
|
+
3. **Identify entry points** — HTTP routes, CLI commands, cron jobs, queue consumers — that would trigger the code path being modified.
|
|
32
|
+
4. **Identify existing tests** for the affected code. Note flaky/skipped ones.
|
|
33
|
+
5. **Note constraints** — config files, feature flags, migrations, deploy manifests that need lockstep changes.
|
|
34
|
+
|
|
35
|
+
# Output
|
|
36
|
+
|
|
37
|
+
Write the report to `docs/scout/<slug>.md` (create the directory if missing). Format:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
# Codebase Scout Report — <task>
|
|
41
|
+
|
|
42
|
+
## Primary touchpoints
|
|
43
|
+
- <path:line> — <role in the task>
|
|
44
|
+
- ...
|
|
45
|
+
|
|
46
|
+
## Entry points that reach this code
|
|
47
|
+
- <HTTP route / CLI cmd / job> at <path:line>
|
|
48
|
+
|
|
49
|
+
## Existing tests
|
|
50
|
+
- <test path> — <what it covers> — <passing? skipped?>
|
|
51
|
+
|
|
52
|
+
## Constraints and co-changes
|
|
53
|
+
- <config / migration / flag> — <why it's linked>
|
|
54
|
+
|
|
55
|
+
## Patterns in use here
|
|
56
|
+
- <1–3 sentences on the style the code follows, for the implementer>
|
|
57
|
+
|
|
58
|
+
## Risks / landmines
|
|
59
|
+
- <anything surprising: dead code, TODO comments, shims, version skew>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
After writing the file, append `"scout"` to `workflow.json → completed`.
|
|
63
|
+
|
|
64
|
+
Tell the user: `Scout report at <path>. Next: /research.`
|
|
65
|
+
|
|
66
|
+
# Constraints
|
|
67
|
+
|
|
68
|
+
- **Project source is read-only during scout.** Do not modify project files. The only write is to `docs/scout/<slug>.md`.
|
|
69
|
+
- **Do not speculate.** If a search turns up nothing, say so. Do not invent paths.
|
|
70
|
+
- **Keep the report under ~300 lines.** If the surface is genuinely larger, say so and propose a scoping split with the user.
|
|
71
|
+
- **Do not recommend an implementation approach.** That is `/research`'s job. Stick to what is.
|
|
72
|
+
- **No code generation.** No new files outside `docs/scout/`.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security
|
|
3
|
+
owner: baseline
|
|
4
|
+
description: Workflow Phase 8 (optional) — OWASP-aligned security review of pending code changes. Produces a prioritized findings report (Critical/High/Medium/Low) mapped to OWASP Top 10 and CWE IDs. Output at `docs/security/<slug>-<date>.md`. Read-only.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are conducting an evidence-based security review of pending code changes on the current branch. No fixes are applied here — fixes go through `/tdd` or a follow-up patch. This skill produces findings.
|
|
8
|
+
|
|
9
|
+
# Prereqs
|
|
10
|
+
|
|
11
|
+
- `simplify` in `completed`.
|
|
12
|
+
|
|
13
|
+
Per `workflow.json → exceptions`, security may be skipped for low-risk changes. Triage decides.
|
|
14
|
+
|
|
15
|
+
# Scope
|
|
16
|
+
|
|
17
|
+
Review the current branch's changes (git diff vs. base branch) and any files the user names explicitly. Do **not** review the full repo history.
|
|
18
|
+
|
|
19
|
+
Focus areas, in order:
|
|
20
|
+
|
|
21
|
+
1. **OWASP Top 10 (2021)** — A01 Broken Access Control, A02 Cryptographic Failures, A03 Injection, A04 Insecure Design, A05 Security Misconfiguration, A06 Vulnerable & Outdated Components, A07 Identification & Authentication Failures, A08 Software & Data Integrity Failures, A09 Logging & Monitoring Failures, A10 SSRF.
|
|
22
|
+
2. **Secrets hygiene** — hardcoded tokens, API keys, private keys, `.env` leakage.
|
|
23
|
+
3. **Input validation / output encoding** at trust boundaries (HTTP handlers, CLI entrypoints, message consumers, file parsers).
|
|
24
|
+
4. **AuthN / AuthZ** — missing checks, IDOR, privilege confusion, session fixation.
|
|
25
|
+
5. **Cryptography** — weak algorithms, hardcoded IVs, ECB mode, unsalted hashes, homegrown crypto.
|
|
26
|
+
6. **Dependency risk** — newly added packages; check known CVEs via context7 / WebFetch advisory DBs.
|
|
27
|
+
|
|
28
|
+
# Method
|
|
29
|
+
|
|
30
|
+
1. `git diff --stat` then `git diff` against the base branch.
|
|
31
|
+
2. For each changed file, identify the trust boundary (if any) and enumerate tainted data flows.
|
|
32
|
+
3. For any library's secure-usage API in doubt, hit the `context7` MCP — never recall crypto/auth APIs from training data.
|
|
33
|
+
4. Run existing security linters if configured (`bandit`, `semgrep`, `gosec`, `npm audit`, `pip-audit`) via Bash. Do **not** install new tools.
|
|
34
|
+
|
|
35
|
+
# Output
|
|
36
|
+
|
|
37
|
+
Write the report to `docs/security/<slug>-<date>.md`. Format:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
# Security Review — <branch name> — <date>
|
|
41
|
+
|
|
42
|
+
## Summary
|
|
43
|
+
<1–3 sentences. State overall risk: LOW | MEDIUM | HIGH | CRITICAL.>
|
|
44
|
+
|
|
45
|
+
## Findings
|
|
46
|
+
|
|
47
|
+
### [CRITICAL|HIGH|MEDIUM|LOW] <short title>
|
|
48
|
+
- **OWASP**: <A0X - category> | **CWE**: CWE-XXX
|
|
49
|
+
- **File**: path:line
|
|
50
|
+
- **Evidence**:
|
|
51
|
+
```
|
|
52
|
+
<5–10 lines of the offending code>
|
|
53
|
+
```
|
|
54
|
+
- **Impact**: <what an attacker can do>
|
|
55
|
+
- **Recommendation**: <concrete fix, not "consider sanitizing">
|
|
56
|
+
|
|
57
|
+
## Dependencies
|
|
58
|
+
<new packages in this diff, with CVE check results>
|
|
59
|
+
|
|
60
|
+
## Out of scope / Noted
|
|
61
|
+
<Observations not in the diff but worth flagging for later.>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
# Decision after review
|
|
65
|
+
|
|
66
|
+
- **CRITICAL or HIGH findings** → surface them, do **not** mark this phase complete. Ask the user how to proceed (fix now, track and accept risk, or defer).
|
|
67
|
+
- **Only MEDIUM/LOW** → append `"security"` to `workflow.json → completed`. Tell the user: `Security review at <path>. Next: /integrate.`
|
|
68
|
+
|
|
69
|
+
# Constraints
|
|
70
|
+
|
|
71
|
+
- **Never modify project code.** This skill is read-only against project files. The only write is to `docs/security/`.
|
|
72
|
+
- **Never claim PASS/clean without enumerating what you checked.**
|
|
73
|
+
- **Speculative findings ("could potentially")** → mark LOW and say so.
|
|
74
|
+
- **Don't dump full file contents.** Cite `path:line` and show minimal snippets.
|
|
75
|
+
- **If the diff is empty or larger than ~2000 lines**, report that and stop.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: simplify
|
|
3
|
+
owner: baseline
|
|
4
|
+
description: Workflow Phase 7 — Mechanical cleanup pass over the branch diff, followed by a `code-structure` review pass and a `verify` re-stamp. Shadows the global `simplify` skill at project scope; the cleanup pass is performed inline rather than via Skill self-call.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Prereq
|
|
8
|
+
|
|
9
|
+
`tdd` in `completed` AND `.claude/state/last_test_result` line 1 is `PASS`.
|
|
10
|
+
|
|
11
|
+
# Note on shadowing
|
|
12
|
+
|
|
13
|
+
This skill **shadows** the global `simplify` skill (same name, project scope wins). To avoid invoking itself, the cleanup pass is performed inline below — do **not** invoke `simplify` via the Skill tool from inside this file.
|
|
14
|
+
|
|
15
|
+
# Steps
|
|
16
|
+
|
|
17
|
+
## 1. Verify prereq
|
|
18
|
+
|
|
19
|
+
Read `.claude/state/last_test_result`; line 1 must be `PASS`.
|
|
20
|
+
|
|
21
|
+
## 2. Mechanical cleanup pass over the diff
|
|
22
|
+
|
|
23
|
+
Across the diff of this branch — **delete, don't comment out**:
|
|
24
|
+
|
|
25
|
+
- Dead code (unreferenced functions, unused imports, unreachable branches).
|
|
26
|
+
- Duplication that can collapse without harming readability.
|
|
27
|
+
- Over-abstraction (premature factories, single-implementation interfaces).
|
|
28
|
+
- Commented-out code — seed.md forbids it.
|
|
29
|
+
- `TODO` / `FIXME` / `HACK` / `XXX` — resolve or remove; seed.md forbids them in source.
|
|
30
|
+
- Stubs, `raise NotImplementedError`, "not implemented" placeholders.
|
|
31
|
+
|
|
32
|
+
## 3. `code-structure` review pass
|
|
33
|
+
|
|
34
|
+
Invoke `Skill(code-structure)` and apply its Detection Rules to every file the branch touches:
|
|
35
|
+
|
|
36
|
+
- Orchestration files leaking raw primitives or inline business logic.
|
|
37
|
+
- Siblings at mixed abstraction levels (named call next to raw primitive).
|
|
38
|
+
- Loop bodies carrying more than one abstraction level.
|
|
39
|
+
- Domain modules reaching directly for raw infrastructure.
|
|
40
|
+
- Files longer than ~80 lines of substantive code — split along layer lines.
|
|
41
|
+
|
|
42
|
+
Fixes here are in scope. Refactors that go beyond layering (new design patterns, interface changes) are **out of scope** — flag them and leave for a follow-up spec.
|
|
43
|
+
|
|
44
|
+
## 4. Scope guardrails
|
|
45
|
+
|
|
46
|
+
- Do not add features.
|
|
47
|
+
- Do not refactor scope beyond cleanup.
|
|
48
|
+
- Do not change public APIs. If a public API needs changing, surface it and stop — that belongs in a new spec.
|
|
49
|
+
|
|
50
|
+
## 5. Re-verify (inlined)
|
|
51
|
+
|
|
52
|
+
Inline the four mechanical operations from `.claude/skills/verify/SKILL.md` (the contract doc):
|
|
53
|
+
|
|
54
|
+
- Read `.claude/project.json` → `test.cmd`. If absent or empty, the verdict is `FAIL` with reason "project.json not configured" and step 5 stops with that verdict.
|
|
55
|
+
- Run the command via Bash from the project root. Capture stdout, stderr, exit code. Do not retry.
|
|
56
|
+
- Apply verdict rules: `PASS` iff exit code 0 AND at least one test executed AND no failed/errored test; otherwise `FAIL`.
|
|
57
|
+
- Atomically write `.claude/state/last_test_result` with the canonical four-line format (`<PASS|FAIL>\n<ISO-8601 UTC timestamp>\n<exact command>\n<exit code>\n`). The `verify_pass_guard` hook reads line 1 as the binding verdict.
|
|
58
|
+
|
|
59
|
+
## 6. Decide + write harness_state
|
|
60
|
+
|
|
61
|
+
- **Still PASS** → append `"simplify"` to `completed`. Marker FIRST: `echo "<slug>" > .claude/state/.harness_active` (refresh the active marker). Then write `.claude/state/harness_state` with `{state: "continue", slug, reason: "simplify clean; next: security or integrate"}` — exactly three keys; no `written_at`, no `tick_count`. Tell the user: "Cleanup done, tests green. Next: `/security` (optional) or `/integrate`."
|
|
62
|
+
- **FAIL** → revert the cleanup changes and surface exactly what broke (test name + first assertion). Marker FIRST: `rm -f .claude/state/.harness_active`. Then write `harness_state` with `{state: "yielded", slug, reason: "simplify FAIL after cleanup; reverted; needs user review"}`.
|
|
63
|
+
|
|
64
|
+
# Constraints
|
|
65
|
+
|
|
66
|
+
- **Never invoke the global `simplify` via the Skill tool from this file.** Name shadowing makes that a self-call.
|
|
67
|
+
- **Cleanup is mechanical.** If you find yourself reasoning about a refactor's design implications, stop — that's outside this phase's scope.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec
|
|
3
|
+
owner: baseline
|
|
4
|
+
description: Draft a Workflow Phase 4 technical spec from an intake (and optionally a BRD + scout + research memo). The spec defines how the system will change: design (C4 + UML + dependency graph in PlantUML), data, APIs, tests, rollout, rollback. Output lives at `docs/specs/<slug>.md`. Never self-approves — approval happens via `/approve-spec`.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Spec — Workflow Phase 4
|
|
8
|
+
|
|
9
|
+
You are drafting a **technical spec**. The spec answers "how" — what changes, in which files, behind which flags, with which tests and rollout. It is the document a different engineer can pick up tomorrow and build from.
|
|
10
|
+
|
|
11
|
+
The spec is **diagram-driven**: C4 + UML + a dependency graph in PlantUML, tables for contracts and traceability, prose only for what a diagram cannot say. Three hooks enforce this at the Write boundary:
|
|
12
|
+
|
|
13
|
+
- `artifact_template_guard` — required `##` headings present.
|
|
14
|
+
- `spec_diagram_presence_guard` — required diagram kinds present inside ```plantuml``` fences.
|
|
15
|
+
- `plantuml_syntax_guard` — every ```plantuml``` fence parses.
|
|
16
|
+
|
|
17
|
+
## Prerequisite
|
|
18
|
+
|
|
19
|
+
Per `.claude/state/workflow.json`, `research` must be in `completed` OR in `exceptions` (quickfixes and some bugfixes skip research). The `track_guard` hook enforces this at Write time, but verify upfront so you can stop with a clear message rather than hitting the guard.
|
|
20
|
+
|
|
21
|
+
## Inputs
|
|
22
|
+
|
|
23
|
+
- **Required**: the intake at `docs/intake/<slug>.md` (or the bugfix description if entry was `/triage` → `spec`).
|
|
24
|
+
- **Optional**: BRD at `docs/brd/<slug>.md`, scout report at `docs/scout/<slug>.md`, research memo at `docs/research/<slug>.md`.
|
|
25
|
+
- `template.md` in this skill directory — the canonical structure.
|
|
26
|
+
|
|
27
|
+
## Steps
|
|
28
|
+
|
|
29
|
+
1. Read all available upstream artifacts. Note the acceptance-criterion IDs from the intake/BRD — the spec's AC table must either reuse those IDs or trace to them explicitly.
|
|
30
|
+
2. Read `template.md`. Every `##` heading must appear in the output; every required diagram kind (C4 Context/Container/Component, class, sequence, dependency graph) must appear inside a ```plantuml``` fence.
|
|
31
|
+
3. Draft each diagram **first**, then the surrounding table/prose. If you cannot draw a diagram, you do not understand that part of the design yet — record it under **Open questions** rather than faking prose.
|
|
32
|
+
4. Confirm every third-party API cited (in the Libraries table, Contracts rows, or diagram labels) via the `context7` MCP. Record the library version. Never recall an API from training data.
|
|
33
|
+
5. Verify each `AC-NNN` row points to a real `§Behavior #N` anchor, and that the corresponding sequence diagram actually defines the promised behaviour.
|
|
34
|
+
6. Run `/spec-lint <slug>` before saving if you want to preview what the guards will report — same checks, not enforced.
|
|
35
|
+
7. Write to `docs/specs/<slug>.md`.
|
|
36
|
+
8. **NEVER write `Status: Approved`, `Approved: true`, or any variation.** The `spec_approval_guard` blocks self-approval. Approval is the token written by `/approve-spec` to `.claude/state/spec_approvals/<slug>.approval`.
|
|
37
|
+
9. Append `"spec"` to `.claude/state/workflow.json` → `completed`.
|
|
38
|
+
10. Tell the user: "Spec drafted at `docs/specs/<slug>.md`. Render diagrams with `/spec-render <slug>`, review, then `/approve-spec <slug>` (or pass the full path). After approval, `/tdd`."
|
|
39
|
+
|
|
40
|
+
## Diagram rules (non-negotiable)
|
|
41
|
+
|
|
42
|
+
- **Renderable PlantUML only.** Every fence must validate — broken diagrams are worse than missing ones because they waste reviewer time. Test locally with `plantuml -checkonly -pipe` or the `plantuml` MCP server.
|
|
43
|
+
- **C4 uses the stdlib includes**: `!include <C4/C4_Context>`, `!include <C4/C4_Container>`, `!include <C4/C4_Component>`. No remote URL includes — they break offline review.
|
|
44
|
+
- **One sequence per AC.** The sequence *is* the contract; prose descriptions of behaviour are forbidden. If an AC spans multiple interactions, use `==` dividers inside one sequence diagram rather than splitting into two.
|
|
45
|
+
- **Dependency graph is directed and acyclic.** `A --> B` means "A depends on B". Cycles mean the design has a deadlock risk — surface under Open questions, don't draw the cycle.
|
|
46
|
+
- **Class diagram mirrors the migration DDL.** Every `<<new>>` / `<<changed>>` field must have a matching `ALTER` in the DDL block. If the DDL changes, update the class diagram in the same edit.
|
|
47
|
+
|
|
48
|
+
## Drafting rules (from seed.md § Code Standards)
|
|
49
|
+
|
|
50
|
+
- **No stubs — EVER.** If the spec declares a function or endpoint, define its contract fully: inputs, outputs, errors, idempotency, side effects, ownership. If you can't, do not declare it — flag it as an Open question.
|
|
51
|
+
- **YAGNI.** The spec describes what is built now. A "future option" with no current test driving it does not belong here.
|
|
52
|
+
- **Context7 for every library API.** API shape confirmed via the `context7` MCP, not training recall. Record the library version.
|
|
53
|
+
- **Acceptance criteria are testable.** Numbered, concrete, traced. "Users can retry" is not an AC; "on 5xx from upstream, worker retries with 100/200/400 ms backoff, max 3 tries, then dead-letters" is.
|
|
54
|
+
- **Rollout and rollback are named, not 'standard.'** Which flag? Which kill-switch? Which metric + threshold + window detects a bad rollout within 5 minutes?
|
|
55
|
+
|
|
56
|
+
## Archive planning
|
|
57
|
+
|
|
58
|
+
The spec template includes an **Archive plan** section. Its purpose is to *document at drafting time* which artifacts ship together when this work lands. For 90% of specs the default bundle (every file named `<slug>.*` in the workflow directories) is exactly right — leave the "Extras" list as *(none)*. Only populate it if this work produces a one-off file that isn't slug-named but belongs with the bundle (e.g., a migration script kept for reference, a runbook).
|
|
59
|
+
|
|
60
|
+
The `archive` skill (Phase 10.5) reads the slug convention automatically; the human-authored "Extras" list is an advisory — surface it to the reviewer so the bundle is transparent before approval.
|
|
61
|
+
|
|
62
|
+
## Common failure modes (don't)
|
|
63
|
+
|
|
64
|
+
- Restating the intake verbatim — the spec earns its keep by adding design, not by re-narrating requirements.
|
|
65
|
+
- Writing behavior as prose ("we'll retry on 5xx") — draw the sequence.
|
|
66
|
+
- A `C4_Container` diagram that invents containers not in any code path — if it isn't deployable today, it belongs in a future-work spec.
|
|
67
|
+
- An AC row whose `§Behavior #N` anchor resolves to an empty section.
|
|
68
|
+
- Hiding open questions in body prose — surface them under **Open questions** so the reviewer (and `/approve-spec` gate) sees them.
|
|
69
|
+
- Pre-optimizing — if profiling hasn't run, a performance plan is speculation.
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# <Spec — technical, short, specific>
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
Technical spec. Produced by the `spec` skill.
|
|
5
|
+
|
|
6
|
+
Guard-enforced invariants:
|
|
7
|
+
- Required ## headings (artifact_template_guard):
|
|
8
|
+
Goal, Design, Acceptance criteria, Test plan.
|
|
9
|
+
- Required diagram kinds inside ```plantuml``` fences
|
|
10
|
+
(spec_diagram_presence_guard, configured in project.json →
|
|
11
|
+
artifacts.required_diagrams.spec):
|
|
12
|
+
c4_context, c4_container, c4_component,
|
|
13
|
+
sequence, class, dependency_graph.
|
|
14
|
+
- Every ```plantuml``` fence must parse (plantuml_syntax_guard).
|
|
15
|
+
|
|
16
|
+
Approval: NEVER add "Status: Approved" — spec_approval_guard blocks it.
|
|
17
|
+
Approval is a token written by /approve-spec.
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
## Context
|
|
21
|
+
|
|
22
|
+
| Input | Path |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Intake | `docs/intake/<slug>.md` |
|
|
25
|
+
| BRD *(if any)* | `docs/brd/<slug>.md` |
|
|
26
|
+
| Scout *(if any)* | `docs/scout/<slug>.md` |
|
|
27
|
+
| Research *(if any)* | `docs/research/<slug>.md` |
|
|
28
|
+
|
|
29
|
+
## Goal
|
|
30
|
+
|
|
31
|
+
<One sentence. What the system does after this spec ships. Not why — the intake owns why.>
|
|
32
|
+
|
|
33
|
+
## Non-goals
|
|
34
|
+
|
|
35
|
+
- <Explicit exclusion. Keeps the spec from quietly growing.>
|
|
36
|
+
|
|
37
|
+
## Design
|
|
38
|
+
|
|
39
|
+
Diagrams are the contract. Prose is only for things a diagram cannot say.
|
|
40
|
+
|
|
41
|
+
### C4 — System context
|
|
42
|
+
|
|
43
|
+
Who interacts with the system, and which external systems it depends on.
|
|
44
|
+
|
|
45
|
+
```plantuml
|
|
46
|
+
@startuml
|
|
47
|
+
!include <C4/C4_Context>
|
|
48
|
+
title System Context — <system>
|
|
49
|
+
Person(user, "<Role>", "<responsibility>")
|
|
50
|
+
System(sut, "<System under change>", "<one-line purpose>")
|
|
51
|
+
System_Ext(dep1, "<External dep>", "<purpose>")
|
|
52
|
+
Rel(user, sut, "<action>")
|
|
53
|
+
Rel(sut, dep1, "<protocol, verb>")
|
|
54
|
+
@enduml
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### C4 — Container
|
|
58
|
+
|
|
59
|
+
Deployable units inside the system boundary and how they communicate.
|
|
60
|
+
|
|
61
|
+
```plantuml
|
|
62
|
+
@startuml
|
|
63
|
+
!include <C4/C4_Container>
|
|
64
|
+
title Container — <system>
|
|
65
|
+
System_Boundary(sut, "<System>") {
|
|
66
|
+
Container(api, "<API>", "<tech>", "<role>")
|
|
67
|
+
Container(worker, "<Worker>", "<tech>", "<role>")
|
|
68
|
+
ContainerDb(db, "<DB>", "<engine>", "<stores>")
|
|
69
|
+
}
|
|
70
|
+
Rel(api, worker, "<queue or RPC>")
|
|
71
|
+
Rel(api, db, "reads/writes")
|
|
72
|
+
Rel(worker, db, "writes")
|
|
73
|
+
@enduml
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### C4 — Component (changed containers only)
|
|
77
|
+
|
|
78
|
+
One diagram per container whose internals change. Skip containers that are untouched.
|
|
79
|
+
|
|
80
|
+
```plantuml
|
|
81
|
+
@startuml
|
|
82
|
+
!include <C4/C4_Component>
|
|
83
|
+
title Component — <container>
|
|
84
|
+
Container_Boundary(api, "<API>") {
|
|
85
|
+
Component(ctrl, "<Controller>", "<tech>", "<role>")
|
|
86
|
+
Component(svc, "<Service>", "<tech>", "<role>")
|
|
87
|
+
Component(repo, "<Repo>", "<tech>", "<role>")
|
|
88
|
+
}
|
|
89
|
+
Rel(ctrl, svc, "invokes")
|
|
90
|
+
Rel(svc, repo, "persists via")
|
|
91
|
+
@enduml
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Data model — class diagram
|
|
95
|
+
|
|
96
|
+
Entities, fields, and cardinality. Mark new/changed with `<<new>>` or `<<changed>>`.
|
|
97
|
+
|
|
98
|
+
```plantuml
|
|
99
|
+
@startuml
|
|
100
|
+
title Data model — <domain>
|
|
101
|
+
class Order {
|
|
102
|
+
+id: UUID <<pk>>
|
|
103
|
+
+status: OrderStatus
|
|
104
|
+
+total_cents: int <<new>>
|
|
105
|
+
+created_at: timestamp
|
|
106
|
+
}
|
|
107
|
+
class LineItem {
|
|
108
|
+
+order_id: UUID <<fk>>
|
|
109
|
+
+sku: string
|
|
110
|
+
+qty: int
|
|
111
|
+
}
|
|
112
|
+
Order "1" *-- "many" LineItem
|
|
113
|
+
@enduml
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Migration DDL
|
|
117
|
+
|
|
118
|
+
```sql
|
|
119
|
+
-- forward
|
|
120
|
+
ALTER TABLE orders ADD COLUMN total_cents int NOT NULL DEFAULT 0;
|
|
121
|
+
-- reverse
|
|
122
|
+
ALTER TABLE orders DROP COLUMN total_cents;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Behavior — sequence per AC
|
|
126
|
+
|
|
127
|
+
One sequence diagram per acceptance criterion. The sequence is the contract: label every arrow with method + payload, include failure branches explicitly. Section anchors here (`§Behavior #N`) are referenced from the AC table.
|
|
128
|
+
|
|
129
|
+
```plantuml
|
|
130
|
+
@startuml
|
|
131
|
+
title Behavior #1 — <AC-001 summary>
|
|
132
|
+
actor Client
|
|
133
|
+
participant API
|
|
134
|
+
participant Service
|
|
135
|
+
database DB
|
|
136
|
+
|
|
137
|
+
Client -> API : POST /orders {sku, qty}
|
|
138
|
+
API -> Service : createOrder(cmd)
|
|
139
|
+
Service -> DB : INSERT order
|
|
140
|
+
alt success
|
|
141
|
+
DB --> Service : order_id
|
|
142
|
+
Service --> API : 201 Created {order_id}
|
|
143
|
+
else idempotency conflict
|
|
144
|
+
DB --> Service : conflict
|
|
145
|
+
Service --> API : 409 Conflict
|
|
146
|
+
end
|
|
147
|
+
API --> Client : response
|
|
148
|
+
@enduml
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### State — core entity *(only if stateful)*
|
|
152
|
+
|
|
153
|
+
Finite-state model. Omit the block if the system has no non-trivial state machine — but keep the heading so reviewers see the explicit choice.
|
|
154
|
+
|
|
155
|
+
```plantuml
|
|
156
|
+
@startuml
|
|
157
|
+
title State — <entity>
|
|
158
|
+
[*] --> Draft
|
|
159
|
+
Draft --> Submitted : submit
|
|
160
|
+
Submitted --> Approved : approve
|
|
161
|
+
Submitted --> Rejected : reject
|
|
162
|
+
Approved --> [*]
|
|
163
|
+
Rejected --> [*]
|
|
164
|
+
@enduml
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Dependencies — graph
|
|
168
|
+
|
|
169
|
+
Directed graph of build/runtime dependencies. Edge `A --> B` reads "A depends on B". The first line `' @kind dependency-graph` is a PlantUML comment that identifies the block to `spec_diagram_presence_guard`.
|
|
170
|
+
|
|
171
|
+
```plantuml
|
|
172
|
+
@startuml
|
|
173
|
+
' @kind dependency-graph
|
|
174
|
+
title Dependencies — <system>
|
|
175
|
+
left to right direction
|
|
176
|
+
[api] --> [service]
|
|
177
|
+
[service] --> [repo]
|
|
178
|
+
[repo] --> [postgres]
|
|
179
|
+
[service] --> [redis]
|
|
180
|
+
[worker] --> [service]
|
|
181
|
+
[worker] --> [sqs]
|
|
182
|
+
@enduml
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Contracts
|
|
186
|
+
|
|
187
|
+
One row per endpoint / CLI command / message. Tables, not prose.
|
|
188
|
+
|
|
189
|
+
| Kind | Name | Input | Output | Errors | Idempotent |
|
|
190
|
+
|---|---|---|---|---|---|
|
|
191
|
+
| HTTP | `POST /orders` | `{sku, qty}` | `201 {order_id}` | 400, 409, 5xx | yes (`Idempotency-Key`) |
|
|
192
|
+
| Event | `order.created.v1` | `{order_id, total_cents}` | — | — | consumer de-dupes |
|
|
193
|
+
|
|
194
|
+
### Libraries and versions
|
|
195
|
+
|
|
196
|
+
Every entry must be confirmed via the `context7` MCP — no training-data recall for third-party APIs (seed.md § Context7 Rule).
|
|
197
|
+
|
|
198
|
+
| Library@version | Purpose | Key APIs | Confirmed via context7 |
|
|
199
|
+
|---|---|---|---|
|
|
200
|
+
| `<lib@x.y.z>` | `<use>` | `<api names>` | yes |
|
|
201
|
+
|
|
202
|
+
### Alternatives considered
|
|
203
|
+
|
|
204
|
+
| Alt | Summary | Rejected because |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| A | <description> | <reason> |
|
|
207
|
+
| B | <description> | <reason> |
|
|
208
|
+
|
|
209
|
+
## Design calls
|
|
210
|
+
|
|
211
|
+
When this spec's `write_set` intersects `project.json → tdd.ui_globs`, every UI surface needs a design call here. `/tdd` Step 6 reads each row, serializes it to a `task_brief`, and invokes `Skill(design-ui, task_brief)` once per row. design-ui then routes through `impeccable` for the actual design work.
|
|
212
|
+
|
|
213
|
+
If the write_set has no UI files, leave the section body as `*(none)*` — the required heading must still be present per `project.json → artifacts.required_sections.spec`. `spec_design_calls_guard` only fires (denies the write) when both conditions hold: write_set intersects ui_globs AND the section body is missing or empty.
|
|
214
|
+
|
|
215
|
+
| Slug | Intent | Target files | Write set | Register | References |
|
|
216
|
+
|---|---|---|---|---|---|
|
|
217
|
+
| settings-page | build a settings page that doesn't feel like a SaaS template | `app/settings/page.tsx` | `app/settings/**` | inherit | — |
|
|
218
|
+
|
|
219
|
+
For specs with no UI surface:
|
|
220
|
+
|
|
221
|
+
- *(none)*
|
|
222
|
+
|
|
223
|
+
## Acceptance criteria
|
|
224
|
+
|
|
225
|
+
Numbered, testable, traced. Each AC points to the §Behavior sequence that defines it.
|
|
226
|
+
|
|
227
|
+
| ID | Criterion (given / when / then) | Upstream AC | Sequence |
|
|
228
|
+
|---|---|---|---|
|
|
229
|
+
| AC-001 | given X, when Y, then Z | intake AC 1 | §Behavior #1 |
|
|
230
|
+
| AC-002 | given X, when Y, then Z | BR-001 | §Behavior #2 |
|
|
231
|
+
|
|
232
|
+
## Test plan
|
|
233
|
+
|
|
234
|
+
Scenarios by category. The `scenario` skill (invoked from `/tdd` or `/swarm-dispatch` workers) turns these into failing tests; main context decides the recipe before invocation. Every row must reference at least one AC (or an invariant the regression row defends).
|
|
235
|
+
|
|
236
|
+
| Category | Scenario | Expected | Covers |
|
|
237
|
+
|---|---|---|---|
|
|
238
|
+
| Golden path | <case> | <result> | AC-001 |
|
|
239
|
+
| Input boundary | empty / max / off-by-one / unicode | <result> | AC-001 |
|
|
240
|
+
| Contract violation | invalid type / missing field / unauthorized | <result> | AC-002 |
|
|
241
|
+
| Concurrency / ordering | <race, interleaving> | <result> | — |
|
|
242
|
+
| Failure mode | dep down / timeout / partial write | <result> | — |
|
|
243
|
+
| Regression trap | <invariant> | unchanged | — |
|
|
244
|
+
|
|
245
|
+
## Observability
|
|
246
|
+
|
|
247
|
+
| Signal | Name | Shape | Purpose |
|
|
248
|
+
|---|---|---|---|
|
|
249
|
+
| Log | `<event>` | fields: `<names>` | audit / debug |
|
|
250
|
+
| Metric | `<name>` | counter/histogram, labels: `<names>` | SLO |
|
|
251
|
+
| Alarm | `<name>` | `<metric + threshold + window>` | page target |
|
|
252
|
+
|
|
253
|
+
## Rollout
|
|
254
|
+
|
|
255
|
+
- **Feature flag**: `<flag.name>` — default off.
|
|
256
|
+
- **Migration order**: 1 DDL → 2 backfill → 3 dual-write → 4 read-swap → 5 cleanup.
|
|
257
|
+
- **Canary**: <percentage, duration, success signal>.
|
|
258
|
+
|
|
259
|
+
## Rollback
|
|
260
|
+
|
|
261
|
+
- **Kill-switch**: `<flag off | deploy revert | command>`.
|
|
262
|
+
- **Signal to roll back**: `<metric + threshold + window>` — must trip within 5 minutes of a bad rollout.
|
|
263
|
+
|
|
264
|
+
## Archive plan
|
|
265
|
+
|
|
266
|
+
When this spec ships, the `archive` skill (Phase 10.5) moves the following into `docs/archive/<ship-date>/<slug>/`. Defaults are the slug-matched artifacts; add any one-off files this work produced (e.g., migration scripts kept for reference) below. Advisory — the `archive` skill discovers slug-matched files automatically; this section documents the *bundle* for the human reviewer.
|
|
267
|
+
|
|
268
|
+
- Defaults *(automatic)*: intake, brd, scout, research, spec, spec-rendered/, spec approval, swarm plan + approval (if used), security reports (concatenated).
|
|
269
|
+
- Extras *(list any non-default files)*:
|
|
270
|
+
- *(none)*
|
|
271
|
+
|
|
272
|
+
## Open questions
|
|
273
|
+
|
|
274
|
+
- <question — blocks approval until resolved>
|