@geminix/gxpm 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/AGENTS.md +148 -0
- package/CANON.md +53 -0
- package/CLAUDE.md +60 -0
- package/CONTEXT.md +49 -0
- package/DEBUG.md +59 -0
- package/ISSUE_CONTEXT.md +25 -0
- package/README.md +143 -0
- package/VERSION +1 -0
- package/agents/cleanup-auditor/cleanup-auditor.md +56 -0
- package/agents/grill-master.md +26 -0
- package/agents/implementer.md +32 -0
- package/agents/review-army/accessibility-reviewer.md +54 -0
- package/agents/review-army/code-quality-reviewer.md +54 -0
- package/agents/review-army/security-reviewer.md +56 -0
- package/agents/review-army/spec-compliance-reviewer.md +51 -0
- package/agents/review-army/test-reviewer.md +55 -0
- package/agents/reviewer.md +59 -0
- package/agents/ship-audit-army/docs-auditor.md +53 -0
- package/agents/ship-audit-army/performance-auditor.md +52 -0
- package/agents/ship-audit-army/security-auditor.md +52 -0
- package/agents/specifier.md +55 -0
- package/agents/triage-officer.md +27 -0
- package/bin/gxpm +17 -0
- package/bin/gxpm-browser +17 -0
- package/bin/gxpm-config +15 -0
- package/bin/gxpm-eval +13 -0
- package/bin/gxpm-global-discover +15 -0
- package/bin/gxpm-init +38 -0
- package/bin/gxpm-investigate +194 -0
- package/bin/gxpm-uninstall +15 -0
- package/bin/gxpm-update-check +165 -0
- package/commands/build.md +40 -0
- package/commands/help.md +53 -0
- package/commands/plan.md +34 -0
- package/commands/refine.md +46 -0
- package/commands/review.md +34 -0
- package/commands/ship.md +37 -0
- package/core/ac-check.ts +20 -0
- package/core/agent-runtime.ts +363 -0
- package/core/artifact-validator.ts +151 -0
- package/core/artifacts.ts +313 -0
- package/core/autopilot.ts +250 -0
- package/core/capabilities.ts +779 -0
- package/core/checkpoint.ts +370 -0
- package/core/cleanup.ts +32 -0
- package/core/command-probe.ts +82 -0
- package/core/config.ts +533 -0
- package/core/contracts/behavior-spec.schema.ts +38 -0
- package/core/contracts/converter.ts +61 -0
- package/core/contracts/host.ts +43 -0
- package/core/converters/converter.ts +93 -0
- package/core/converters/index.ts +8 -0
- package/core/converters/managed-artifact.ts +119 -0
- package/core/converters/parser.ts +159 -0
- package/core/converters/template-renderer.ts +35 -0
- package/core/converters/writer.ts +61 -0
- package/core/dag-executor.ts +426 -0
- package/core/dag-loader.ts +292 -0
- package/core/dag-schemas.ts +150 -0
- package/core/dispatch.ts +125 -0
- package/core/evidence.ts +148 -0
- package/core/gate.ts +269 -0
- package/core/hook-engine.ts +566 -0
- package/core/host-probe.ts +64 -0
- package/core/implement.ts +16 -0
- package/core/isolation-errors.ts +174 -0
- package/core/isolation-resolver.ts +921 -0
- package/core/issue-context.ts +381 -0
- package/core/issue-readiness.ts +457 -0
- package/core/issue-sync.ts +427 -0
- package/core/issues.ts +132 -0
- package/core/land.ts +108 -0
- package/core/orchestrator.ts +54 -0
- package/core/phase-artifact.ts +32 -0
- package/core/phase-gates.ts +130 -0
- package/core/phase-rewind.ts +94 -0
- package/core/plan-lint.ts +61 -0
- package/core/plan.ts +77 -0
- package/core/port-allocation.ts +50 -0
- package/core/pr-check.ts +15 -0
- package/core/preset-system/preset-resolver.ts +221 -0
- package/core/project-init-status.ts +127 -0
- package/core/qa.ts +15 -0
- package/core/resilience.ts +165 -0
- package/core/runs.ts +288 -0
- package/core/safe-path.test.ts +80 -0
- package/core/safe-path.ts +60 -0
- package/core/sdd-gate.test.ts +98 -0
- package/core/sdd-gate.ts +134 -0
- package/core/self-review.ts +62 -0
- package/core/session.ts +70 -0
- package/core/ship.ts +86 -0
- package/core/specify.ts +173 -0
- package/core/state.ts +1002 -0
- package/core/template-engine.ts +152 -0
- package/core/template-resolver.test.ts +70 -0
- package/core/template-resolver.ts +156 -0
- package/core/triage.ts +26 -0
- package/core/verify.ts +15 -0
- package/core/wiki-native.ts +2423 -0
- package/core/wiki.ts +27 -0
- package/core/workflow-event-emitter.ts +163 -0
- package/core/workflows/engine.ts +273 -0
- package/core/workflows/expressions.ts +76 -0
- package/core/workflows/index.ts +38 -0
- package/core/workflows/steps/command.ts +43 -0
- package/core/workflows/steps/gate.ts +47 -0
- package/core/workflows/steps/gxpm.ts +44 -0
- package/core/workflows/steps/linear.ts +31 -0
- package/core/workflows/steps/shell.ts +65 -0
- package/core/workflows/types.ts +62 -0
- package/core/workspace-runtime.ts +227 -0
- package/core/worktree-init-steps.ts +647 -0
- package/core/worktree-init.ts +330 -0
- package/core/worktree-owner.ts +143 -0
- package/docs/GXPM_VERIFY.md +98 -0
- package/docs/INSTALL_FOR_AGENTS.md +113 -0
- package/docs/README.md +57 -0
- package/docs/adr/adr-005-multi-platform-skill-converter.md +72 -0
- package/docs/agents/domain.md +30 -0
- package/docs/agents/issue-tracker.md +30 -0
- package/docs/agents/triage-labels.md +32 -0
- package/docs/architecture/gxpm-architecture-diagram.md +265 -0
- package/docs/architecture/gxpm-current-architecture.md +175 -0
- package/docs/architecture/gxpm-current-flow.md +278 -0
- package/docs/architecture/gxpm-replacement-architecture.md +211 -0
- package/docs/architecture/gxpm-target-architecture.md +449 -0
- package/docs/architecture/gxpm-v0-contract.md +311 -0
- package/docs/architecture/layered-workflow-boundaries.md +193 -0
- package/docs/architecture/preset-system.md +126 -0
- package/docs/architecture/scaffold-northstar.md +23 -0
- package/docs/brainstorms/2026-05-14-bdd-then-tdd-design.md +320 -0
- package/docs/brainstorms/README.md +22 -0
- package/docs/brainstorms/docs-knowledge-system-requirements.md +29 -0
- package/docs/governance/beta-skill-promotion.md +39 -0
- package/docs/governance/development-contract.md +144 -0
- package/docs/governance/gherkin-style.md +90 -0
- package/docs/governance/host-adapter.md +56 -0
- package/docs/governance/skill-authoring.md +87 -0
- package/docs/governance/skill-testing.md +356 -0
- package/docs/governance/template-authoring.md +53 -0
- package/docs/migrations/v0.2.md +51 -0
- package/docs/plans/README.md +23 -0
- package/docs/plans/bdd-then-tdd-plan.md +1767 -0
- package/docs/plans/docs-knowledge-system-plan.md +31 -0
- package/docs/plans/spec-kit-sdd-adoption-plan.md +305 -0
- package/docs/research/agents-md-best-practices.md +207 -0
- package/docs/research/archon-study.md +351 -0
- package/docs/research/claude-hooks-study.md +440 -0
- package/docs/research/codex-hooks-study.md +624 -0
- package/docs/research/everything-claude-code-study.md +252 -0
- package/docs/research/from-skills-to-layered-workflow.md +322 -0
- package/docs/research/gsd-study.md +69 -0
- package/docs/research/kimi-hooks-study.md +274 -0
- package/docs/research/mattpocock-skills-comparison.md +429 -0
- package/docs/research/mattpocock-skills-study.md +275 -0
- package/docs/research/oh-my-codex-study.md +279 -0
- package/docs/research/perplexity-agent-skills-design.md +168 -0
- package/docs/research/pmc-gstack-skill-study.md +122 -0
- package/docs/research/spec-kit-study.md +224 -0
- package/docs/research/superpowers-study.md +209 -0
- package/docs/roadmap/initial-roadmap.md +53 -0
- package/docs/solutions/README.md +45 -0
- package/docs/solutions/artifact-nesting-recovery.md +58 -0
- package/docs/solutions/session-context-restore-practice.md +67 -0
- package/docs/solutions/workflow/version-drift-recovery.md +49 -0
- package/docs/solutions/worktree-gate-recovery.md +62 -0
- package/docs/specs/README.md +28 -0
- package/docs/specs/claude.md +45 -0
- package/docs/specs/codex.md +44 -0
- package/docs/specs/cursor.md +44 -0
- package/hosts/adapters/claude.ts +29 -0
- package/hosts/adapters/codex.ts +27 -0
- package/hosts/adapters/cursor.ts +27 -0
- package/hosts/adapters/kimi.ts +27 -0
- package/hosts/claude.ts +23 -0
- package/hosts/codex.ts +26 -0
- package/hosts/cursor.ts +19 -0
- package/hosts/index.ts +33 -0
- package/hosts/registry.test.ts +52 -0
- package/hosts/registry.ts +57 -0
- package/hosts/schema.ts +58 -0
- package/package.json +52 -0
- package/scripts/browser.ts +185 -0
- package/scripts/cleanup.ts +142 -0
- package/scripts/commands/artifact.ts +115 -0
- package/scripts/commands/autopilot.ts +143 -0
- package/scripts/commands/capability.ts +57 -0
- package/scripts/commands/config.ts +69 -0
- package/scripts/commands/dag.ts +126 -0
- package/scripts/commands/feedback.ts +123 -0
- package/scripts/commands/gate.ts +291 -0
- package/scripts/commands/helpers.ts +126 -0
- package/scripts/commands/hook.ts +66 -0
- package/scripts/commands/init.ts +515 -0
- package/scripts/commands/issue.ts +825 -0
- package/scripts/commands/phase.ts +61 -0
- package/scripts/commands/preset.ts +159 -0
- package/scripts/commands/runtime.ts +199 -0
- package/scripts/commands/specify.ts +71 -0
- package/scripts/commands/upgrade.ts +243 -0
- package/scripts/commands/verify.ts +183 -0
- package/scripts/commands/wiki.ts +242 -0
- package/scripts/commands/workflow.ts +131 -0
- package/scripts/dev-skill.ts +55 -0
- package/scripts/discover-skills.ts +116 -0
- package/scripts/doctor.ts +410 -0
- package/scripts/dogfood-check.ts +125 -0
- package/scripts/eval-functional.ts +218 -0
- package/scripts/eval.ts +246 -0
- package/scripts/gen-skill-docs.ts +201 -0
- package/scripts/global-discover.ts +217 -0
- package/scripts/governance-check.ts +75 -0
- package/scripts/gxpm-check.ts +12 -0
- package/scripts/gxpm.ts +216 -0
- package/scripts/host-config.ts +62 -0
- package/scripts/install-claude-hooks.ts +138 -0
- package/scripts/install-codex-hooks.ts +271 -0
- package/scripts/install-hooks.ts +128 -0
- package/scripts/install-kimi-hooks.ts +92 -0
- package/scripts/install-skill.ts +184 -0
- package/scripts/phase-artifact-commands.ts +100 -0
- package/scripts/post-land-sync.ts +46 -0
- package/scripts/scaffold-check.ts +85 -0
- package/scripts/skill-naming-check.ts +78 -0
- package/scripts/skill-structure-check.ts +157 -0
- package/scripts/skills-lock-check.ts +60 -0
- package/scripts/sync-markdown-artifacts.ts +172 -0
- package/scripts/uninstall.ts +162 -0
- package/scripts/version.ts +47 -0
- package/scripts/wait-pr-ready.ts +407 -0
- package/skills/gxpm/SKILL.md +485 -0
- package/skills/gxpm/SKILL.md.tmpl +422 -0
- package/skills/gxpm/references/CANON.md +53 -0
- package/skills/gxpm/references/key-rules.md +130 -0
- package/skills/gxpm-architecture/SKILL.md +106 -0
- package/skills/gxpm-architecture/references/DEEPENING.md +37 -0
- package/skills/gxpm-architecture/references/INTERFACE-DESIGN.md +44 -0
- package/skills/gxpm-autopilot/SKILL.md +116 -0
- package/skills/gxpm-autopilot/SKILL.md.tmpl +107 -0
- package/skills/gxpm-browser/SKILL.md +105 -0
- package/skills/gxpm-browser/SKILL.md.tmpl +41 -0
- package/skills/gxpm-browser/references/commands.md +43 -0
- package/skills/gxpm-browser/references/evidence-path.md +20 -0
- package/skills/gxpm-build/SKILL.md +78 -0
- package/skills/gxpm-cleanup/SKILL.md +76 -0
- package/skills/gxpm-debug-issue/SKILL.md +39 -0
- package/skills/gxpm-diagnose/SKILL.md +220 -0
- package/skills/gxpm-diagnose/SKILL.md.tmpl +31 -0
- package/skills/gxpm-diagnose/references/feedback-loop.md +34 -0
- package/skills/gxpm-diagnose/references/feedback-loops.md +43 -0
- package/skills/gxpm-diagnose/references/phases.md +60 -0
- package/skills/gxpm-eval/SKILL.md +78 -0
- package/skills/gxpm-explore-codebase/SKILL.md +36 -0
- package/skills/gxpm-explore-codebase/scripts/summarize-communities.ts +51 -0
- package/skills/gxpm-feedback/SKILL.md +122 -0
- package/skills/gxpm-grill/SKILL.md +159 -0
- package/skills/gxpm-grill/SKILL.md.tmpl +77 -0
- package/skills/gxpm-grill/references/documentation-templates.md +56 -0
- package/skills/gxpm-grill/references/process.md +25 -0
- package/skills/gxpm-handoff/SKILL.md +112 -0
- package/skills/gxpm-hygiene/SKILL.md +69 -0
- package/skills/gxpm-implementer/SKILL.md +142 -0
- package/skills/gxpm-implementer/SKILL.md.tmpl +141 -0
- package/skills/gxpm-linear/SKILL.md +282 -0
- package/skills/gxpm-linear/SKILL.md.tmpl +86 -0
- package/skills/gxpm-linear/references/commands.md +75 -0
- package/skills/gxpm-linear/references/workflows.md +120 -0
- package/skills/gxpm-planning/SKILL.md +134 -0
- package/skills/gxpm-prototype/SKILL.md +64 -0
- package/skills/gxpm-refactor-safely/SKILL.md +62 -0
- package/skills/gxpm-review-army/SKILL.md +117 -0
- package/skills/gxpm-review-changes/SKILL.md +36 -0
- package/skills/gxpm-setup/SKILL.md +101 -0
- package/skills/gxpm-specifier/SKILL.md +135 -0
- package/skills/gxpm-tdd/SKILL.md +187 -0
- package/skills/gxpm-tdd/references/interface-design.md +23 -0
- package/skills/gxpm-tdd/references/mocking.md +27 -0
- package/skills/gxpm-tdd/references/red-green-refactor.md +61 -0
- package/skills/gxpm-tdd/references/troubleshooting.md +28 -0
- package/skills/gxpm-tdd/references/workflow.md +50 -0
- package/skills/gxpm-tdd/testing-anti-patterns.tmpl +304 -0
- package/skills/gxpm-triage/SKILL.md +160 -0
- package/skills/gxpm-verify/SKILL.md +107 -0
- package/skills/gxpm-write-skill/SKILL.md +131 -0
- package/skills/gxpm-zoom-out/SKILL.md +69 -0
- package/skills/maintain-hygiene-skills-lock/SKILL.md +54 -0
- package/skills/maintain-hygiene-skills-lock/SKILL.md.tmpl +53 -0
- package/templates/constitution-template.md +63 -0
- package/templates/hooks/gxpm-commit-msg +16 -0
- package/templates/hooks/gxpm-post-checkout +19 -0
- package/templates/hooks/gxpm-post-commit +7 -0
- package/templates/hooks/gxpm-post-merge +29 -0
- package/templates/hooks/gxpm-pre-commit +39 -0
- package/templates/hooks/gxpm-pre-push +33 -0
- package/templates/plan-template.md.tmpl +46 -0
- package/templates/spec-template.md.tmpl +63 -0
- package/templates/specify-stub.tmpl +22 -0
- package/templates/tasks-template.md.tmpl +32 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gxpm-review-changes
|
|
3
|
+
description: Structured code review using change detection and impact analysis. Use when reviewing a pull request, assessing risk before merging, or checking for missing test coverage after changes.
|
|
4
|
+
---
|
|
5
|
+
<!-- AUTO-GENERATED from SKILL.md.tmpl - do not edit directly -->
|
|
6
|
+
|
|
7
|
+
## gxpm-review-changes
|
|
8
|
+
|
|
9
|
+
Perform a thorough, risk-aware code review using GitNexus.
|
|
10
|
+
|
|
11
|
+
### 入口条件
|
|
12
|
+
|
|
13
|
+
- **触发时机**:Use when reviewing a pull request, assessing risk before merging, or checking for missing test coverage after changes.
|
|
14
|
+
- **目标**:Perform a thorough, risk-aware code review using GitNexus.
|
|
15
|
+
|
|
16
|
+
### 可操作流程
|
|
17
|
+
|
|
18
|
+
1. Run `detect_changes` to map the diff to affected symbols and execution flows.
|
|
19
|
+
2. For high-risk symbols, run `impact` with `direction: "upstream"` and `includeTests: true` when useful.
|
|
20
|
+
3. Use `context` on key symbols to understand callers, callees, and process participation.
|
|
21
|
+
4. Use `query` for broader execution-flow questions raised by the diff.
|
|
22
|
+
5. For any untested changes, suggest specific test cases.
|
|
23
|
+
|
|
24
|
+
### 红旗清单 / 反模式
|
|
25
|
+
|
|
26
|
+
- Start with `detect_changes`, then inspect only the highest-risk symbols.
|
|
27
|
+
- Use `impact`/`context` before raw `cypher`.
|
|
28
|
+
- Target: complete any review/debug/refactor task in ≤5 graph tool calls.
|
|
29
|
+
|
|
30
|
+
### 验证清单 / 出口条件
|
|
31
|
+
|
|
32
|
+
Provide findings grouped by risk level (high/medium/low) with:
|
|
33
|
+
- What changed and why it matters
|
|
34
|
+
- Test coverage status
|
|
35
|
+
- Suggested improvements
|
|
36
|
+
- Overall merge recommendation
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gxpm-setup
|
|
3
|
+
description: Scaffold per-repo configuration for gxpm skills. Use when first using gxpm in a repo, or when issue tracker, triage labels, or domain doc layout is unclear.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Setup
|
|
7
|
+
|
|
8
|
+
Scaffold the per-repo configuration that gxpm skills consume:
|
|
9
|
+
|
|
10
|
+
- **Issue tracker** — where issues live (GitHub, Linear, or local markdown)
|
|
11
|
+
- **Triage labels** — the strings used for the five canonical triage roles
|
|
12
|
+
- **Domain docs** — where `CONTEXT.md` and ADRs live, and the consumer rules for reading them
|
|
13
|
+
|
|
14
|
+
## 入口条件
|
|
15
|
+
|
|
16
|
+
**何时触发**
|
|
17
|
+
- 首次在当前 repo 使用 gxpm skills。
|
|
18
|
+
- `gxpm-triage`、`gxpm-planning` 等 skill 缺少 issue tracker 或 label 上下文。
|
|
19
|
+
- 用户说 "setup gxpm"、"configure gxpm"、"初始化 gxpm"。
|
|
20
|
+
- 刚创建新 repo,需要配置 gxpm 工作流。
|
|
21
|
+
|
|
22
|
+
**Skill 边界**
|
|
23
|
+
- 需要创建 issue → `/gxpm-triage`
|
|
24
|
+
- 需要写计划 → `/gxpm-planning`
|
|
25
|
+
- 需要调试 → `/gxpm-diagnose`
|
|
26
|
+
|
|
27
|
+
## 可操作流程
|
|
28
|
+
|
|
29
|
+
### 1. Explore
|
|
30
|
+
|
|
31
|
+
Read the current repo state:
|
|
32
|
+
|
|
33
|
+
- `git remote -v` — GitHub? GitLab? No remote?
|
|
34
|
+
- `AGENTS.md` / `CLAUDE.md` at root — does either exist?
|
|
35
|
+
- `CONTEXT.md` / `CONTEXT-MAP.md` at root
|
|
36
|
+
- `docs/adr/` or `.gxpm/out-of-scope/` directories
|
|
37
|
+
- Existing `.gxpm/config.json`
|
|
38
|
+
|
|
39
|
+
### 2. Present findings and ask
|
|
40
|
+
|
|
41
|
+
Summarise what's present and what's missing. Walk the user through three decisions **one at a time**.
|
|
42
|
+
|
|
43
|
+
**Section A — Issue tracker.**
|
|
44
|
+
|
|
45
|
+
Default: if `git remote` points at GitHub, propose GitHub Issues. Otherwise offer:
|
|
46
|
+
|
|
47
|
+
- **GitHub** — uses `gh` CLI
|
|
48
|
+
- **Linear** — uses Linear CLI
|
|
49
|
+
- **Local markdown** — issues as files under `.gxpm/issues/` (gxpm default)
|
|
50
|
+
- **Other** — ask user to describe the workflow in one paragraph
|
|
51
|
+
|
|
52
|
+
**Section B — Triage label vocabulary.**
|
|
53
|
+
|
|
54
|
+
The five canonical roles:
|
|
55
|
+
|
|
56
|
+
- `needs-triage` — maintainer needs to evaluate
|
|
57
|
+
- `needs-info` — waiting on reporter
|
|
58
|
+
- `ready-for-agent` — fully specified, AFK-ready
|
|
59
|
+
- `ready-for-human` — needs human implementation
|
|
60
|
+
- `wontfix` — will not be actioned
|
|
61
|
+
|
|
62
|
+
Default: each role's string equals its name. Ask if they want to override any.
|
|
63
|
+
|
|
64
|
+
**Section C — Domain docs.**
|
|
65
|
+
|
|
66
|
+
Confirm layout:
|
|
67
|
+
|
|
68
|
+
- **Single-context** — one `CONTEXT.md` + `docs/adr/` at repo root (most repos)
|
|
69
|
+
- **Multi-context** — `CONTEXT-MAP.md` at root pointing to per-context `CONTEXT.md` files (monorepo)
|
|
70
|
+
|
|
71
|
+
### 3. Write config
|
|
72
|
+
|
|
73
|
+
Write to `.gxpm/agents/`:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
.gxpm/
|
|
77
|
+
├── agents/
|
|
78
|
+
│ ├── issue-tracker.md
|
|
79
|
+
│ ├── triage-labels.md
|
|
80
|
+
│ └── domain.md
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Also update `AGENTS.md` or `CLAUDE.md` with an `## Agent skills` block if not present.
|
|
84
|
+
|
|
85
|
+
## 红旗清单 / 反模式
|
|
86
|
+
|
|
87
|
+
- **STOP:不要假设用户的 issue tracker。** 总是先检查 `git remote` 再提问。
|
|
88
|
+
- **STOP:不要覆盖用户已有的配置。** 如果 `.gxpm/agents/` 已存在,先展示当前内容,询问是否更新。
|
|
89
|
+
- **STOP:不要同时问三个问题。** 一次只问一个 section,得到回答后再继续。
|
|
90
|
+
|
|
91
|
+
## 验证清单 / 出口条件
|
|
92
|
+
|
|
93
|
+
- [ ] `.gxpm/agents/issue-tracker.md` 已写入,包含 tracker 类型和 CLI 工具。
|
|
94
|
+
- [ ] `.gxpm/agents/triage-labels.md` 已写入,包含 5 个 canonical roles 的映射。
|
|
95
|
+
- [ ] `.gxpm/agents/domain.md` 已写入,包含 CONTEXT.md / ADR 布局规则。
|
|
96
|
+
- [ ] `AGENTS.md` 或 `CLAUDE.md` 已更新 `## Agent skills` 区块(如果不存在)。
|
|
97
|
+
- [ ] 用户已确认配置正确。
|
|
98
|
+
|
|
99
|
+
**失败时路由**
|
|
100
|
+
- 配置后需要创建 issue → `/gxpm-triage`
|
|
101
|
+
- 配置后需要制定计划 → `/gxpm-planning`
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gxpm-specifier
|
|
3
|
+
description: BDD behavior specification design skill. Use during gxpm specify phase, when user mentions BDD, Gherkin, Given-When-Then, behavior spec, or behavior-first development.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# gxpm-specifier
|
|
7
|
+
|
|
8
|
+
## Core Principle
|
|
9
|
+
|
|
10
|
+
**Specify is BDD. Implement is TDD. The two must be separated by a user confirmation.**
|
|
11
|
+
|
|
12
|
+
在 specify 阶段,**不写一行测试逻辑代码**。产出的仅是 Gherkin 行为注释 + 空函数 stub + 结构化 artifact。
|
|
13
|
+
|
|
14
|
+
## 入口条件
|
|
15
|
+
|
|
16
|
+
- gxpm issue 处于 `specify` phase
|
|
17
|
+
- 用户要求"先写行为再写代码"、"BDD 先行"、"Given-When-Then"
|
|
18
|
+
- `dispatch-handoff.json` 已存在
|
|
19
|
+
|
|
20
|
+
## Constitution Gate(宪法门)
|
|
21
|
+
|
|
22
|
+
在 specify 阶段,**CANON.md 是最高权威**。每次生成 spec 前,必须:
|
|
23
|
+
|
|
24
|
+
1. **读取 CANON.md**,提取与当前 feature 相关的 3-5 条核心纪律
|
|
25
|
+
2. **在 spec 开头写入宪法合规声明**:
|
|
26
|
+
```markdown
|
|
27
|
+
## Constitution Compliance
|
|
28
|
+
|
|
29
|
+
本规格遵循 CANON.md 以下条款:
|
|
30
|
+
- Article X: [相关条款摘要]
|
|
31
|
+
- Article Y: [相关条款摘要]
|
|
32
|
+
- ...
|
|
33
|
+
|
|
34
|
+
任何违反上述条款的实现方案都必须显式说明理由。
|
|
35
|
+
```
|
|
36
|
+
3. **检查清单**(spec 末尾必须包含):
|
|
37
|
+
- [ ] 没有过工程化(≤3 个核心模块)
|
|
38
|
+
- [ ] 没有过早抽象(直接使用框架能力)
|
|
39
|
+
- [ ] 测试优先(contracts → tests → source)
|
|
40
|
+
- [ ] 无 `[NEEDS CLARIFICATION]` 残留
|
|
41
|
+
|
|
42
|
+
## [NEEDS CLARIFICATION] 强制标记
|
|
43
|
+
|
|
44
|
+
遇到以下情况时,**禁止猜测**,必须使用 `[NEEDS CLARIFICATION: 具体问题]` 标记:
|
|
45
|
+
|
|
46
|
+
- 用户 prompt 未明确的技术栈或架构选择
|
|
47
|
+
- 需求中缺失的边界条件、错误处理策略
|
|
48
|
+
- 与现有代码风格/模式冲突的实现方式
|
|
49
|
+
- 性能、安全、并发等非功能性需求未量化
|
|
50
|
+
- 与上游 artifact(acceptance-contract / implementation-plan)不一致的地方
|
|
51
|
+
|
|
52
|
+
**规则**:
|
|
53
|
+
- 每个 `[NEEDS CLARIFICATION]` 必须包含具体的、可回答的问题
|
|
54
|
+
- 标记数量 > 3 时,必须暂停生成,向用户呈现所有标记并请求澄清
|
|
55
|
+
- 用户澄清后,替换标记为确定内容,不得删除标记不留痕迹
|
|
56
|
+
|
|
57
|
+
## Hard Rules
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
NO TEST LOGIC IN SPECIFY PHASE
|
|
61
|
+
NO IMPLEMENTATION CODE IN SPECIFY PHASE
|
|
62
|
+
NO PLACEHOLDER DATA (foo/bar/test/123)
|
|
63
|
+
NO SCENARIO WITH > 10 STEPS
|
|
64
|
+
NO MIXED CONCERNS IN ONE SCENARIO
|
|
65
|
+
NO <placeholder> SENTINEL REMAINS AT CONFIRM TIME
|
|
66
|
+
NO CONSTITUTION VIOLATION WITHOUT DOCUMENTED RATIONALE
|
|
67
|
+
NO GUESSING — USE [NEEDS CLARIFICATION] INSTEAD
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
违反任一条 = 删除产出,从 `gxpm specify init` 重新开始。
|
|
71
|
+
|
|
72
|
+
## 可操作流程
|
|
73
|
+
|
|
74
|
+
1. 读取上游 artifact:`acceptance-contract`、`implementation-plan`、`dispatch-handoff`
|
|
75
|
+
2. 读取治理文档:`docs/governance/gherkin-style.md`
|
|
76
|
+
3. 在 `test/` 下找 1-2 个既有测试文件作为风格参照
|
|
77
|
+
4. 草拟 Feature + Scenarios(每 scenario `given`/`when`/`then` 各 ≥1 项)
|
|
78
|
+
5. 为每个 scenario 生成空 stub:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// Feature: <title>
|
|
82
|
+
//
|
|
83
|
+
// Scenario (scn-01): <name>
|
|
84
|
+
// Given <given[0]>
|
|
85
|
+
// And <given[1]>
|
|
86
|
+
// When <when>
|
|
87
|
+
// Then <then[0]>
|
|
88
|
+
// And <then[1]>
|
|
89
|
+
|
|
90
|
+
test("test_<scenario_name_in_snake_case>", () => {
|
|
91
|
+
// intentionally empty — awaiting user confirmation
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
6. 运行 `gxpm specify init <issue-id>` 写入 `behavior-spec.json`(自动用 `<placeholder>` 占位)
|
|
96
|
+
7. 直接编辑 `.gxpm/issues/<issue-id>/artifacts/behavior-spec.json`,把所有 `<placeholder>` 替换为真实领域语言(`gxpm specify edit` 命令未实现,请用 $EDITOR 直接打开 JSON 文件)
|
|
97
|
+
8. 调用 AskUserQuestion 呈现三选项:
|
|
98
|
+
- 行为正确,继续
|
|
99
|
+
- 需要调整:用户反馈 → 回到步骤 4
|
|
100
|
+
- 补充边界场景:增加 scenario → 回到步骤 4
|
|
101
|
+
9. 用户确认后运行 `gxpm specify confirm <issue-id>`
|
|
102
|
+
|
|
103
|
+
## 红旗清单
|
|
104
|
+
|
|
105
|
+
立即停止并重新开始:
|
|
106
|
+
|
|
107
|
+
- 在 specify 阶段写了 `expect` / `assert` 语句
|
|
108
|
+
- 用 `foo` / `bar` / `test` 等占位符
|
|
109
|
+
- scenario 步骤 > 10
|
|
110
|
+
- 一个 scenario 同时测功能 + 性能
|
|
111
|
+
- 在 Then 写 UI 选择器、HTTP 状态码(除非接口本身被测)
|
|
112
|
+
- 跳过用户确认直接 `gxpm specify confirm`
|
|
113
|
+
- 跳过 specify 直接 implement(phase-gate 会拒绝)
|
|
114
|
+
- confirm 时 `<placeholder>` 字符串仍残留(`confirmSpecify` 会拒绝)
|
|
115
|
+
|
|
116
|
+
## 验证清单
|
|
117
|
+
|
|
118
|
+
每次 `gxpm specify confirm` 前自查:
|
|
119
|
+
|
|
120
|
+
- [ ] 单一行为,可独立执行
|
|
121
|
+
- [ ] 无混合关注点
|
|
122
|
+
- [ ] 词汇稳定,CONTEXT.md 术语对齐
|
|
123
|
+
- [ ] 领域级抽象,无 UI/HTTP/SQL 管道术语
|
|
124
|
+
- [ ] 最小但充分的 Given
|
|
125
|
+
- [ ] 真实示例数据
|
|
126
|
+
- [ ] 第三人称、现在时、主谓结构
|
|
127
|
+
- [ ] 严格 Given→When→Then,Then 可观察
|
|
128
|
+
- [ ] 步骤数 < 10
|
|
129
|
+
- [ ] 每个 scenario.stubPath 真实存在
|
|
130
|
+
- [ ] 全文无 `<placeholder>` 残留
|
|
131
|
+
- [ ] 用户已通过 AskUserQuestion 或终端确认
|
|
132
|
+
|
|
133
|
+
## Handoff
|
|
134
|
+
|
|
135
|
+
`confirmedAt` 写入 → phase 可转 implement → `gxpm-tdd` skill 接管。
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gxpm-tdd
|
|
3
|
+
description: Test-driven development with red-green-refactor loops via vertical slices. Use when user wants to build features or fix bugs using TDD, mentions 'red-green-refactor', wants integration tests, or asks for test-first development.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development
|
|
7
|
+
|
|
8
|
+
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
|
9
|
+
|
|
10
|
+
**Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it.
|
|
11
|
+
|
|
12
|
+
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means. The warning sign: your test breaks when you refactor, but behavior hasn't changed.
|
|
13
|
+
|
|
14
|
+
**Violating the letter of the rules is violating the spirit of the rules.**
|
|
15
|
+
|
|
16
|
+
## 入口条件
|
|
17
|
+
|
|
18
|
+
在以下场景触发本 skill:
|
|
19
|
+
|
|
20
|
+
- 用户要求使用 TDD 构建功能或修复 bug
|
|
21
|
+
- 用户提到 "red-green-refactor"
|
|
22
|
+
- 用户需要集成测试
|
|
23
|
+
- 用户要求测试优先开发
|
|
24
|
+
|
|
25
|
+
在 gxpm 工作流中,`implement` 阶段应将首个子任务视为 **tracer bullet**,从该任务开始 TDD 循环。
|
|
26
|
+
|
|
27
|
+
## 可操作流程
|
|
28
|
+
|
|
29
|
+
### The Iron Law
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Write code before the test? Delete it. Start over.
|
|
36
|
+
|
|
37
|
+
**No exceptions:**
|
|
38
|
+
- Don't keep it as "reference"
|
|
39
|
+
- Don't "adapt" it while writing tests
|
|
40
|
+
- Don't look at it
|
|
41
|
+
- Delete means delete
|
|
42
|
+
|
|
43
|
+
Implement fresh from tests. Period.
|
|
44
|
+
|
|
45
|
+
See [references/red-green-refactor.md](references/red-green-refactor.md) for the full red-green-refactor cycle.
|
|
46
|
+
|
|
47
|
+
### The Specify-First Iron Law
|
|
48
|
+
|
|
49
|
+
**Before writing ANY test logic, the test scenario MUST already exist in `.gxpm/issues/<id>/artifacts/behavior-spec.json` with `confirmedAt` set.**
|
|
50
|
+
|
|
51
|
+
If you find yourself writing a test without a corresponding entry in `behavior-spec.json`:
|
|
52
|
+
|
|
53
|
+
- STOP
|
|
54
|
+
- Delete the test code you wrote
|
|
55
|
+
- Return to specify phase: `gxpm phase rewind <id> --to specify --reason "missing scenario"`
|
|
56
|
+
- Run `gxpm specify revise <id>` to clear `confirmedAt`
|
|
57
|
+
- Add the scenario to `behavior-spec.json`
|
|
58
|
+
- Re-confirm with `gxpm specify confirm <id>`
|
|
59
|
+
- Then resume TDD
|
|
60
|
+
|
|
61
|
+
**Why:** BDD describes WHAT behavior we want; TDD enforces THAT behavior incrementally. Jumping to TDD without a confirmed BDD spec means the agent is inventing test cases — the precise failure mode this discipline prevents.
|
|
62
|
+
|
|
63
|
+
**The test stub file at `scenario.stubPath` is your contract.** Open it; the Gherkin comment block at the top is the only legitimate source of assertions you may translate into code.
|
|
64
|
+
|
|
65
|
+
### 正确做法:垂直切片(Vertical Slices)
|
|
66
|
+
|
|
67
|
+
**DO NOT write all tests first, then all implementation.** This is "horizontal slicing" — treating RED as "write all tests" and GREEN as "write all code."
|
|
68
|
+
|
|
69
|
+
This produces **crap tests**:
|
|
70
|
+
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
|
71
|
+
- You end up testing the _shape_ of things rather than user-facing behavior
|
|
72
|
+
- Tests become insensitive to real changes
|
|
73
|
+
|
|
74
|
+
**Correct approach**: Vertical slices via tracer bullets.
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
WRONG (horizontal):
|
|
78
|
+
RED: test1, test2, test3, test4, test5
|
|
79
|
+
GREEN: impl1, impl2, impl3, impl4, impl5
|
|
80
|
+
|
|
81
|
+
RIGHT (vertical):
|
|
82
|
+
RED→GREEN: test1→impl1
|
|
83
|
+
RED→GREEN: test2→impl2
|
|
84
|
+
RED→GREEN: test3→impl3
|
|
85
|
+
...
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
See [references/workflow.md](references/workflow.md) for the full TDD workflow.
|
|
89
|
+
|
|
90
|
+
### 卡壳时的应对策略
|
|
91
|
+
|
|
92
|
+
See [references/troubleshooting.md](references/troubleshooting.md) for detailed guidance.
|
|
93
|
+
|
|
94
|
+
Quick reference:
|
|
95
|
+
|
|
96
|
+
| Problem | Solution |
|
|
97
|
+
|---------|----------|
|
|
98
|
+
| Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
|
|
99
|
+
| Test too complicated | Design too complicated. Simplify interface. |
|
|
100
|
+
| Must mock everything | Code too coupled. Use dependency injection. |
|
|
101
|
+
| Test setup huge | Extract helpers. Still complex? Simplify design. |
|
|
102
|
+
|
|
103
|
+
### 调试集成
|
|
104
|
+
|
|
105
|
+
Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
|
|
106
|
+
|
|
107
|
+
Never fix bugs without a test.
|
|
108
|
+
|
|
109
|
+
### 添加 mock 或测试工具时
|
|
110
|
+
|
|
111
|
+
Read [references/mocking.md](references/mocking.md) before adding mocks, changing tests, or adding test-only methods to production code.
|
|
112
|
+
|
|
113
|
+
See [references/interface-design.md](references/interface-design.md) for designing testable interfaces.
|
|
114
|
+
|
|
115
|
+
## 红旗清单 / 反模式
|
|
116
|
+
|
|
117
|
+
### 必须立即停止并重新开始的情况
|
|
118
|
+
|
|
119
|
+
- Code before test
|
|
120
|
+
- Test after implementation
|
|
121
|
+
- Test passes immediately
|
|
122
|
+
- Can't explain why test failed
|
|
123
|
+
- Tests added "later"
|
|
124
|
+
- Rationalizing "just this once"
|
|
125
|
+
- "I already manually tested it"
|
|
126
|
+
- "Tests after achieve the same purpose"
|
|
127
|
+
- "It's about spirit not ritual"
|
|
128
|
+
- "Keep as reference" or "adapt existing code"
|
|
129
|
+
- "Already spent X hours, deleting is wasteful"
|
|
130
|
+
- "TDD is dogmatic, I'm being pragmatic"
|
|
131
|
+
- "This is different because..."
|
|
132
|
+
- Writing a test without a matching scenario in `behavior-spec.json`
|
|
133
|
+
- Adding assertions that do not appear in the scenario's `then` clauses
|
|
134
|
+
|
|
135
|
+
**All of these mean: Delete code. Start over with TDD.**
|
|
136
|
+
|
|
137
|
+
### 水平切片(Horizontal Slices)
|
|
138
|
+
|
|
139
|
+
一次性写完全部测试再写全部实现是水平切片,会产生脆弱且脱离实际的测试。必须按垂直切片逐个 RED→GREEN→REFACTOR 推进。
|
|
140
|
+
|
|
141
|
+
## 验证清单 / 出口条件
|
|
142
|
+
|
|
143
|
+
每个 TDD 循环完成后检查:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
[ ] Test describes behavior, not implementation
|
|
147
|
+
[ ] Test uses public interface only
|
|
148
|
+
[ ] Test would survive internal refactor
|
|
149
|
+
[ ] Code is minimal for this test
|
|
150
|
+
[ ] No speculative features added
|
|
151
|
+
[ ] Verify RED executed (test failed for expected reason)
|
|
152
|
+
[ ] Verify GREEN executed (test passes + all others pass + output clean)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Final Rule
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
Production code → test exists and failed first
|
|
159
|
+
Otherwise → not TDD
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
No exceptions without your human partner's permission.
|
|
163
|
+
|
|
164
|
+
### 验证与证据
|
|
165
|
+
|
|
166
|
+
单个 TDD 循环的测试验证由测试运行器覆盖。全部 TDD 循环完成后,加载 `/gxpm-verify` 运行完整验证流水线并收集 `local-verify` 证据。
|
|
167
|
+
|
|
168
|
+
在 gxpm 工作流中:
|
|
169
|
+
- 使用 `gxpm run event <issue-id> <run-id> --type test-passed` 记录测试里程碑。
|
|
170
|
+
- TDD 循环完成后,加载 `/gxpm-verify` 执行完整验证流水线并产出 `local-verify` 证据。
|
|
171
|
+
- 如果在 TDD 过程中发现 bug,先写重现该 bug 的 failing test。仅当根因不明时才切换到 `/gxpm-diagnose` skill。
|
|
172
|
+
|
|
173
|
+
## 常见说辞表
|
|
174
|
+
|
|
175
|
+
| Excuse | Reality |
|
|
176
|
+
|--------|---------|
|
|
177
|
+
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
|
|
178
|
+
| "I'll test after" | Tests passing immediately prove nothing. |
|
|
179
|
+
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
|
|
180
|
+
| "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
|
|
181
|
+
| "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
|
|
182
|
+
| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
|
|
183
|
+
| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
|
|
184
|
+
| "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
|
|
185
|
+
| "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
|
|
186
|
+
| "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
|
|
187
|
+
| "Existing code has no tests" | You're improving it. Add tests for existing code. |
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Interface Design for Testability
|
|
2
|
+
|
|
3
|
+
Reference for `/gxpm-tdd`.
|
|
4
|
+
|
|
5
|
+
## Deep modules
|
|
6
|
+
|
|
7
|
+
A deep module encapsulates a lot of functionality in a simple, testable interface which rarely changes. Aim for small interface, deep implementation.
|
|
8
|
+
|
|
9
|
+
> "The best modules are deep. They allow a lot of functionality to be accessed through a simple interface."
|
|
10
|
+
> — John Ousterhout, A Philosophy Of Software Design
|
|
11
|
+
|
|
12
|
+
## Testability checklist
|
|
13
|
+
|
|
14
|
+
- [ ] Can I test this through its public interface only?
|
|
15
|
+
- [ ] Would this test survive a complete internal rewrite?
|
|
16
|
+
- [ ] Is the interface smaller than the implementation?
|
|
17
|
+
- [ ] Are error modes explicit and testable?
|
|
18
|
+
|
|
19
|
+
## Warning signs
|
|
20
|
+
|
|
21
|
+
- Constructor takes 5+ dependencies → module is doing too much.
|
|
22
|
+
- Test needs to know internal state → interface is incomplete.
|
|
23
|
+
- Renaming a private function breaks tests → tests are coupled to implementation.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Mocking Guidelines
|
|
2
|
+
|
|
3
|
+
Reference for `/gxpm-tdd`. Read this before adding mocks, changing tests, or adding test-only methods to production code.
|
|
4
|
+
|
|
5
|
+
## Prefer real collaborators
|
|
6
|
+
|
|
7
|
+
Mock only at system boundaries (HTTP, database, file system, clock). Everything inside the application boundary should use real objects.
|
|
8
|
+
|
|
9
|
+
## Mocking red flags
|
|
10
|
+
|
|
11
|
+
- You need to mock more than 2 collaborators for a single test → design is too coupled.
|
|
12
|
+
- The mock verifies it was called with specific arguments → test is coupled to implementation, not behavior.
|
|
13
|
+
- You need a "test-only" method on production code → the seam is in the wrong place.
|
|
14
|
+
|
|
15
|
+
## Good seams for mocking
|
|
16
|
+
|
|
17
|
+
| Boundary | Mock strategy |
|
|
18
|
+
|----------|--------------|
|
|
19
|
+
| HTTP client | Stub the transport layer, not the service calling it |
|
|
20
|
+
| Database | In-memory test DB or transaction rollback |
|
|
21
|
+
| File system | Temp directory with cleanup |
|
|
22
|
+
| Clock | Injectable `now()` function or frozen time |
|
|
23
|
+
| Random | Injectable seed |
|
|
24
|
+
|
|
25
|
+
## One adapter = hypothetical seam. Two adapters = real seam.
|
|
26
|
+
|
|
27
|
+
If you have one production adapter and one test adapter, the seam is real and worth keeping. If you only have a test adapter, reconsider whether the abstraction pulls its weight.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## Red-Green-Refactor
|
|
2
|
+
|
|
3
|
+
Each vertical slice follows this cycle. No skips. No shortcuts.
|
|
4
|
+
|
|
5
|
+
### RED — Write Failing Test
|
|
6
|
+
|
|
7
|
+
Write one minimal test showing what should happen.
|
|
8
|
+
|
|
9
|
+
**Requirements:**
|
|
10
|
+
- One behavior
|
|
11
|
+
- Clear name
|
|
12
|
+
- Real code (no mocks unless unavoidable)
|
|
13
|
+
|
|
14
|
+
### Verify RED — Watch It Fail (MANDATORY. Never skip.)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun test path/to/test.test.ts
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Confirm:
|
|
21
|
+
- Test fails (not errors)
|
|
22
|
+
- Failure message is expected
|
|
23
|
+
- Fails because feature missing (not typos)
|
|
24
|
+
|
|
25
|
+
**Test passes?** You're testing existing behavior. Fix test.
|
|
26
|
+
|
|
27
|
+
**Test errors?** Fix error, re-run until it fails correctly.
|
|
28
|
+
|
|
29
|
+
### GREEN — Minimal Code
|
|
30
|
+
|
|
31
|
+
Write simplest code to pass the test.
|
|
32
|
+
|
|
33
|
+
Don't add features, refactor other code, or "improve" beyond the test.
|
|
34
|
+
|
|
35
|
+
### Verify GREEN — Watch It Pass (MANDATORY)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bun test path/to/test.test.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Confirm:
|
|
42
|
+
- Test passes
|
|
43
|
+
- Other tests still pass
|
|
44
|
+
- Output pristine (no errors, warnings)
|
|
45
|
+
|
|
46
|
+
**Test fails?** Fix code, not test.
|
|
47
|
+
|
|
48
|
+
**Other tests fail?** Fix now.
|
|
49
|
+
|
|
50
|
+
### REFACTOR — Clean Up
|
|
51
|
+
|
|
52
|
+
After green only:
|
|
53
|
+
- Remove duplication
|
|
54
|
+
- Improve names
|
|
55
|
+
- Extract helpers
|
|
56
|
+
|
|
57
|
+
Keep tests green. Don't add behavior.
|
|
58
|
+
|
|
59
|
+
### Repeat
|
|
60
|
+
|
|
61
|
+
Next failing test for next feature.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# TDD Troubleshooting
|
|
2
|
+
|
|
3
|
+
Reference for `/gxpm-tdd`.
|
|
4
|
+
|
|
5
|
+
## Don't know how to test
|
|
6
|
+
|
|
7
|
+
Write the wished-for API first. Write the assertion first. If still stuck, ask your human partner — the interface design is unclear.
|
|
8
|
+
|
|
9
|
+
## Test too complicated
|
|
10
|
+
|
|
11
|
+
Design is too complicated. Simplify the interface. A hard-to-test module is hard to use.
|
|
12
|
+
|
|
13
|
+
## Must mock everything
|
|
14
|
+
|
|
15
|
+
Code is too coupled. Use dependency injection. Move integration points to the edges.
|
|
16
|
+
|
|
17
|
+
## Test setup is huge
|
|
18
|
+
|
|
19
|
+
Extract helpers. If still complex after helpers, simplify the design — the module has too many dependencies.
|
|
20
|
+
|
|
21
|
+
## Test passes immediately
|
|
22
|
+
|
|
23
|
+
This usually means:
|
|
24
|
+
- The test doesn't actually assert anything meaningful.
|
|
25
|
+
- The implementation was written before the test (violation of Iron Law).
|
|
26
|
+
- The test is asserting on the wrong thing.
|
|
27
|
+
|
|
28
|
+
**Action:** Stop. Verify the test can fail by deliberately breaking the assertion. If it still passes, delete and rewrite.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## Workflow
|
|
2
|
+
|
|
3
|
+
### 1. Planning
|
|
4
|
+
|
|
5
|
+
Before writing any code:
|
|
6
|
+
- [ ] Confirm with user what interface changes are needed
|
|
7
|
+
- [ ] Confirm which behaviors to test (prioritise)
|
|
8
|
+
- [ ] Identify opportunities for deep modules (small interface, deep implementation)
|
|
9
|
+
- [ ] Design interfaces for testability
|
|
10
|
+
- [ ] List the behaviors to test (not implementation steps)
|
|
11
|
+
- [ ] Get user approval on the plan
|
|
12
|
+
|
|
13
|
+
**You can't test everything.** Focus on critical paths and complex logic.
|
|
14
|
+
|
|
15
|
+
### 2. Tracer Bullet
|
|
16
|
+
|
|
17
|
+
Write ONE test that confirms ONE thing about the system:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
RED: Write test for first behavior → verify it fails correctly
|
|
21
|
+
GREEN: Write minimal code to pass → verify it passes
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This is your tracer bullet — proves the path works end-to-end.
|
|
25
|
+
|
|
26
|
+
### 3. Incremental Loop
|
|
27
|
+
|
|
28
|
+
For each remaining behavior:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
RED: Write next test → verify it fails correctly
|
|
32
|
+
GREEN: Minimal code to pass → verify it passes + all other tests pass
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Rules:
|
|
36
|
+
- One test at a time
|
|
37
|
+
- Only enough code to pass current test
|
|
38
|
+
- Don't anticipate future tests
|
|
39
|
+
- Keep tests focused on observable behavior
|
|
40
|
+
- **Never skip Verify RED or Verify GREEN**
|
|
41
|
+
|
|
42
|
+
### 4. Refactor
|
|
43
|
+
|
|
44
|
+
After all tests pass, look for refactor candidates:
|
|
45
|
+
- [ ] Extract duplication
|
|
46
|
+
- [ ] Deepen modules (move complexity behind simple interfaces)
|
|
47
|
+
- [ ] Apply SOLID principles where natural
|
|
48
|
+
- [ ] Run tests after each refactor step
|
|
49
|
+
|
|
50
|
+
**Never refactor while RED.** Get to GREEN first.
|