supipowers 1.2.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +118 -56
  2. package/bin/install.ts +48 -128
  3. package/package.json +11 -3
  4. package/skills/code-review/SKILL.md +137 -40
  5. package/skills/context-mode/SKILL.md +67 -56
  6. package/skills/creating-supi-agents/SKILL.md +204 -0
  7. package/skills/debugging/SKILL.md +86 -40
  8. package/skills/fix-pr/SKILL.md +96 -65
  9. package/skills/planning/SKILL.md +103 -46
  10. package/skills/qa-strategy/SKILL.md +68 -46
  11. package/skills/receiving-code-review/SKILL.md +60 -53
  12. package/skills/release/SKILL.md +111 -39
  13. package/skills/tdd/SKILL.md +118 -67
  14. package/skills/verification/SKILL.md +71 -37
  15. package/src/bootstrap.ts +27 -5
  16. package/src/commands/agents.ts +249 -0
  17. package/src/commands/ai-review.ts +1113 -0
  18. package/src/commands/config.ts +224 -95
  19. package/src/commands/doctor.ts +19 -13
  20. package/src/commands/fix-pr.ts +8 -11
  21. package/src/commands/generate.ts +200 -0
  22. package/src/commands/model-picker.ts +5 -15
  23. package/src/commands/model.ts +4 -5
  24. package/src/commands/optimize-context.ts +202 -0
  25. package/src/commands/plan.ts +148 -92
  26. package/src/commands/qa.ts +14 -23
  27. package/src/commands/release.ts +504 -275
  28. package/src/commands/review.ts +643 -86
  29. package/src/commands/status.ts +44 -17
  30. package/src/commands/supi.ts +69 -41
  31. package/src/commands/update.ts +57 -2
  32. package/src/config/defaults.ts +6 -39
  33. package/src/config/loader.ts +388 -40
  34. package/src/config/model-resolver.ts +26 -22
  35. package/src/config/schema.ts +113 -48
  36. package/src/context/analyzer.ts +61 -2
  37. package/src/context/optimizer.ts +199 -0
  38. package/src/context-mode/compressor.ts +14 -11
  39. package/src/context-mode/detector.ts +16 -54
  40. package/src/context-mode/event-extractor.ts +45 -16
  41. package/src/context-mode/event-store.ts +225 -16
  42. package/src/context-mode/hooks.ts +195 -22
  43. package/src/context-mode/knowledge/chunker.ts +235 -0
  44. package/src/context-mode/knowledge/store.ts +187 -0
  45. package/src/context-mode/routing.ts +12 -23
  46. package/src/context-mode/sandbox/executor.ts +183 -0
  47. package/src/context-mode/sandbox/runners.ts +40 -0
  48. package/src/context-mode/snapshot-builder.ts +243 -7
  49. package/src/context-mode/tools.ts +440 -0
  50. package/src/context-mode/web/fetcher.ts +117 -0
  51. package/src/context-mode/web/html-to-md.ts +293 -0
  52. package/src/debug/logger.ts +107 -0
  53. package/src/deps/registry.ts +0 -20
  54. package/src/docs/drift.ts +454 -0
  55. package/src/fix-pr/fetch-comments.ts +66 -0
  56. package/src/git/commit-msg.ts +2 -1
  57. package/src/git/commit.ts +123 -141
  58. package/src/git/conventions.ts +2 -2
  59. package/src/git/status.ts +4 -1
  60. package/src/lsp/bridge.ts +138 -12
  61. package/src/planning/approval-flow.ts +125 -19
  62. package/src/planning/plan-writer-prompt.ts +4 -11
  63. package/src/planning/planning-ask-tool.ts +81 -0
  64. package/src/planning/prompt-builder.ts +9 -169
  65. package/src/planning/system-prompt.ts +290 -0
  66. package/src/platform/omp.ts +50 -4
  67. package/src/platform/progress.ts +182 -0
  68. package/src/platform/test-utils.ts +4 -1
  69. package/src/platform/tui-colors.ts +30 -0
  70. package/src/platform/types.ts +1 -0
  71. package/src/qa/detect-app-type.ts +102 -0
  72. package/src/qa/discover-routes.ts +353 -0
  73. package/src/quality/ai-session.ts +96 -0
  74. package/src/quality/ai-setup.ts +86 -0
  75. package/src/quality/gates/ai-review.ts +129 -0
  76. package/src/quality/gates/build.ts +8 -0
  77. package/src/quality/gates/command.ts +150 -0
  78. package/src/quality/gates/format.ts +28 -0
  79. package/src/quality/gates/lint.ts +22 -0
  80. package/src/quality/gates/lsp-diagnostics.ts +84 -0
  81. package/src/quality/gates/test-suite.ts +8 -0
  82. package/src/quality/gates/typecheck.ts +22 -0
  83. package/src/quality/registry.ts +25 -0
  84. package/src/quality/review-gates.ts +33 -0
  85. package/src/quality/runner.ts +268 -0
  86. package/src/quality/schemas.ts +48 -0
  87. package/src/quality/setup.ts +227 -0
  88. package/src/release/changelog.ts +7 -3
  89. package/src/release/channels/custom.ts +43 -0
  90. package/src/release/channels/gitea.ts +35 -0
  91. package/src/release/channels/github.ts +35 -0
  92. package/src/release/channels/gitlab.ts +35 -0
  93. package/src/release/channels/registry.ts +52 -0
  94. package/src/release/channels/types.ts +27 -0
  95. package/src/release/detector.ts +10 -63
  96. package/src/release/executor.ts +61 -51
  97. package/src/release/prompt.ts +38 -38
  98. package/src/release/version.ts +129 -10
  99. package/src/review/agent-loader.ts +331 -0
  100. package/src/review/consolidator.ts +180 -0
  101. package/src/review/default-agents/correctness.md +72 -0
  102. package/src/review/default-agents/maintainability.md +64 -0
  103. package/src/review/default-agents/security.md +67 -0
  104. package/src/review/fixer.ts +219 -0
  105. package/src/review/multi-agent-runner.ts +135 -0
  106. package/src/review/output.ts +147 -0
  107. package/src/review/prompts/agent-review-wrapper.md +36 -0
  108. package/src/review/prompts/fix-findings.md +32 -0
  109. package/src/review/prompts/fix-output-schema.md +18 -0
  110. package/src/review/prompts/invalid-output-retry.md +22 -0
  111. package/src/review/prompts/output-instructions.md +14 -0
  112. package/src/review/prompts/review-output-schema.md +38 -0
  113. package/src/review/prompts/single-review.md +53 -0
  114. package/src/review/prompts/validation-review.md +30 -0
  115. package/src/review/runner.ts +128 -0
  116. package/src/review/scope.ts +353 -0
  117. package/src/review/template.ts +15 -0
  118. package/src/review/types.ts +296 -0
  119. package/src/review/validator.ts +160 -0
  120. package/src/storage/plans.ts +5 -3
  121. package/src/storage/reports.ts +50 -7
  122. package/src/storage/review-sessions.ts +117 -0
  123. package/src/text.ts +19 -0
  124. package/src/types.ts +336 -26
  125. package/src/utils/paths.ts +39 -0
  126. package/src/visual/companion.ts +5 -3
  127. package/src/visual/start-server.ts +101 -0
  128. package/src/visual/stop-server.ts +39 -0
  129. package/bin/ctx-mode-wrapper.mjs +0 -66
  130. package/src/config/profiles.ts +0 -64
  131. package/src/context-mode/installer.ts +0 -38
  132. package/src/quality/ai-review-gate.ts +0 -43
  133. package/src/quality/gate-runner.ts +0 -67
  134. package/src/quality/lsp-gate.ts +0 -24
  135. package/src/quality/test-gate.ts +0 -39
  136. package/src/visual/scripts/start-server.sh +0 -98
  137. package/src/visual/scripts/stop-server.sh +0 -21
@@ -5,50 +5,50 @@ description: Receiving code review feedback — verify before implementing, tech
5
5
 
6
6
  # Receiving Code Review
7
7
 
8
- ## Core Principle
8
+ Code review requires technical evaluation, not emotional performance. Verify before implementing. Technical correctness over social comfort.
9
9
 
10
- Code review requires technical evaluation, not emotional performance.
11
- Verify before implementing. Ask before assuming. Technical correctness over social comfort.
10
+ ## Quick Reference
12
11
 
13
- ## The Response Pattern
14
-
15
- 1. **READ:** Complete feedback without reacting.
16
- 2. **UNDERSTAND:** Restate the requirement in your own words, or ask for clarification.
17
- 3. **VERIFY:** Check against codebase reality.
18
- 4. **EVALUATE:** Is this technically sound for THIS codebase?
19
- 5. **RESPOND:** Technical acknowledgment or reasoned pushback.
20
- 6. **IMPLEMENT:** One item at a time, test each change.
12
+ | Aspect | Detail |
13
+ |--------|--------|
14
+ | **Input** | Review comments (inline or summary), PR diff, full codebase access |
15
+ | **Output** | Per-comment response (acknowledgment, pushback, or question) + code changes with tests |
16
+ | **Core loop** | Read → Understand → Verify → Evaluate → Respond → Implement |
17
+ | **Key rule** | Every suggestion is a hypothesis — verify it against the codebase before acting |
21
18
 
22
- ## Forbidden Responses
23
-
24
- Never use performative agreement:
25
- - "You're absolutely right!"
26
- - "Great point!"
27
- - "Excellent catch!"
28
- - "Thanks for catching that!"
19
+ ## The Response Pattern
29
20
 
30
- Instead: restate requirements, ask clarifying questions, take action.
21
+ 1. **Read** the complete feedback without reacting.
22
+ 2. **Understand** — restate the requirement, or ask for clarification.
23
+ 3. **Verify** — does the issue actually exist? Does the cited pattern match what's in the code?
24
+ 4. **Evaluate** — does the suggestion match established patterns? Break existing callers? Warrant its scope?
25
+ 5. **Respond** — technical acknowledgment or reasoned pushback.
26
+ 6. **Implement** — one item at a time, test each change.
31
27
 
32
- Acceptable responses:
33
- - "Fixed. [description of what changed]"
34
- - "Good catch — [issue]. Fixed in [location]."
35
- - "I disagree because [technical reason]. Here's why: ..."
28
+ ## Acceptable vs Forbidden Responses
36
29
 
37
- ## Handling Unclear Feedback
30
+ | Forbidden (performative agreement) | Acceptable (technical acknowledgment) |
31
+ |------------------------------------|---------------------------------------|
32
+ | "You're absolutely right!" | "Fixed. [description of what changed]" |
33
+ | "Great point!" / "Excellent catch!" | "Good catch — [issue]. Fixed in [location]." |
34
+ | Any empty praise before acting | "I disagree because [technical reason]. Here's why: ..." |
38
35
 
39
- If ANY item is unclear, stop and ask for clarification before implementing anything.
40
- Items may be related — clarify all unclear items before starting work.
36
+ If ANY item is unclear, stop and ask for clarification before implementing. Review items may have dependencies — implementing one may invalidate another. Clarify all unclear items before starting work.
41
37
 
42
38
  ## Source-Specific Handling
43
39
 
44
- **From your human partner:** Trusted. Implement after understanding.
40
+ | Source | Trust level | Approach |
41
+ |--------|------------|----------|
42
+ | Human partner | High trust | Implement after understanding. Still verify complex or cross-cutting changes against codebase. |
43
+ | External reviewer | Verify first | Check technically. Look for breaking changes. Confirm the reviewer has full context. |
45
44
 
46
- **From external reviewers:** Verify technically. Check for breaking changes. Question whether the reviewer understands the full context.
47
-
48
- ## YAGNI Check
45
+ ## When to Push Back
49
46
 
50
- For suggested "professional features" — grep the codebase for actual usage.
51
- If unused, suggest removal instead of implementing.
47
+ Push back when feedback would:
48
+ - Introduce bugs or break existing behavior
49
+ - Add unnecessary complexity (YAGNI — grep codebase for actual usage before implementing suggested features)
50
+ - Contradict established codebase patterns
51
+ - Solve a problem that doesn't exist
52
52
 
53
53
  ## Implementation Order
54
54
 
@@ -58,30 +58,37 @@ If unused, suggest removal instead of implementing.
58
58
  4. Complex fixes (may need discussion)
59
59
  5. Test each change before moving to the next
60
60
 
61
- ## When to Push Back
61
+ ## Example: Full Review Cycle
62
62
 
63
- Push back when feedback would:
64
- - Introduce bugs or break existing behavior
65
- - Add unnecessary complexity (YAGNI violation)
66
- - Contradict the codebase's established patterns
67
- - Solve a problem that doesn't exist
63
+ **Review comment:** _"This should use a builder pattern instead of direct construction for `SessionConfig`."_
64
+
65
+ **Wrong response:**
66
+ > "Great suggestion! Refactoring to builder pattern now."
67
+
68
+ Implements builder pattern without checking whether it fits. Ships unnecessary abstraction.
69
+
70
+ **Correct response:**
68
71
 
69
- Use technical reasoning, not defensiveness.
72
+ 1. **Verify**: grep codebase for `SessionConfig` construction sites — find 2 call sites, both pass 3 fields.
73
+ 2. **Evaluate**: builder pattern adds complexity for 2 simple call sites. No optional fields, no conditional construction. YAGNI.
74
+ 3. **Respond**:
75
+ > "`SessionConfig` has 2 call sites, both passing the same 3 required fields. A builder adds indirection without benefit here. If construction grows more complex, I'll revisit. Keeping direct construction — thoughts?"
76
+ 4. **Outcome**: pushback accepted. No unnecessary abstraction shipped.
70
77
 
71
- ## Common Mistakes
78
+ ## MUST DO / MUST NOT DO
72
79
 
73
- | Mistake | Fix |
74
- |---------|-----|
75
- | Agree immediately | Verify against codebase first |
76
- | Implement all at once | One at a time, test each |
77
- | Skip unclear items | Ask first, implement second |
78
- | Performative gratitude | Technical acknowledgment only |
79
- | Defensive pushback | Reasoned technical argument |
80
- | Trust without verifying | Check codebase reality |
81
- | Implement suggested feature | YAGNI check — is it actually needed? |
80
+ | MUST DO | MUST NOT DO |
81
+ |---------|-------------|
82
+ | Verify every suggestion against actual codebase state | Agree performatively then implement blindly |
83
+ | Restate requirements before implementing | Skip unclear items and guess intent |
84
+ | Push back with technical evidence | Push back with defensiveness or emotion |
85
+ | Implement and test one item at a time | Batch-implement all feedback untested |
86
+ | Treat partner feedback as high-trust, not infallible | Treat any source as unconditionally trusted |
82
87
 
83
- ## The Bottom Line
88
+ ## Final Checklist
84
89
 
85
- External feedback = suggestions to evaluate, not orders to follow.
86
- Verify. Question. Then implement.
87
- No performative agreement. Technical rigor always.
90
+ - [ ] Every comment has a response: acknowledgment, question, or reasoned pushback
91
+ - [ ] No performative agreement — every response contains technical content
92
+ - [ ] Unclear items clarified before any implementation started
93
+ - [ ] Each change tested before moving to the next
94
+ - [ ] Pushbacks cite codebase evidence, not opinion
@@ -1,65 +1,137 @@
1
1
  # Release Polish Mode
2
2
 
3
- ## Purpose
3
+ Rewrite raw commit logs into user-facing release notes, then execute the release after confirmation.
4
4
 
5
- You are polishing release notes for a new version. The raw changelog and release commands have been provided by the `/supi:release` command. Your job is to rewrite the changelog into clear, user-facing language before the release is executed.
5
+ ## Quick Reference
6
6
 
7
- ## What to Do
7
+ | Aspect | Detail |
8
+ |---|---|
9
+ | **Trigger** | `/supi:release` command |
10
+ | **Input** | Markdown changelog with commit hashes + ordered list of shell commands to execute |
11
+ | **Output** | Polished changelog shown to user → confirmation → sequential command execution with status reporting |
12
+ | **Scope** | Rewrite language only — no version changes, no command changes, no invented content |
8
13
 
9
- ### Rewrite commit entries
14
+ ## Input Contract
10
15
 
11
- Transform technical commit messages into language a user would understand:
12
- - "fix: handle null in parseConfig" -> "Fixed a crash when configuration values were missing"
13
- - "feat(auth): add token refresh" -> "Added automatic token refresh to prevent session expiry"
14
- - Remove implementation details that don't affect users
15
- - Make passive tense active where it reads better
16
+ You receive two things from `/supi:release`:
16
17
 
17
- ### Group related changes
18
+ 1. **Raw changelog** — Markdown with sections (some may be empty) and entries like:
19
+ ```
20
+ ### Features
21
+ - feat(auth): add token refresh (a1b2c3d)
22
+ - feat(auth): handle edge case in refresh (e4f5g6h)
23
+ ```
24
+ 2. **Release commands** — ordered shell commands to execute verbatim after confirmation:
25
+ ```
26
+ git tag v1.2.0
27
+ git push origin v1.2.0
28
+ npm publish
29
+ ```
18
30
 
19
- If multiple commits touch the same feature or area, consolidate them into a single entry:
20
- - Keep one representative hash (prefer the most descriptive commit)
21
- - Mention the scope if it helps users understand what area changed
31
+ ## Output Contract
22
32
 
23
- ### Preserve section structure
33
+ 1. Polished changelog (Markdown, same structure)
34
+ 2. Confirmation prompt: `"Ready to release v{version}?"`
35
+ 3. On approval: sequential command execution with per-command status
36
+ 4. On failure: structured error report (see Error Handling)
24
37
 
25
- Maintain the six sections in this order:
26
- 1. **Breaking Changes** — anything that requires user action on upgrade
38
+ ## Rewriting Entries
39
+
40
+ Transform technical commit messages into user-facing language. Every entry MUST retain its hash(es) at the end: `(abc1234)`.
41
+
42
+ ### Before / After
43
+
44
+ | Raw | Polished |
45
+ |---|---|
46
+ | `fix: handle null in parseConfig (a1b2c3d)` | `Fixed a crash when configuration values were missing (a1b2c3d)` |
47
+ | `feat(auth): add token refresh (e4f5g6h)` | `Added automatic token refresh to prevent session expiry (e4f5g6h)` |
48
+ | `refactor: extract parseConfig into util module (x9y8z7w)` | *(omit — internal restructuring with no user-visible effect)* |
49
+ | `X was fixed in the parser` | `Fixed X in the parser` *(prefer active voice)* |
50
+
51
+ ## Grouping Related Changes
52
+
53
+ When multiple commits touch the same feature, consolidate into one entry. Keep the hash of the commit whose message best describes the user-visible change.
54
+
55
+ ### Before
56
+
57
+ ```markdown
58
+ ### Features
59
+ - feat(auth): add token refresh endpoint (a1b2c3d)
60
+ - feat(auth): handle refresh token expiry edge case (e4f5g6h)
61
+ - feat(auth): add refresh token rotation (i7j8k9l)
62
+ ```
63
+
64
+ ### After
65
+
66
+ ```markdown
67
+ ### Features
68
+ - Added automatic token refresh with rotation and expiry handling (a1b2c3d)
69
+ ```
70
+
71
+ ## Section Order
72
+
73
+ Maintain these sections in this fixed order. Omit any section with no entries.
74
+
75
+ 1. **Breaking Changes** — requires user action on upgrade
27
76
  2. **Features** — new capabilities
28
77
  3. **Fixes** — bugs resolved
29
78
  4. **Improvements** — refactors, performance gains, reverts
30
79
  5. **Maintenance** — chores, CI, build, tests, docs, style
31
80
  6. **Other** — non-conventional commits
32
81
 
33
- If a section has no entries, omit it entirely.
34
-
35
- ### Preserve commit hashes
36
-
37
- Every entry must retain its original commit hash(es) for traceability. Format: `(abc1234)` at the end of the line.
82
+ ## MUST DO / MUST NOT DO
38
83
 
39
- ## What NOT to Do
40
-
41
- - Do not change the version number
42
- - Do not invent features or fixes not represented in the provided commits
43
- - Do not skip the confirmation step before executing commands
44
- - Do not modify the release commands provided execute them exactly as given
45
- - Do not reorder sections (Breaking > Features > Fixes > Improvements > Maintenance > Other)
84
+ | MUST | MUST NOT |
85
+ |---|---|
86
+ | Retain original commit hash(es) on every entry | Change the version number |
87
+ | Omit empty sections entirely | Invent features or fixes not in the provided commits |
88
+ | Consolidate related commits into one entry | Modify or reorder the release commands |
89
+ | Use active voice ("Fixed X" not "X was fixed") | Skip the confirmation step |
90
+ | Omit internal-only commits (refactors, renames, extractions with no user-visible effect) | Reorder sections from the fixed order above |
91
+ | Always include scope when the changelog covers multiple packages/areas | Attempt cleanup or undo after a failed command |
46
92
 
47
93
  ## Confirmation Flow
48
94
 
49
95
  After presenting the polished changelog:
50
96
 
51
97
  1. Show the full formatted changelog
52
- 2. Ask: "Ready to release v{version}?"
53
- 3. On **yes**: execute the provided commands in sequence, reporting each as it runs
54
- 4. On **no**: ask "Would you like to edit the changelog further, or abort entirely?"
55
- - On edit: allow the user to provide corrections, then re-confirm
56
- - On abort: stop without executing any commands
98
+ 2. Ask: `"Ready to release v{version}?"`
99
+ 3. **yes** execute commands in sequence, reporting each:
100
+ ```
101
+ Running: git tag v1.2.0 ...
102
+ Running: git push origin v1.2.0 ...
103
+ Running: npm publish ... ✓
104
+ Release v1.2.0 complete.
105
+ ```
106
+ 4. **no** → ask: `"Would you like to edit the changelog further, or abort entirely?"`
107
+ - **edit**: accept corrections, re-present, re-confirm
108
+ - **abort**: stop without executing any commands
57
109
 
58
110
  ## Error Handling
59
111
 
60
- If any release command fails:
61
- - Stop immediately — do not run subsequent commands
62
- - Report the exact error output
63
- - List which commands succeeded before the failure
64
- - List which commands were not run
65
- - Do not attempt to clean up or undo — leave that to the user
112
+ If any release command fails, stop immediately. Report in this format:
113
+
114
+ ```
115
+ Command failed: npm publish
116
+ Error: ERR_403 You do not have permission to publish
117
+
118
+ Succeeded:
119
+ ✓ git tag v1.2.0
120
+ ✓ git push origin v1.2.0
121
+
122
+ Not run:
123
+ - gh release create v1.2.0
124
+
125
+ Manual intervention required — do not attempt to undo.
126
+ ```
127
+
128
+ ## Final Checklist
129
+
130
+ Before yielding the polished changelog, verify:
131
+
132
+ - [ ] Every entry has at least one commit hash
133
+ - [ ] No empty sections remain
134
+ - [ ] Version number is unchanged from the original
135
+ - [ ] Release commands are unmodified
136
+ - [ ] No internal-only commits (pure refactors, renames) appear in the output
137
+ - [ ] Sections follow the fixed order
@@ -5,79 +5,130 @@ description: Test-driven development — write the test first, watch it fail, wr
5
5
 
6
6
  # Test-Driven Development
7
7
 
8
- ## Iron Law
8
+ Write the failing test first. Then make it pass. Then clean up. Every time.
9
+
10
+ ## Quick Reference
11
+
12
+ | Field | Value |
13
+ |-------|-------|
14
+ | Scope | Any code change: new feature, bug fix, refactor |
15
+ | Input | Feature request, bug report, or function signature to implement |
16
+ | Output | Test file(s) + implementation, all tests green, no dead code |
17
+ | Cycle | RED → GREEN → REFACTOR (never skip a phase) |
18
+ | Core rule | You MUST NOT write production code without a failing test |
19
+ | Mocks | Mock only external I/O (network, filesystem, third-party APIs). All internal code uses real implementations. |
20
+
21
+ ## The Cycle
22
+
23
+ ### RED — Write a Failing Test
24
+
25
+ 1. One behavior per test. If the name needs "and", split it.
26
+ 2. Name describes expected behavior, not implementation.
27
+ 3. Run the test. It MUST fail (not error). Confirm:
28
+ - Failure message matches your expectation.
29
+ - It fails because the feature is missing, not because of a typo or import error.
30
+ 4. If the test passes immediately, you are testing existing behavior — rewrite the test.
31
+
32
+ ```typescript
33
+ // RED: test for a function that doesn't exist yet
34
+ test("parsePort returns number for valid port string", () => {
35
+ expect(parsePort("8080")).toBe(8080);
36
+ });
37
+
38
+ // Run → FAIL: parsePort is not defined
39
+ // Good: fails because the function is missing.
40
+ //
41
+ // BAD fail: "Cannot find module './parser'"
42
+ // That's an error, not a test failure. Fix the import first.
43
+ ```
44
+
45
+ ### GREEN — Minimal Code to Pass
46
+
47
+ 1. Write the simplest code that makes the failing test pass.
48
+ 2. You MUST NOT add features, refactor, or "improve" beyond what the test demands.
49
+ 3. Run all tests. They MUST all pass with clean output.
50
+ 4. If the new test fails, fix the code — not the test.
51
+
52
+ ```typescript
53
+ // GREEN: minimal implementation — nothing extra
54
+ function parsePort(value: string): number {
55
+ return Number(value);
56
+ }
57
+
58
+ // Run → PASS. Stop here. Don't add validation yet —
59
+ // no test demands it.
60
+ ```
61
+
62
+ ### REFACTOR — Clean Up (Green Tests Only)
63
+
64
+ 1. Remove duplication, improve names, extract helpers.
65
+ 2. Keep all tests green. You MUST NOT add behavior during refactor.
66
+ 3. Limit refactor scope to code touched in this cycle. Time-box: if it takes more than a few minutes, defer to a separate cycle.
67
+
68
+ ```typescript
69
+ // After adding a second test for invalid input and making it green,
70
+ // you notice duplication between parsePort and parseHost.
71
+ // REFACTOR: extract shared parsing logic.
72
+
73
+ // BEFORE (duplication)
74
+ function parsePort(v: string): number { return Number(v); }
75
+ function parseHost(v: string): string { return v.trim().toLowerCase(); }
76
+
77
+ // AFTER (shared helper, both tests still green)
78
+ function sanitize(v: string): string { return v.trim(); }
79
+ function parsePort(v: string): number { return Number(sanitize(v)); }
80
+ function parseHost(v: string): string { return sanitize(v).toLowerCase(); }
81
+ ```
9
82
 
10
- **NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.**
11
-
12
- Write code before the test? Delete it. Start over. No exceptions.
13
-
14
- ## Red-Green-Refactor
15
-
16
- ### RED — Write Failing Test
17
-
18
- - One behavior per test. "and" in the name? Split it.
19
- - Clear name that describes behavior.
20
- - Real code, not mocks (unless unavoidable).
21
-
22
- **Watch it fail. MANDATORY.**
23
- - Confirm: fails (not errors), failure message expected, fails because feature missing.
24
- - Test passes? You're testing existing behavior. Fix the test.
25
-
26
- ### GREEN — Minimal Code
27
-
28
- Write the simplest code that makes the test pass.
29
-
30
- - Don't add features, refactor other code, or "improve" beyond the test.
31
-
32
- **Watch it pass. MANDATORY.**
33
- - Confirm: test passes, other tests still pass, output pristine.
34
- - Test fails? Fix code, not test.
35
-
36
- ### REFACTOR — Clean Up (After Green Only)
37
-
38
- - Remove duplication, improve names, extract helpers.
39
- - Keep tests green. Don't add behavior.
40
-
41
- ## Verification Checklist
42
-
43
- Before marking work complete:
44
-
45
- - [ ] Every new function/method has a test
46
- - [ ] Watched each test fail before implementing
47
- - [ ] Each test failed for expected reason (feature missing, not typo)
48
- - [ ] Wrote minimal code to pass each test
49
- - [ ] All tests pass with pristine output
50
- - [ ] Tests use real code (mocks only if unavoidable)
51
- - [ ] Edge cases and errors covered
52
-
53
- ## Red Flags — STOP and Start Over
54
-
55
- - Code before test
56
- - Test after implementation
57
- - Test passes immediately
58
- - Can't explain why test failed
59
- - Tests added "later"
60
- - Rationalizing "just this once"
61
-
62
- All of these mean: delete code, start over with TDD.
63
-
64
- ## Testing Anti-Patterns
83
+ ## Bug Fix Flow
65
84
 
66
- - Don't test mock behavior instead of real behavior
67
- - Don't add test-only methods to production classes
68
- - Don't mock without understanding dependencies
69
- - Mocks are tools to isolate, not things to test
85
+ ```
86
+ Bug reported Write failing test that reproduces it → GREEN → REFACTOR
87
+ ```
88
+
89
+ ```typescript
90
+ // Bug: parsePort(" 8080 ") returns NaN instead of 8080.
91
+ // RED: write a test that exposes the bug
92
+ test("parsePort trims whitespace", () => {
93
+ expect(parsePort(" 8080 ")).toBe(8080);
94
+ });
95
+ // Run → FAIL: Expected 8080, received NaN. Good — bug reproduced.
96
+
97
+ // GREEN: fix the implementation
98
+ function parsePort(v: string): number {
99
+ return Number(v.trim()); // ← minimal fix
100
+ }
101
+ // Run → PASS. Bug fixed. Test prevents regression.
102
+ ```
103
+
104
+ ## MUST DO / MUST NOT DO
105
+
106
+ | MUST DO | MUST NOT DO |
107
+ |---------|-------------|
108
+ | Run the test and watch it fail before writing code | Write production code before a failing test exists |
109
+ | Confirm failure is for the expected reason | Ignore why a test failed (typo ≠ missing feature) |
110
+ | Write the simplest passing implementation | Add unrequested features during GREEN |
111
+ | Keep all tests green during REFACTOR | Add new behavior during REFACTOR |
112
+ | Use real implementations for internal code | Mock internal modules to avoid setup effort |
113
+ | Write one assertion per behavior | Stuff multiple behaviors into one test |
114
+ | Test edge cases and error paths | Test only the happy path |
70
115
 
71
116
  ## When Stuck
72
117
 
73
118
  | Problem | Solution |
74
119
  |---------|----------|
75
- | Don't know how to test | Write wished-for API. Write assertion first. Ask. |
76
- | Test too complicated | Design too complicated. Simplify interface. |
77
- | Must mock everything | Code too coupled. Use dependency injection. |
78
- | Test setup huge | Extract helpers. Still complex? Simplify design. |
120
+ | Don't know how to test it | Write the API you wish existed. Write the assertion first. |
121
+ | Test too complicated | Interface too complicated. Simplify the design. |
122
+ | Must mock everything | Code too coupled. Introduce dependency injection. |
123
+ | Test setup is huge | Extract test helpers. Still complex? Simplify the production design. |
124
+ | Can't find test files / runner | Check `package.json` scripts, look for existing `*.test.*` or `*.spec.*` files, match the project's conventions. |
79
125
 
80
- ## Bug Fix Flow
126
+ ## Verification Checklist
81
127
 
82
- Bug found? Write a failing test reproducing it. Follow the TDD cycle.
83
- The test proves the fix and prevents regression. Never fix bugs without a test.
128
+ - [ ] Every new function/method has a test
129
+ - [ ] Each test was watched failing before implementation
130
+ - [ ] Each failure was for the expected reason
131
+ - [ ] All tests pass with clean output
132
+ - [ ] Mocks limited to external I/O only
133
+ - [ ] Edge cases and error paths covered
134
+ - [ ] No dead code or unrequested features added
@@ -5,50 +5,84 @@ description: Verification before completion — evidence before claims, always
5
5
 
6
6
  # Verification Before Completion
7
7
 
8
- ## Iron Law
8
+ Evidence before assertions. No completion claim without fresh verification output.
9
9
 
10
- **NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE.**
10
+ ## Quick Reference
11
11
 
12
- Claiming work is complete without verification is dishonesty, not efficiency.
13
- Evidence before assertions, always.
12
+ | Aspect | Detail |
13
+ |--------|--------|
14
+ | **Scope** | Every status/completion claim before it leaves the agent |
15
+ | **Input** | A completion claim about to be made (tests pass, build succeeds, bug fixed, etc.) |
16
+ | **Output** | The claim restated with evidence (command + output), OR a corrected status with evidence |
17
+ | **Core rule** | Run the proving command → read its full output → cite evidence in the claim |
14
18
 
15
- ## The Gate Function (Mandatory Before Any Status Claim)
19
+ ## The Gate Function
16
20
 
17
- 1. **IDENTIFY:** What command proves this claim?
18
- 2. **RUN:** Execute the FULL command (fresh, complete).
19
- 3. **READ:** Full output. Check exit code. Count failures.
20
- 4. **VERIFY:** Does output confirm the claim?
21
- - If NO: State actual status with evidence.
22
- - If YES: State claim WITH evidence.
23
- 5. **ONLY THEN:** Make the claim.
21
+ Before making any status claim, execute these steps in order:
24
22
 
25
- Skip any step = lying, not verifying.
23
+ 1. **IDENTIFY** What single command proves this claim?
24
+ 2. **RUN** — Execute it fresh: no `--filter`, no subset, no cached result.
25
+ 3. **READ** — Check exit code. Scan output for failure/error indicators. Count failures.
26
+ 4. **VERIFY** — Does the output confirm the claim?
27
+ - **YES →** State claim with evidence (command run + key output).
28
+ - **NO →** State actual status with evidence. Do not soften.
29
+ 5. **CLAIM** — Only now may you assert completion.
30
+
31
+ ### Before / After
32
+
33
+ **Bad — claiming without evidence:**
34
+ ```
35
+ I've fixed the failing test. The build should be green now. Moving on to the next task.
36
+ ```
37
+
38
+ **Good — Gate Function applied:**
39
+ ```
40
+ Ran `bun test src/auth.test.ts` — 14/14 passing, exit 0.
41
+ Ran `bun run build` — compiled successfully, exit 0.
42
+ Auth fix verified: original symptom (401 on refresh) no longer reproduces.
43
+ ```
44
+
45
+ **Bad — partial verification presented as full:**
46
+ ```
47
+ Ran the linter — 0 errors. Build succeeds.
48
+ ```
49
+ (Linter passing does not prove the build succeeds. Two different commands.)
50
+
51
+ **Good — each claim has its own proof:**
52
+ ```
53
+ Ran `eslint src/` — 0 errors, 0 warnings.
54
+ Ran `bun run build` — exit 0, bundle output at dist/.
55
+ Both linter and build verified independently.
56
+ ```
26
57
 
27
58
  ## Common Failure Patterns
28
59
 
29
60
  | Claim | Requires | Not Sufficient |
30
61
  |-------|----------|----------------|
31
- | Tests pass | Test command output: 0 failures | Previous run, "should pass" |
32
- | Build succeeds | Build command: exit 0 | Linter passing, logs look good |
33
- | Bug fixed | Test original symptom: passes | Code changed, assumed fixed |
34
- | Regression test works | Red-green cycle verified | Test passes once |
35
- | Agent completed | VCS diff shows changes | Agent reports "success" |
36
- | Requirements met | Line-by-line checklist | Tests passing |
37
-
38
- ## Red Flags STOP Before Claiming
39
-
40
- - Using "should", "probably", "seems to"
41
- - Expressing satisfaction before verification ("Great!", "Perfect!", "Done!")
42
- - About to commit/push/PR without verification
43
- - Trusting agent success reports without checking
44
- - Relying on partial verification
45
- - Thinking "just this once"
46
-
47
- ## When to Apply
48
-
49
- ALWAYS before:
50
- - Any variation of success/completion claims
51
- - Any expression of satisfaction about work state
52
- - Committing, PR creation, task completion
53
- - Moving to next task
54
- - Delegating to agents
62
+ | Tests pass | Test command output showing 0 failures | Previous run, "should pass" |
63
+ | Build succeeds | Build command with exit 0 | Linter passing, "logs look good" |
64
+ | Bug fixed | Original symptom reproduced and now passes | Code changed, assumed fixed |
65
+ | Regression test works | Red-green cycle: test fails without fix, passes with it | Test passes once |
66
+ | Agent completed task | VCS diff shows expected changes | Agent self-reports "success" |
67
+ | Requirements met | Each requirement checked against output/behavior | "Tests passing" (tests may not cover all requirements) |
68
+
69
+ ## MUST DO / MUST NOT DO
70
+
71
+ | MUST DO | MUST NOT DO |
72
+ |---------|-------------|
73
+ | Run the exact proving command fresh before claiming | Rely on a previous run or memory |
74
+ | Cite command + output in the claim | Use hedging words: "should", "probably", "seems to" |
75
+ | Verify each distinct claim with its own command | Substitute one verification for another (linter ≠ build) |
76
+ | Check agent work via VCS diff, not agent self-report | Trust agent/tool success messages without checking |
77
+ | State actual status when verification fails | Express satisfaction ("Done!", "Perfect!") before verifying |
78
+
79
+ ## Final Checklist
80
+
81
+ Before any completion claim, confirm:
82
+
83
+ - [ ] Proving command identified and executed fresh
84
+ - [ ] Exit code checked
85
+ - [ ] Output scanned for errors/failures — count is zero
86
+ - [ ] Evidence (command + key output) included in the claim
87
+ - [ ] Each distinct claim verified independently
88
+ - [ ] If delegated to agent: VCS diff reviewed, not just agent report