@garygentry/feature-forge 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 +21 -0
- package/adapters/GENERATION-REPORT.md +128 -0
- package/adapters/claude/agents/forge-researcher.md +137 -0
- package/adapters/claude/agents/forge-spec-writer.md +115 -0
- package/adapters/claude/agents/forge-verifier.md +121 -0
- package/adapters/claude/references/epic-manifest-schema.json +120 -0
- package/adapters/claude/references/forge-config-schema.json +166 -0
- package/adapters/claude/references/pipeline-state-schema.json +110 -0
- package/adapters/claude/references/portable-root.md +56 -0
- package/adapters/claude/references/process-overview.md +123 -0
- package/adapters/claude/references/ralph-loop-contract.md +221 -0
- package/adapters/claude/references/shared-conventions.md +144 -0
- package/adapters/claude/references/skill-frontmatter.schema.json +17 -0
- package/adapters/claude/references/stack-resolution.md +51 -0
- package/adapters/claude/references/stacks/_generic.md +90 -0
- package/adapters/claude/references/stacks/go.md +138 -0
- package/adapters/claude/references/stacks/python.md +163 -0
- package/adapters/claude/references/stacks/rust.md +151 -0
- package/adapters/claude/references/stacks/typescript.md +111 -0
- package/adapters/claude/references/vendor-construct-inventory.md +49 -0
- package/adapters/claude/scripts/forge-root.sh +50 -0
- package/adapters/claude/skills/forge/SKILL.md +165 -0
- package/adapters/claude/skills/forge-0-epic/SKILL.md +303 -0
- package/adapters/claude/skills/forge-0-epic/references/edit-mode.md +222 -0
- package/adapters/claude/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
- package/adapters/claude/skills/forge-1-prd/SKILL.md +121 -0
- package/adapters/claude/skills/forge-1-prd/references/prd-template.md +106 -0
- package/adapters/claude/skills/forge-2-tech/SKILL.md +198 -0
- package/adapters/claude/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
- package/adapters/claude/skills/forge-3-specs/SKILL.md +154 -0
- package/adapters/claude/skills/forge-3-specs/references/spec-archetypes.md +106 -0
- package/adapters/claude/skills/forge-3-specs/references/spec-examples.md +71 -0
- package/adapters/claude/skills/forge-4-backlog/SKILL.md +146 -0
- package/adapters/claude/skills/forge-5-loop/SKILL.md +303 -0
- package/adapters/claude/skills/forge-5-loop/references/result-reporting.md +63 -0
- package/adapters/claude/skills/forge-5-loop/references/runner-contract.md +214 -0
- package/adapters/claude/skills/forge-6-docs/SKILL.md +179 -0
- package/adapters/claude/skills/forge-6-docs/references/doc-conventions.md +126 -0
- package/adapters/claude/skills/forge-fix/SKILL.md +65 -0
- package/adapters/claude/skills/forge-init/SKILL.md +29 -0
- package/adapters/claude/skills/forge-verify/SKILL.md +219 -0
- package/adapters/claude/skills/forge-verify/references/verification-checklists.md +379 -0
- package/adapters/codex/agents/forge-researcher.md +133 -0
- package/adapters/codex/agents/forge-spec-writer.md +112 -0
- package/adapters/codex/agents/forge-verifier.md +115 -0
- package/adapters/codex/agents/openai.yaml +10 -0
- package/adapters/codex/references/epic-manifest-schema.json +120 -0
- package/adapters/codex/references/forge-config-schema.json +166 -0
- package/adapters/codex/references/pipeline-state-schema.json +110 -0
- package/adapters/codex/references/portable-root.md +56 -0
- package/adapters/codex/references/process-overview.md +123 -0
- package/adapters/codex/references/ralph-loop-contract.md +221 -0
- package/adapters/codex/references/shared-conventions.md +144 -0
- package/adapters/codex/references/skill-frontmatter.schema.json +17 -0
- package/adapters/codex/references/stack-resolution.md +51 -0
- package/adapters/codex/references/stacks/_generic.md +90 -0
- package/adapters/codex/references/stacks/go.md +138 -0
- package/adapters/codex/references/stacks/python.md +163 -0
- package/adapters/codex/references/stacks/rust.md +151 -0
- package/adapters/codex/references/stacks/typescript.md +111 -0
- package/adapters/codex/references/vendor-construct-inventory.md +49 -0
- package/adapters/codex/scripts/forge-root.sh +50 -0
- package/adapters/codex/skills/forge/forge.md +164 -0
- package/adapters/codex/skills/forge-0-epic/forge-0-epic.md +302 -0
- package/adapters/codex/skills/forge-0-epic/references/edit-mode.md +222 -0
- package/adapters/codex/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
- package/adapters/codex/skills/forge-1-prd/forge-1-prd.md +120 -0
- package/adapters/codex/skills/forge-1-prd/references/prd-template.md +106 -0
- package/adapters/codex/skills/forge-2-tech/forge-2-tech.md +197 -0
- package/adapters/codex/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
- package/adapters/codex/skills/forge-3-specs/forge-3-specs.md +153 -0
- package/adapters/codex/skills/forge-3-specs/references/spec-archetypes.md +106 -0
- package/adapters/codex/skills/forge-3-specs/references/spec-examples.md +71 -0
- package/adapters/codex/skills/forge-4-backlog/forge-4-backlog.md +145 -0
- package/adapters/codex/skills/forge-5-loop/forge-5-loop.md +302 -0
- package/adapters/codex/skills/forge-5-loop/references/result-reporting.md +63 -0
- package/adapters/codex/skills/forge-5-loop/references/runner-contract.md +214 -0
- package/adapters/codex/skills/forge-6-docs/forge-6-docs.md +178 -0
- package/adapters/codex/skills/forge-6-docs/references/doc-conventions.md +126 -0
- package/adapters/codex/skills/forge-fix/forge-fix.md +64 -0
- package/adapters/codex/skills/forge-init/forge-init.md +29 -0
- package/adapters/codex/skills/forge-verify/forge-verify.md +218 -0
- package/adapters/codex/skills/forge-verify/references/verification-checklists.md +379 -0
- package/adapters/copilot/agents/forge-researcher.md +133 -0
- package/adapters/copilot/agents/forge-spec-writer.md +112 -0
- package/adapters/copilot/agents/forge-verifier.md +115 -0
- package/adapters/copilot/references/epic-manifest-schema.json +120 -0
- package/adapters/copilot/references/forge-config-schema.json +166 -0
- package/adapters/copilot/references/pipeline-state-schema.json +110 -0
- package/adapters/copilot/references/portable-root.md +56 -0
- package/adapters/copilot/references/process-overview.md +123 -0
- package/adapters/copilot/references/ralph-loop-contract.md +221 -0
- package/adapters/copilot/references/shared-conventions.md +144 -0
- package/adapters/copilot/references/skill-frontmatter.schema.json +17 -0
- package/adapters/copilot/references/stack-resolution.md +51 -0
- package/adapters/copilot/references/stacks/_generic.md +90 -0
- package/adapters/copilot/references/stacks/go.md +138 -0
- package/adapters/copilot/references/stacks/python.md +163 -0
- package/adapters/copilot/references/stacks/rust.md +151 -0
- package/adapters/copilot/references/stacks/typescript.md +111 -0
- package/adapters/copilot/references/vendor-construct-inventory.md +49 -0
- package/adapters/copilot/scripts/forge-root.sh +50 -0
- package/adapters/copilot/skills/forge/forge.md +164 -0
- package/adapters/copilot/skills/forge-0-epic/forge-0-epic.md +302 -0
- package/adapters/copilot/skills/forge-0-epic/references/edit-mode.md +222 -0
- package/adapters/copilot/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
- package/adapters/copilot/skills/forge-1-prd/forge-1-prd.md +120 -0
- package/adapters/copilot/skills/forge-1-prd/references/prd-template.md +106 -0
- package/adapters/copilot/skills/forge-2-tech/forge-2-tech.md +197 -0
- package/adapters/copilot/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
- package/adapters/copilot/skills/forge-3-specs/forge-3-specs.md +153 -0
- package/adapters/copilot/skills/forge-3-specs/references/spec-archetypes.md +106 -0
- package/adapters/copilot/skills/forge-3-specs/references/spec-examples.md +71 -0
- package/adapters/copilot/skills/forge-4-backlog/forge-4-backlog.md +145 -0
- package/adapters/copilot/skills/forge-5-loop/forge-5-loop.md +302 -0
- package/adapters/copilot/skills/forge-5-loop/references/result-reporting.md +63 -0
- package/adapters/copilot/skills/forge-5-loop/references/runner-contract.md +214 -0
- package/adapters/copilot/skills/forge-6-docs/forge-6-docs.md +178 -0
- package/adapters/copilot/skills/forge-6-docs/references/doc-conventions.md +126 -0
- package/adapters/copilot/skills/forge-fix/forge-fix.md +64 -0
- package/adapters/copilot/skills/forge-init/forge-init.md +29 -0
- package/adapters/copilot/skills/forge-verify/forge-verify.md +218 -0
- package/adapters/copilot/skills/forge-verify/references/verification-checklists.md +379 -0
- package/adapters/cursor/agents/forge-researcher.mdc +134 -0
- package/adapters/cursor/agents/forge-spec-writer.mdc +113 -0
- package/adapters/cursor/agents/forge-verifier.mdc +116 -0
- package/adapters/cursor/references/epic-manifest-schema.json +120 -0
- package/adapters/cursor/references/forge-config-schema.json +166 -0
- package/adapters/cursor/references/pipeline-state-schema.json +110 -0
- package/adapters/cursor/references/portable-root.md +56 -0
- package/adapters/cursor/references/process-overview.md +123 -0
- package/adapters/cursor/references/ralph-loop-contract.md +221 -0
- package/adapters/cursor/references/shared-conventions.md +144 -0
- package/adapters/cursor/references/skill-frontmatter.schema.json +17 -0
- package/adapters/cursor/references/stack-resolution.md +51 -0
- package/adapters/cursor/references/stacks/_generic.md +90 -0
- package/adapters/cursor/references/stacks/go.md +138 -0
- package/adapters/cursor/references/stacks/python.md +163 -0
- package/adapters/cursor/references/stacks/rust.md +151 -0
- package/adapters/cursor/references/stacks/typescript.md +111 -0
- package/adapters/cursor/references/vendor-construct-inventory.md +49 -0
- package/adapters/cursor/scripts/forge-root.sh +50 -0
- package/adapters/cursor/skills/forge/forge.mdc +165 -0
- package/adapters/cursor/skills/forge-0-epic/forge-0-epic.mdc +303 -0
- package/adapters/cursor/skills/forge-0-epic/references/edit-mode.md +222 -0
- package/adapters/cursor/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
- package/adapters/cursor/skills/forge-1-prd/forge-1-prd.mdc +121 -0
- package/adapters/cursor/skills/forge-1-prd/references/prd-template.md +106 -0
- package/adapters/cursor/skills/forge-2-tech/forge-2-tech.mdc +198 -0
- package/adapters/cursor/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
- package/adapters/cursor/skills/forge-3-specs/forge-3-specs.mdc +154 -0
- package/adapters/cursor/skills/forge-3-specs/references/spec-archetypes.md +106 -0
- package/adapters/cursor/skills/forge-3-specs/references/spec-examples.md +71 -0
- package/adapters/cursor/skills/forge-4-backlog/forge-4-backlog.mdc +146 -0
- package/adapters/cursor/skills/forge-5-loop/forge-5-loop.mdc +303 -0
- package/adapters/cursor/skills/forge-5-loop/references/result-reporting.md +63 -0
- package/adapters/cursor/skills/forge-5-loop/references/runner-contract.md +214 -0
- package/adapters/cursor/skills/forge-6-docs/forge-6-docs.mdc +179 -0
- package/adapters/cursor/skills/forge-6-docs/references/doc-conventions.md +126 -0
- package/adapters/cursor/skills/forge-fix/forge-fix.mdc +65 -0
- package/adapters/cursor/skills/forge-init/forge-init.mdc +30 -0
- package/adapters/cursor/skills/forge-verify/forge-verify.mdc +219 -0
- package/adapters/cursor/skills/forge-verify/references/verification-checklists.md +379 -0
- package/adapters/gemini/agents/forge-researcher.md +133 -0
- package/adapters/gemini/agents/forge-spec-writer.md +112 -0
- package/adapters/gemini/agents/forge-verifier.md +115 -0
- package/adapters/gemini/gemini-extension.json +54 -0
- package/adapters/gemini/references/epic-manifest-schema.json +120 -0
- package/adapters/gemini/references/forge-config-schema.json +166 -0
- package/adapters/gemini/references/pipeline-state-schema.json +110 -0
- package/adapters/gemini/references/portable-root.md +56 -0
- package/adapters/gemini/references/process-overview.md +123 -0
- package/adapters/gemini/references/ralph-loop-contract.md +221 -0
- package/adapters/gemini/references/shared-conventions.md +144 -0
- package/adapters/gemini/references/skill-frontmatter.schema.json +17 -0
- package/adapters/gemini/references/stack-resolution.md +51 -0
- package/adapters/gemini/references/stacks/_generic.md +90 -0
- package/adapters/gemini/references/stacks/go.md +138 -0
- package/adapters/gemini/references/stacks/python.md +163 -0
- package/adapters/gemini/references/stacks/rust.md +151 -0
- package/adapters/gemini/references/stacks/typescript.md +111 -0
- package/adapters/gemini/references/vendor-construct-inventory.md +49 -0
- package/adapters/gemini/scripts/forge-root.sh +50 -0
- package/adapters/gemini/skills/forge/forge.md +164 -0
- package/adapters/gemini/skills/forge-0-epic/forge-0-epic.md +302 -0
- package/adapters/gemini/skills/forge-0-epic/references/edit-mode.md +222 -0
- package/adapters/gemini/skills/forge-0-epic/references/epic-manifest-subcommands.md +64 -0
- package/adapters/gemini/skills/forge-1-prd/forge-1-prd.md +120 -0
- package/adapters/gemini/skills/forge-1-prd/references/prd-template.md +106 -0
- package/adapters/gemini/skills/forge-2-tech/forge-2-tech.md +197 -0
- package/adapters/gemini/skills/forge-2-tech/references/stack-discovery-checklist.md +95 -0
- package/adapters/gemini/skills/forge-3-specs/forge-3-specs.md +153 -0
- package/adapters/gemini/skills/forge-3-specs/references/spec-archetypes.md +106 -0
- package/adapters/gemini/skills/forge-3-specs/references/spec-examples.md +71 -0
- package/adapters/gemini/skills/forge-4-backlog/forge-4-backlog.md +145 -0
- package/adapters/gemini/skills/forge-5-loop/forge-5-loop.md +302 -0
- package/adapters/gemini/skills/forge-5-loop/references/result-reporting.md +63 -0
- package/adapters/gemini/skills/forge-5-loop/references/runner-contract.md +214 -0
- package/adapters/gemini/skills/forge-6-docs/forge-6-docs.md +178 -0
- package/adapters/gemini/skills/forge-6-docs/references/doc-conventions.md +126 -0
- package/adapters/gemini/skills/forge-fix/forge-fix.md +64 -0
- package/adapters/gemini/skills/forge-init/forge-init.md +29 -0
- package/adapters/gemini/skills/forge-verify/forge-verify.md +218 -0
- package/adapters/gemini/skills/forge-verify/references/verification-checklists.md +379 -0
- package/dist/agent-targets.d.ts +70 -0
- package/dist/agent-targets.js +111 -0
- package/dist/apply.d.ts +49 -0
- package/dist/apply.js +246 -0
- package/dist/cli.d.ts +94 -0
- package/dist/cli.js +508 -0
- package/dist/detect.d.ts +45 -0
- package/dist/detect.js +72 -0
- package/dist/fsutil.d.ts +56 -0
- package/dist/fsutil.js +175 -0
- package/dist/hash.d.ts +50 -0
- package/dist/hash.js +107 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/manifest.d.ts +72 -0
- package/dist/manifest.js +222 -0
- package/dist/plan.d.ts +66 -0
- package/dist/plan.js +166 -0
- package/dist/rauf.d.ts +83 -0
- package/dist/rauf.js +118 -0
- package/dist/report.d.ts +35 -0
- package/dist/report.js +110 -0
- package/dist/source.d.ts +69 -0
- package/dist/source.js +164 -0
- package/dist/types.d.ts +264 -0
- package/dist/types.js +57 -0
- package/package.json +42 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Shared Pipeline Conventions
|
|
2
|
+
|
|
3
|
+
These conventions apply to every forge pipeline skill. Skills reference this file to avoid duplicating shared logic.
|
|
4
|
+
|
|
5
|
+
## Feature Name Requirement
|
|
6
|
+
|
|
7
|
+
Every pipeline skill requires a feature name as the first argument (e.g., `/feature-forge:forge-1-prd auth`).
|
|
8
|
+
|
|
9
|
+
If no feature name is provided:
|
|
10
|
+
1. STOP IMMEDIATELY
|
|
11
|
+
2. Do NOT attempt to guess or infer a feature name
|
|
12
|
+
3. Ask the user to provide one
|
|
13
|
+
4. Do NOT proceed until a feature name is explicitly given
|
|
14
|
+
5. The feature name must be a single kebab-case token. If the user provides multiple words (e.g., "user auth flow"), convert to kebab-case: `user-auth-flow`.
|
|
15
|
+
|
|
16
|
+
## User Input Protocol
|
|
17
|
+
|
|
18
|
+
### CRITICAL GUARDRAIL: Use AskUserQuestion for All Questions
|
|
19
|
+
|
|
20
|
+
You MUST use the `AskUserQuestion` tool whenever you need the user's input before proceeding. This includes yes/no confirmations, choices between options, interview questions, and feedback on artifacts. NEVER output questions as inline prose text — the user may not be prompted and the session will stall.
|
|
21
|
+
|
|
22
|
+
**Required turn structure:** Output your analysis, findings, or context as regular text. Then call `AskUserQuestion` with your questions. Do NOT mix questions into your text output.
|
|
23
|
+
|
|
24
|
+
**WRONG — questions as inline prose (causes stalling):**
|
|
25
|
+
```
|
|
26
|
+
I found that the codebase uses React and TanStack Router. Here are my questions:
|
|
27
|
+
1. Where should this component live?
|
|
28
|
+
2. Should we use server-side rendering?
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**RIGHT — context as text, questions via tool:**
|
|
32
|
+
```
|
|
33
|
+
I found that the codebase uses React and TanStack Router.
|
|
34
|
+
[then call AskUserQuestion with: "1. Where should this component live? 2. Should we use server-side rendering?"]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Recommendations:** Only recommend a specific option when codebase evidence, established conventions, or strong technical rationale clearly favors it. If options are equally valid, present them neutrally — let the user decide without bias.
|
|
38
|
+
|
|
39
|
+
## Configuration Reading
|
|
40
|
+
|
|
41
|
+
Read `forge.config.json` from the project root. If it doesn't exist, use defaults.
|
|
42
|
+
|
|
43
|
+
If `forge.config.json` does not exist and no `.pipeline-state.json` files exist anywhere in `{specsDir}/`, suggest: "No forge.config.json found. Run `/feature-forge:forge-init` to create one with defaults, or I'll use built-in defaults. Want me to continue with defaults?"
|
|
44
|
+
|
|
45
|
+
Extract these config values (use defaults if not present):
|
|
46
|
+
- `specsDir` (default: `./specs`)
|
|
47
|
+
- `docsDir` (default: `./docs/architecture`)
|
|
48
|
+
- `backlogDir` (default: null — backlog lives at `{specsDir}/{feature}/backlog.json`; when `backlogDir` is configured, forge-4 composes `{backlogDir}/{feature}/`)
|
|
49
|
+
- `gitCommitAfterStage` (default: true)
|
|
50
|
+
- `commitPrefix` (default: `forge`)
|
|
51
|
+
- `loopIterationMultiplier` (default: `1.5`)
|
|
52
|
+
- `loopRunner` (optional object — the loop runner to drive; **defaults to rauf** when absent, with every command templated. See `references/forge-config-schema.json` and `references/ralph-loop-contract.md`.)
|
|
53
|
+
|
|
54
|
+
## Feature Directory Resolution
|
|
55
|
+
|
|
56
|
+
Before any file I/O against a feature's artifacts, resolve its directory through the deterministic helper rather than hardcoding `{specsDir}/{feature}/`. This makes flat (`{specsDir}/{feature}/`) and nested (`{specsDir}/{epic}/{feature}/`) layouts both resolve from a bare feature name (REQ-DIR-03), with standalone features behaving exactly as today.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
R="$(for d in "$HOME"/.claude/skills/feature-forge "$HOME"/.claude/plugins/*/feature-forge; do [ -x "$d/scripts/forge-root.sh" ] && exec "$d/scripts/forge-root.sh"; done)"
|
|
60
|
+
[ -n "$R" ] || { echo "feature-forge: cannot locate plugin root" >&2; exit 1; }
|
|
61
|
+
resolvedFeatureDir=$(python3 "$R/scripts/epic-manifest.py" \
|
|
62
|
+
resolve "<feature>" --specs-dir "<specsDir>")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- **Exit 0:** stdout is the absolute feature directory. Use it everywhere this skill previously wrote `{specsDir}/{feature}/`.
|
|
66
|
+
- **Exit 1:** the helper reports a structured finding (`not-found`, `ambiguous` — see `00-core-definitions.md §4`). Because this `resolve` call passes **no `--json`** (the subcommand has no such flag), the finding is a plain `not-found:`/`ambiguous:` line on **stderr** with empty stdout — there is no findings JSON to parse. **STOP** and surface that stderr line verbatim. (The `{valid, findings[]}`-on-stdout envelope is the `--json` shape used by `render-status`/`validate`, not by `resolve`.)
|
|
67
|
+
- **Exit 2:** a usage / safety error (`unsafe-name`, a path-containment escape, missing file). The message is a plain `Error: …` line on **stderr** with empty stdout — there is no findings JSON to parse. **STOP** and surface that stderr line verbatim.
|
|
68
|
+
|
|
69
|
+
In both failure cases, do not fall back to a guessed path.
|
|
70
|
+
|
|
71
|
+
**Resolution algorithm (summary; full spec in `02-manifest-helper-cli.md §4`):**
|
|
72
|
+
1. Reject the name if unsafe (path separator, `..`, absolute, or failing `SAFE_NAME_RE`) — before any filesystem access.
|
|
73
|
+
2. If `{specsDir}/{name}/.pipeline-state.json` exists → return that flat path.
|
|
74
|
+
3. Else if exactly one `{specsDir}/*/{name}/.pipeline-state.json` exists → return that nested path.
|
|
75
|
+
4. More than one match anywhere → `ambiguous` error listing all matching paths (uniqueness violation, REQ-DIR-04).
|
|
76
|
+
5. Zero matches → `not-found` error.
|
|
77
|
+
|
|
78
|
+
A directory counts as a **feature** only if it directly contains a `.pipeline-state.json` (the *feature-shaped-dir bound*, `00-core-definitions.md §6`). Non-feature subtrees (`.verification/`, `tests/`, fixture dirs, and the epic root itself — which holds `epic-manifest.json` but no `.pipeline-state.json`) are therefore never matched as features.
|
|
79
|
+
|
|
80
|
+
**Compatibility:** for a standalone feature the resolver returns its flat path with no epic logic engaged (REQ-COMPAT-01/02) — standalone-feature behavior is unchanged. A pre-existing latent name collision is reported for manual cleanup by the navigator / forge-verify epic mode (CHECK-E08), not by aborting an unrelated command whose name resolves to exactly one dir (tech-spec §3.4).
|
|
81
|
+
|
|
82
|
+
## Epic Context Injection
|
|
83
|
+
|
|
84
|
+
After resolving the feature directory, check the feature's `.pipeline-state.json` for an `epic` back-pointer. **If absent, skip this block entirely** (standalone feature — REQ-COMPAT-01; standalone-feature behavior is unchanged). **If present**, load exactly the following context, and nothing transitive (REQ-CTX-01):
|
|
85
|
+
|
|
86
|
+
1. **`{specsDir}/{epic}/EPIC.md`** — the epic narrative, including the per-feature Contracts sections.
|
|
87
|
+
2. **This feature's `charter`** — read from `{specsDir}/{epic}/epic-manifest.json` (the `features[]` entry whose `name` matches), together with its `exposes` and `consumes` arrays. These are the feature's **contract obligations** (REQ-CTX-02): what it must expose to dependents and what it consumes from dependencies.
|
|
88
|
+
3. **Direct completed dependencies only** — for each `name` in this feature's `dependsOn`, resolve that sibling's directory and, **only if it is complete-for-orchestration** (`00-core-definitions.md §7`), load its `PRD.md` and `tech-spec.md`.
|
|
89
|
+
|
|
90
|
+
**Do NOT load** transitive (indirect) dependencies' specs. Indirect contracts reach this feature only through the *direct* deps' Contracts sections in `EPIC.md`. This bounds context size and keeps the injected set deterministic (REQ-CTX-01).
|
|
91
|
+
|
|
92
|
+
To obtain the manifest contracts and the live completion status of each dependency in one deterministic call, run `render-status` and read the per-feature `status` and the `consumes`/`exposes` arrays rather than re-deriving them:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
R="$(for d in "$HOME"/.claude/skills/feature-forge "$HOME"/.claude/plugins/*/feature-forge; do [ -x "$d/scripts/forge-root.sh" ] && exec "$d/scripts/forge-root.sh"; done)"
|
|
96
|
+
[ -n "$R" ] || { echo "feature-forge: cannot locate plugin root" >&2; exit 1; }
|
|
97
|
+
python3 "$R/scripts/epic-manifest.py" \
|
|
98
|
+
render-status "<epic>" --specs-dir "<specsDir>" --json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
If `render-status` fails, proceed with **only** EPIC.md + charter (a corrupt manifest must not silently inject stale dep specs — REQ-ROBUST-02): on **exit 1**, parse the `{findings[]}` JSON from stdout and surface each; on **exit 2**, surface the plain `Error:` line from stderr verbatim. Do not attempt to parse findings JSON on an exit-2 failure (stdout is empty).
|
|
102
|
+
|
|
103
|
+
## Pipeline State Protocol
|
|
104
|
+
|
|
105
|
+
Write pipeline state conforming to `references/pipeline-state-schema.json`. Always update `updatedAt` when modifying pipeline state.
|
|
106
|
+
|
|
107
|
+
### Staleness Detection (Read-Time)
|
|
108
|
+
|
|
109
|
+
When loading upstream artifacts as prerequisites, check `basedOnVersions` in the pipeline state for this stage. If any upstream stage's current version is newer than the version recorded in `basedOnVersions`, warn the user before proceeding:
|
|
110
|
+
|
|
111
|
+
> "This stage was built against {upstream} v{old}, but {upstream} is now at v{new}. The current artifacts may be outdated. Consider re-running this stage, or use --force to proceed with potentially stale inputs."
|
|
112
|
+
|
|
113
|
+
## Git Commit Protocol
|
|
114
|
+
|
|
115
|
+
When `gitCommitAfterStage` is true, follow this exact order to avoid state inconsistency:
|
|
116
|
+
|
|
117
|
+
1. **Stage specific files only:** `git add {specsDir}/{feature}/` — never use `git add -A` or `git add .`
|
|
118
|
+
2. **Attempt commit:** `git commit -m "{commitPrefix}({feature}): <action>"`
|
|
119
|
+
3. **If commit succeeds:** capture the commit hash, then update pipeline state with `status: "complete"` and the `commitHash`
|
|
120
|
+
4. **If commit fails:** do NOT update pipeline state to complete. Report the error to the user and leave state as `in-progress` so the stage can be resumed. Common failure causes:
|
|
121
|
+
- **Pre-commit hook failure:** Report the hook output. Never use `--no-verify` to bypass. Help the user fix the underlying issue.
|
|
122
|
+
- **Merge conflicts:** Report conflicting files. Suggest resolution steps appropriate to the conflict.
|
|
123
|
+
- **Nothing to commit:** If all artifacts were already committed, this is fine — proceed with state update but note the absence of a new commit hash.
|
|
124
|
+
5. **Never** use `git add -A`, `--no-verify`, or `--force` flags
|
|
125
|
+
|
|
126
|
+
## Crash Recovery
|
|
127
|
+
|
|
128
|
+
When a skill detects that `currentStage` matches itself and the stage status is `in-progress`, a previous run was interrupted. Follow this recovery protocol:
|
|
129
|
+
|
|
130
|
+
1. **Inventory existing artifacts:** List all files on disk in `{specsDir}/{feature}/` that this stage would produce
|
|
131
|
+
2. **Compare against state:** Check the `artifacts` array in the pipeline state for this stage — it tracks files written incrementally during the previous run
|
|
132
|
+
3. **Present options to user:** "This stage was interrupted. Found {N} artifacts from the previous run: {list}. Would you like to resume from where it left off, or restart the stage from scratch?"
|
|
133
|
+
4. **If resume:** Skip artifact generation for files that already exist and appear complete (non-empty, properly structured). Continue from the next unwritten artifact.
|
|
134
|
+
5. **If restart:** Proceed normally. The version number will increment.
|
|
135
|
+
|
|
136
|
+
**Incremental artifact tracking:** When a stage writes multiple files (e.g., forge-3-specs writing a suite of spec documents), update the `artifacts` array in `.pipeline-state.json` after writing each file — not just at stage completion. This ensures crash recovery knows exactly which files were successfully written.
|
|
137
|
+
|
|
138
|
+
## Force Mode
|
|
139
|
+
|
|
140
|
+
If the user passes `--force` as an argument, skip prerequisite validation with a warning:
|
|
141
|
+
|
|
142
|
+
> Force mode: skipping prerequisite checks. Pipeline state tracking may be incomplete. Recommend running `/feature-forge:forge {feature}` after to verify status.
|
|
143
|
+
|
|
144
|
+
Continue with the stage even if prior stages are not marked complete. Still read any existing artifacts (PRD.md, tech-spec.md, etc.) if they exist on disk — force mode skips the pipeline state check, not the artifact loading.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/garygentry/feature-forge/references/skill-frontmatter.schema.json",
|
|
4
|
+
"title": "feature-forge canonical SKILL.md frontmatter",
|
|
5
|
+
"description": "Spec-pure frontmatter for canonical skills/*/SKILL.md. Source of truth for the allowed/required key sets loaded by scripts/check-spec-purity.py. NO version key (REQ-VER-03): versions live in manifests only.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["name", "description"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": { "type": "string" },
|
|
11
|
+
"description": { "type": "string" },
|
|
12
|
+
"license": { "type": "string" },
|
|
13
|
+
"compatibility": {},
|
|
14
|
+
"metadata": { "type": "object" },
|
|
15
|
+
"allowed-tools": {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Stack Resolution Protocol
|
|
2
|
+
|
|
3
|
+
How feature-forge resolves stack-specific guidance for a project.
|
|
4
|
+
|
|
5
|
+
## Resolution Order (highest priority first)
|
|
6
|
+
|
|
7
|
+
1. **Project-level override**: `.claude/references/stack-decisions.md` in the project root. If this file exists, it takes absolute precedence — it contains the team's explicit technology decisions.
|
|
8
|
+
|
|
9
|
+
2. **Detected stack profile**: `references/stacks/{stack}.md` in this plugin, where `{stack}` matches the `stack` field in `forge.config.json`. Provides language-specific conventions for spec writing, verification, and examples.
|
|
10
|
+
|
|
11
|
+
3. **Generic fallback**: `references/stacks/_generic.md` in this plugin. Language-neutral guidance that works for any stack. Used when no stack is detected or no matching profile exists.
|
|
12
|
+
|
|
13
|
+
## How Stack Detection Works
|
|
14
|
+
|
|
15
|
+
Stack detection happens during **forge-2-tech** (the technical specification stage), which is the natural point where technology decisions are made.
|
|
16
|
+
|
|
17
|
+
1. The agent examines the project's root manifest and build files
|
|
18
|
+
2. Identifies the primary language, build tool, package manager, and framework
|
|
19
|
+
3. Asks the user to confirm: "I detected this as a {stack} project. Correct?"
|
|
20
|
+
4. Persists the stack identity in `forge.config.json` via the `stack`, `typeCheckCommand`, and `testCommand` fields
|
|
21
|
+
5. All downstream stages (forge-3-specs, forge-4-backlog, forge-verify, forge-6-docs) read the `stack` field and load the matching profile
|
|
22
|
+
|
|
23
|
+
## forge.config.json Fields
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"stack": "typescript",
|
|
28
|
+
"typeCheckCommand": "bun run typecheck",
|
|
29
|
+
"testCommand": "bun test"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `stack` — Identifier matching a profile filename in `references/stacks/` (e.g., "typescript", "python", "go")
|
|
34
|
+
- `typeCheckCommand` — Used in acceptance criteria and verification checks. Null if the stack has no type checker.
|
|
35
|
+
- `testCommand` — Used in acceptance criteria and verification checks.
|
|
36
|
+
|
|
37
|
+
## Available Profiles
|
|
38
|
+
|
|
39
|
+
| Profile | File | Covers |
|
|
40
|
+
|---------|------|--------|
|
|
41
|
+
| TypeScript | `references/stacks/typescript.md` | Node.js/Bun, npm/pnpm/bun, monorepo patterns, TS-specific spec conventions |
|
|
42
|
+
| Python | `references/stacks/python.md` | Python 3.10+, pip/uv/poetry, pytest, type hints, Pydantic/dataclasses |
|
|
43
|
+
| Generic | `references/stacks/_generic.md` | Any stack — language-neutral guidance using placeholders |
|
|
44
|
+
|
|
45
|
+
## When No Stack Is Configured
|
|
46
|
+
|
|
47
|
+
If `forge.config.json` has no `stack` field and forge-2-tech hasn't run yet (e.g., when using `--force`), skills should:
|
|
48
|
+
|
|
49
|
+
1. Attempt basic detection from project files (look for manifest files)
|
|
50
|
+
2. Use `_generic.md` as fallback
|
|
51
|
+
3. Note in the pipeline state that stack detection was skipped
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Generic Stack Profile
|
|
2
|
+
|
|
3
|
+
Language-neutral guidance for projects without a dedicated stack profile. Use this as a fallback when no matching `references/stacks/{stack}.md` exists.
|
|
4
|
+
|
|
5
|
+
## Discovery Protocol
|
|
6
|
+
|
|
7
|
+
Identify the project's stack by checking for these manifest and build files:
|
|
8
|
+
|
|
9
|
+
| File | Stack |
|
|
10
|
+
|------|-------|
|
|
11
|
+
| `package.json` | Node.js / Bun (JavaScript/TypeScript) |
|
|
12
|
+
| `pyproject.toml`, `setup.py`, `setup.cfg` | Python |
|
|
13
|
+
| `go.mod` | Go |
|
|
14
|
+
| `Cargo.toml` | Rust |
|
|
15
|
+
| `pom.xml`, `build.gradle`, `build.gradle.kts` | Java / Kotlin |
|
|
16
|
+
| `*.csproj`, `*.sln` | .NET (C#/F#) |
|
|
17
|
+
| `mix.exs` | Elixir |
|
|
18
|
+
| `Gemfile` | Ruby |
|
|
19
|
+
| `Package.swift` | Swift |
|
|
20
|
+
|
|
21
|
+
Also check for:
|
|
22
|
+
- **Lock files**: Reveal the package manager (`bun.lockb`, `uv.lock`, `poetry.lock`, `go.sum`, `Cargo.lock`, etc.)
|
|
23
|
+
- **Workspace/monorepo configs**: `turbo.json`, `nx.json`, `lerna.json`, `pants.toml`, `Cargo workspace`, Go workspace `go.work`
|
|
24
|
+
- **CI configuration**: `.github/workflows/`, `Makefile`, `justfile` — often reveals build and test commands
|
|
25
|
+
|
|
26
|
+
## Archetype Adaptations
|
|
27
|
+
|
|
28
|
+
### 00-core-definitions.md
|
|
29
|
+
|
|
30
|
+
The shared type/data contract document. Language-neutral name for what TypeScript calls "core types and interfaces." Contents should include:
|
|
31
|
+
|
|
32
|
+
- **Data structures**: The primary types, classes, structs, records, or models that define the feature's domain. Use the project's idiomatic type system (dataclasses, structs, interfaces, schemas, etc.)
|
|
33
|
+
- **Error/exception hierarchy**: Base error type and domain-specific subtypes with structured properties. Every language has a mechanism for this (exception classes, error types, Result enums, etc.)
|
|
34
|
+
- **Constants and enumerations**: Shared values referenced across the feature
|
|
35
|
+
- **Public contracts**: Function signatures, protocols, interfaces, or traits that define the feature's API surface
|
|
36
|
+
|
|
37
|
+
**Documentation rule**: Every type/structure must have documentation comments in the project's convention (JSDoc, docstrings, godoc, rustdoc, etc.)
|
|
38
|
+
|
|
39
|
+
**Export rule**: Everything must be accessible through the module's entry point following project conventions.
|
|
40
|
+
|
|
41
|
+
### 01-architecture-layout.md
|
|
42
|
+
|
|
43
|
+
How the feature is structured in the project:
|
|
44
|
+
|
|
45
|
+
- **Directory tree**: Full layout (not abbreviated)
|
|
46
|
+
- **Project manifest**: Dependencies, entry points, build scripts
|
|
47
|
+
- **Build/compiler configuration**: Key options
|
|
48
|
+
- **Module export structure**: What each entry point exposes
|
|
49
|
+
- **Build and deployment considerations**
|
|
50
|
+
|
|
51
|
+
### NN-testing-strategy.md
|
|
52
|
+
|
|
53
|
+
- **Testing framework and tooling**: Match project conventions
|
|
54
|
+
- **Unit test approach**: What to test, what to mock/stub
|
|
55
|
+
- **Integration test approach**: Cross-module interaction testing
|
|
56
|
+
- **Test fixtures and factories**
|
|
57
|
+
- **Coverage targets**
|
|
58
|
+
- **Test file location conventions**
|
|
59
|
+
|
|
60
|
+
## Spec Conventions
|
|
61
|
+
|
|
62
|
+
When writing implementation specs:
|
|
63
|
+
- Include complete type definitions and function signatures in the project's language — not pseudocode
|
|
64
|
+
- Include documentation comments on every public type and function
|
|
65
|
+
- Include error handling for every operation
|
|
66
|
+
- Include example usage where it aids clarity
|
|
67
|
+
- Cross-reference other spec documents by filename
|
|
68
|
+
|
|
69
|
+
## Verification Adaptations
|
|
70
|
+
|
|
71
|
+
Replace stack-specific checks with these generic equivalents:
|
|
72
|
+
|
|
73
|
+
| Stack-specific check | Generic equivalent |
|
|
74
|
+
|---------------------|-------------------|
|
|
75
|
+
| "Valid TypeScript syntax" | "Valid syntax in the project's language" |
|
|
76
|
+
| "Barrel exports (index.ts)" | "Module exports/entry points follow project conventions" |
|
|
77
|
+
| "bun run typecheck passes" | "`{typeCheckCommand}` passes" (from forge.config.json) |
|
|
78
|
+
| "bun test passes" | "`{testCommand}` passes" (from forge.config.json) |
|
|
79
|
+
| "JSDoc on every field" | "Documentation comments on every field" |
|
|
80
|
+
| "tsconfig.json extends root" | "Build configuration follows project conventions" |
|
|
81
|
+
|
|
82
|
+
## Acceptance Criteria Patterns
|
|
83
|
+
|
|
84
|
+
Use these placeholder patterns in backlog items. Replace `{typeCheckCommand}`, `{testCommand}`, and `{module}` with values from `forge.config.json` and the project structure:
|
|
85
|
+
|
|
86
|
+
- `{typeCheckCommand} passes for {module}`
|
|
87
|
+
- `{testCommand} passes for {module}`
|
|
88
|
+
- `{module}/[entry point] exports [expected symbols]`
|
|
89
|
+
- `[dependency manifest] includes [new dependency]`
|
|
90
|
+
- `[build command] succeeds`
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Go Stack Profile
|
|
2
|
+
|
|
3
|
+
Stack-specific guidance for Go projects (1.21+).
|
|
4
|
+
|
|
5
|
+
## Stack Identity
|
|
6
|
+
|
|
7
|
+
- **Language**: Go 1.21+ (required for `slog` stdlib logging, `slices`/`maps` packages, improved generics)
|
|
8
|
+
- **Build system**: `go build`, `go install` (no external build tool required)
|
|
9
|
+
- **Module system**: Go modules (`go.mod` / `go.sum`)
|
|
10
|
+
- **Philosophy**: Simplicity-first — prefer the standard library, add dependencies only when justified
|
|
11
|
+
|
|
12
|
+
## Discovery Checklist
|
|
13
|
+
|
|
14
|
+
When examining a Go project, check for:
|
|
15
|
+
|
|
16
|
+
- **Module definition**: `go.mod` (module path, Go version, dependencies)
|
|
17
|
+
- **Dependency lock**: `go.sum` (checksums for reproducible builds)
|
|
18
|
+
- **Entry points**: `cmd/` directory (for CLIs, services, or multiple binaries)
|
|
19
|
+
- **Private packages**: `internal/` directory (compiler-enforced encapsulation)
|
|
20
|
+
- **Public packages**: `pkg/` directory (if used — not all projects follow this convention)
|
|
21
|
+
- **Build automation**: `Makefile`, `Taskfile.yml`, `mage` targets
|
|
22
|
+
- **Configuration**: `.golangci.yml` or `.golangci.yaml` (linter config)
|
|
23
|
+
- **Code generation**: `go generate` directives, `//go:generate` comments, `tools.go` for tool dependencies
|
|
24
|
+
- **Framework**: Check imports for chi, gin, echo, fiber (routers), or stdlib `net/http`
|
|
25
|
+
- **Database**: Check for sqlx, pgx, ent, gorm, or `database/sql`
|
|
26
|
+
|
|
27
|
+
## Archetype Conventions
|
|
28
|
+
|
|
29
|
+
### 00-core-definitions.md (Go)
|
|
30
|
+
|
|
31
|
+
- **Structs**: Use `struct` types with json/db tags (e.g., `` `json:"name" db:"name"` ``). Document every exported field with a comment.
|
|
32
|
+
- **Interfaces**: Keep small and behavior-focused (1–3 methods). Define at the consumer site, not the implementation site. Name with `-er` suffix where natural (e.g., `Reader`, `Validator`).
|
|
33
|
+
- **Error types**: Custom types implementing the `error` interface. Use `errors.New` for sentinel errors, `fmt.Errorf` with `%w` for wrapping. Group domain errors in a dedicated `errors.go` file.
|
|
34
|
+
- **Constants**: Use `iota` for sequential constants, typed constants for domain values, `const` blocks for related groups
|
|
35
|
+
- **Type aliases and generics**: Use sparingly. Generic types when the abstraction genuinely applies across multiple concrete types.
|
|
36
|
+
- **No barrel exports**: Go uses package-level visibility (`Exported` vs `unexported`); there is no index file pattern.
|
|
37
|
+
|
|
38
|
+
### 01-architecture-layout.md (Go)
|
|
39
|
+
|
|
40
|
+
- **Standard project layout**:
|
|
41
|
+
- `cmd/<binary-name>/main.go` — entry points (one per binary)
|
|
42
|
+
- `internal/` — private application code (compiler-enforced)
|
|
43
|
+
- `pkg/` — public library code (optional, some projects skip this)
|
|
44
|
+
- `api/` — OpenAPI specs, protobuf definitions, API contracts
|
|
45
|
+
- `configs/` — configuration file templates
|
|
46
|
+
- `scripts/` — build, install, analysis scripts
|
|
47
|
+
- **go.mod**: Module path matching the repo URL (e.g., `github.com/user/repo`), minimum Go version, direct and indirect dependencies
|
|
48
|
+
- **Package design**: One package per directory, package name matches directory name, package-level `doc.go` for documentation
|
|
49
|
+
- **Build considerations**: Cross-compilation with `GOOS`/`GOARCH`, build tags for platform-specific code, `ldflags` for version injection
|
|
50
|
+
|
|
51
|
+
### NN-testing-strategy.md (Go)
|
|
52
|
+
|
|
53
|
+
- **Framework**: `testing` package from stdlib (no external framework required)
|
|
54
|
+
- **Test file location**: `*_test.go` files in the same package (white-box) or `_test` package suffix (black-box)
|
|
55
|
+
- **Table-driven tests**: Standard pattern using slice of test structs with `t.Run()` subtests
|
|
56
|
+
- **Test helpers**: Functions accepting `testing.TB` with `t.Helper()` call at top
|
|
57
|
+
- **Mocking**: Interfaces + manual mocks, or testify/mock, gomock, mockgen if project uses them
|
|
58
|
+
- **Assertions**: stdlib `if got != want` pattern, or testify `assert`/`require` if project uses it
|
|
59
|
+
- **Integration tests**: Build tags (`//go:build integration`) to separate from unit tests
|
|
60
|
+
- **Benchmarks**: `func BenchmarkXxx(b *testing.B)` with `b.N` loop
|
|
61
|
+
- **Test fixtures**: `testdata/` directory (ignored by Go tooling), `TestMain` for setup/teardown
|
|
62
|
+
|
|
63
|
+
## Spec Quality Rules
|
|
64
|
+
|
|
65
|
+
- All Go code must be valid syntax with complete type information — not pseudocode
|
|
66
|
+
- Follow Go idioms:
|
|
67
|
+
- Return `error` as the last return value — never panic for expected failures
|
|
68
|
+
- Accept interfaces, return structs (depend on behavior, produce concrete types)
|
|
69
|
+
- Design meaningful zero values (a zero-valued struct should be usable or clearly invalid)
|
|
70
|
+
- No getters — use the field name directly (e.g., `user.Name` not `user.GetName()`)
|
|
71
|
+
- Use embedding for composition, not inheritance
|
|
72
|
+
- `context.Context` as the first parameter for any function that may block or be cancelled
|
|
73
|
+
- `error` as the last return value for any function that can fail
|
|
74
|
+
- Include complete function signatures with named return values where they improve clarity
|
|
75
|
+
- Document every exported type, function, and method with a comment starting with the identifier name
|
|
76
|
+
- Use `//nolint` directives only with a justification comment
|
|
77
|
+
|
|
78
|
+
## Verification Specifics
|
|
79
|
+
|
|
80
|
+
- **Static analysis**: `go vet ./...` (catches common mistakes)
|
|
81
|
+
- **Linting**: `golangci-lint run` (if `.golangci.yml` exists or CI uses it)
|
|
82
|
+
- **Testing**: `go test ./...` (all packages)
|
|
83
|
+
- **Building**: `go build ./...` (ensures all packages compile)
|
|
84
|
+
- **Formatting**: `gofmt -l .` or `goimports -l .` (should produce no output)
|
|
85
|
+
- **Module tidiness**: `go mod tidy` (ensures `go.mod` and `go.sum` are consistent)
|
|
86
|
+
|
|
87
|
+
## Testing
|
|
88
|
+
|
|
89
|
+
- **Framework**: `testing` stdlib package
|
|
90
|
+
- **Test command**: `go test ./...` for all, `go test -v -run TestName ./pkg/...` for specific
|
|
91
|
+
- **Table-driven tests**: Idiomatic pattern — slice of anonymous structs with `name`, input, and expected fields
|
|
92
|
+
- **Subtests**: `t.Run("case name", func(t *testing.T) { ... })` for grouped assertions
|
|
93
|
+
- **Assertions**: testify `assert`/`require` (if project uses it), otherwise manual `if` checks with `t.Errorf`
|
|
94
|
+
- **Coverage**: `go test -coverprofile=coverage.out ./...` then `go tool cover -html=coverage.out`
|
|
95
|
+
- **Race detection**: `go test -race ./...` for concurrency safety
|
|
96
|
+
- **Fuzzing**: `func FuzzXxx(f *testing.F)` (Go 1.18+)
|
|
97
|
+
|
|
98
|
+
## Common Frameworks
|
|
99
|
+
|
|
100
|
+
| Category | Options |
|
|
101
|
+
|----------|---------|
|
|
102
|
+
| HTTP router | net/http (stdlib), chi, gin, echo, fiber |
|
|
103
|
+
| Database | database/sql (stdlib), sqlx, pgx, ent, gorm |
|
|
104
|
+
| Migrations | golang-migrate, goose, atlas |
|
|
105
|
+
| CLI | cobra, urfave/cli, kong |
|
|
106
|
+
| Logging | log/slog (stdlib), zerolog, zap |
|
|
107
|
+
| Configuration | viper, envconfig, koanf |
|
|
108
|
+
| Dependency injection | wire, fx, dig |
|
|
109
|
+
| gRPC | google.golang.org/grpc, connect-go |
|
|
110
|
+
| Testing | testify, gomock, go-cmp |
|
|
111
|
+
|
|
112
|
+
## Example: Project-Level Override
|
|
113
|
+
|
|
114
|
+
Create `.claude/references/stack-decisions.md` in your project root:
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+
# Stack Decisions
|
|
118
|
+
|
|
119
|
+
## Runtime & Build
|
|
120
|
+
- Go 1.22 with standard go toolchain
|
|
121
|
+
- Makefile for build automation
|
|
122
|
+
|
|
123
|
+
## Backend
|
|
124
|
+
- chi for HTTP routing
|
|
125
|
+
- sqlx with PostgreSQL
|
|
126
|
+
- log/slog for structured logging
|
|
127
|
+
|
|
128
|
+
## Testing
|
|
129
|
+
- testify for assertions and mocking
|
|
130
|
+
- Table-driven tests with t.Run() subtests
|
|
131
|
+
- Build tag `integration` for integration tests
|
|
132
|
+
|
|
133
|
+
## Conventions
|
|
134
|
+
- Standard project layout (cmd/, internal/, pkg/)
|
|
135
|
+
- golangci-lint with project .golangci.yml
|
|
136
|
+
- Context as first parameter, error as last return
|
|
137
|
+
- Interfaces defined at consumer site
|
|
138
|
+
```
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Python Stack Profile
|
|
2
|
+
|
|
3
|
+
Stack-specific guidance for Python projects (3.10+).
|
|
4
|
+
|
|
5
|
+
## Stack Identity
|
|
6
|
+
|
|
7
|
+
- **Language**: Python 3.10+ (required for modern type hint syntax: `X | Y` unions, `match` statements)
|
|
8
|
+
- **Package management**: pip, uv, poetry, pdm, or pipenv (check for respective lock/config files)
|
|
9
|
+
- **Type checking**: mypy, pyright, or pytype
|
|
10
|
+
- **Linting**: ruff, flake8, pylint
|
|
11
|
+
|
|
12
|
+
## Discovery Checklist
|
|
13
|
+
|
|
14
|
+
When examining a Python project, check for:
|
|
15
|
+
|
|
16
|
+
- **Project manifest**: `pyproject.toml` (modern), `setup.py`/`setup.cfg` (legacy), `requirements.txt` (minimal)
|
|
17
|
+
- **Package manager**: `uv.lock` (uv), `poetry.lock` (poetry), `pdm.lock` (pdm), `Pipfile.lock` (pipenv)
|
|
18
|
+
- **Monorepo**: `pants.toml` (Pants), `BUILD` files (Bazel), `nx.json` with Python plugins, or plain workspace structure
|
|
19
|
+
- **Framework**: FastAPI, Django, Flask, Starlette, Litestar
|
|
20
|
+
- **Database**: SQLAlchemy, Django ORM, Tortoise ORM, SQLModel
|
|
21
|
+
- **Validation**: Pydantic, attrs, marshmallow
|
|
22
|
+
- **Testing**: pytest (dominant), unittest
|
|
23
|
+
- **Type checking**: `mypy.ini`, `pyrightconfig.json`, or `[tool.mypy]` / `[tool.pyright]` in `pyproject.toml`
|
|
24
|
+
|
|
25
|
+
## Archetype Conventions
|
|
26
|
+
|
|
27
|
+
### 00-core-definitions.md (Python)
|
|
28
|
+
|
|
29
|
+
- **Data structures**: Use `dataclasses` for simple data containers, Pydantic `BaseModel` for validated/serializable models. Use `TypedDict` for dict-shaped data.
|
|
30
|
+
- **Type aliases**: Use `type` statements (3.12+) or `TypeAlias` annotation
|
|
31
|
+
- **Union types**: Use `X | Y` syntax (3.10+)
|
|
32
|
+
- **Protocols**: Use `typing.Protocol` for structural subtyping (Python's equivalent of interfaces)
|
|
33
|
+
- **Error/exception hierarchy**: Base exception class inheriting from `Exception` (or a more specific built-in); domain-specific subclasses with typed attributes
|
|
34
|
+
- **Constants and enumerations**: Use `enum.Enum`, `enum.StrEnum`, or module-level constants with `Final` annotation
|
|
35
|
+
- **Module exports**: Define `__all__` in `__init__.py` for explicit public API
|
|
36
|
+
|
|
37
|
+
### 01-architecture-layout.md (Python)
|
|
38
|
+
|
|
39
|
+
- **Project layout**: `src/` layout (recommended) or flat layout
|
|
40
|
+
- **pyproject.toml**: `[project]` table with `name`, `dependencies`, `optional-dependencies`, `[project.scripts]` for CLI entry points
|
|
41
|
+
- **Tool configuration**: `[tool.pytest.ini_options]`, `[tool.mypy]`, `[tool.ruff]` sections in `pyproject.toml`
|
|
42
|
+
- **Module entry points**: `__init__.py` files with explicit `__all__` lists for re-exports
|
|
43
|
+
- **Namespace packages**: When applicable, `py.typed` marker for PEP 561 compliance
|
|
44
|
+
|
|
45
|
+
### Monorepo conventions (if applicable)
|
|
46
|
+
|
|
47
|
+
- **Workspace structure**: `packages/` or `libs/` directories with individual `pyproject.toml` per package
|
|
48
|
+
- **Internal dependencies**: Path dependencies in `pyproject.toml` or editable installs
|
|
49
|
+
- **Build coordination**: Pants, Bazel, or Makefile-based orchestration
|
|
50
|
+
|
|
51
|
+
## Spec Quality Rules
|
|
52
|
+
|
|
53
|
+
- All Python code must be valid syntax with complete type annotations — not pseudocode
|
|
54
|
+
- Use Google-style or NumPy-style docstrings consistently (match project convention)
|
|
55
|
+
- Include `Args`, `Returns`, `Raises` sections in docstrings for every public function
|
|
56
|
+
- Use `Protocol` classes to define interfaces/contracts
|
|
57
|
+
- Include explicit import statements in all code examples
|
|
58
|
+
- Use `async def` for asynchronous operations where applicable
|
|
59
|
+
|
|
60
|
+
### Example: Well-Specified Function
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
class SessionExpiredError(AuthError):
|
|
64
|
+
"""Raised when a session token has expired.
|
|
65
|
+
|
|
66
|
+
Attributes:
|
|
67
|
+
expired_at: When the session expired.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def __init__(self, expired_at: datetime) -> None:
|
|
71
|
+
self.expired_at = expired_at
|
|
72
|
+
super().__init__(
|
|
73
|
+
code="SESSION_EXPIRED",
|
|
74
|
+
message=f"Session expired at {expired_at.isoformat()}",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
async def refresh_session_token(
|
|
79
|
+
current_token: str,
|
|
80
|
+
*,
|
|
81
|
+
max_age: timedelta = SESSION_DURATION,
|
|
82
|
+
refresh_threshold: timedelta = REFRESH_THRESHOLD,
|
|
83
|
+
signing_key: bytes,
|
|
84
|
+
) -> str | None:
|
|
85
|
+
"""Refresh a session token if it's within the refresh threshold.
|
|
86
|
+
|
|
87
|
+
Returns a new token with an extended expiry, or None if the session
|
|
88
|
+
is not eligible for refresh (valid but outside threshold).
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
current_token: The JWT string from the session cookie.
|
|
92
|
+
max_age: Maximum age of a token eligible for refresh.
|
|
93
|
+
refresh_threshold: How close to expiry before refresh is allowed.
|
|
94
|
+
signing_key: Secret key for signing the new token.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
New session token string, or None if refresh is not possible.
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
SessionExpiredError: If the token has already expired.
|
|
101
|
+
TokenValidationError: If the token signature is invalid.
|
|
102
|
+
"""
|
|
103
|
+
...
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Verification Specifics
|
|
107
|
+
|
|
108
|
+
- **Type checking**: `mypy .`, `mypy src/`, `pyright`, or `pyright src/`
|
|
109
|
+
- **Linting**: `ruff check .` or `flake8`
|
|
110
|
+
- **Formatting**: `ruff format --check .` or `black --check .`
|
|
111
|
+
- **Import validation**: `mypy` with `--strict` or `--disallow-untyped-defs` catches missing type annotations
|
|
112
|
+
- **Module export validation**: `__all__` lists in `__init__.py` match spec's public API
|
|
113
|
+
|
|
114
|
+
## Testing
|
|
115
|
+
|
|
116
|
+
- **Framework**: pytest (with `conftest.py` for fixtures)
|
|
117
|
+
- **Fixtures**: Define in `conftest.py` at appropriate scope (session, module, function)
|
|
118
|
+
- **Mocking**: `unittest.mock.patch`, `monkeypatch` fixture, or `pytest-mock`
|
|
119
|
+
- **Coverage**: `pytest-cov` with `--cov=src/` flag
|
|
120
|
+
- **Test file location**: `tests/` directory mirroring `src/` structure, or co-located `test_*.py` files
|
|
121
|
+
- **Async testing**: `pytest-asyncio` for async function tests
|
|
122
|
+
- **Type testing**: Runtime checks with `isinstance()`, static checks with `reveal_type()`
|
|
123
|
+
|
|
124
|
+
## Common Frameworks
|
|
125
|
+
|
|
126
|
+
| Category | Options |
|
|
127
|
+
|----------|---------|
|
|
128
|
+
| Web (async) | FastAPI, Starlette, Litestar |
|
|
129
|
+
| Web (sync) | Django, Flask |
|
|
130
|
+
| Database ORM | SQLAlchemy, Django ORM, SQLModel, Tortoise ORM |
|
|
131
|
+
| Migrations | Alembic (SQLAlchemy), Django migrations |
|
|
132
|
+
| Validation | Pydantic, attrs, marshmallow |
|
|
133
|
+
| Task queues | Celery, Dramatiq, Huey, ARQ |
|
|
134
|
+
| CLI | Click, Typer, argparse |
|
|
135
|
+
| HTTP client | httpx, aiohttp, requests |
|
|
136
|
+
|
|
137
|
+
## Example: Project-Level Override
|
|
138
|
+
|
|
139
|
+
Create `.claude/references/stack-decisions.md` in your project root:
|
|
140
|
+
|
|
141
|
+
```markdown
|
|
142
|
+
# Stack Decisions
|
|
143
|
+
|
|
144
|
+
## Runtime & Build
|
|
145
|
+
- Python 3.12 with uv for package management
|
|
146
|
+
- src/ layout with pyproject.toml
|
|
147
|
+
|
|
148
|
+
## Backend
|
|
149
|
+
- FastAPI for HTTP framework
|
|
150
|
+
- SQLAlchemy 2.0 with PostgreSQL (async)
|
|
151
|
+
- Pydantic v2 for validation and serialization
|
|
152
|
+
|
|
153
|
+
## Testing
|
|
154
|
+
- pytest with pytest-asyncio
|
|
155
|
+
- Factory Boy for test fixtures
|
|
156
|
+
- Coverage target: 90%
|
|
157
|
+
|
|
158
|
+
## Conventions
|
|
159
|
+
- Google-style docstrings
|
|
160
|
+
- ruff for linting and formatting
|
|
161
|
+
- mypy with --strict for type checking
|
|
162
|
+
- __all__ exports in every __init__.py
|
|
163
|
+
```
|