@martinffx/atelier 1.0.2 → 1.2.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 (42) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +6 -5
  3. package/package.json +1 -1
  4. package/skills/{code-conventional-commit → code-commit}/SKILL.md +16 -1
  5. package/skills/code-commit/references/pr-workflow.md +145 -0
  6. package/skills/code-debug/SKILL.md +119 -191
  7. package/skills/code-debug/references/bug-patterns.md +71 -0
  8. package/skills/code-debug/references/techniques.md +44 -4
  9. package/skills/code-handoff/SKILL.md +16 -0
  10. package/skills/code-review/references/reviewers.md +3 -11
  11. package/skills/code-review/references/rq.md +4 -5
  12. package/skills/oracle-architect/SKILL.md +82 -1
  13. package/skills/oracle-architect/references/ddd-patterns.md +101 -0
  14. package/skills/oracle-architect/references/interface-design.md +203 -0
  15. package/skills/oracle-doubt/SKILL.md +252 -0
  16. package/skills/oracle-doubt/references/adversarial-prompt.md +47 -0
  17. package/skills/oracle-grillme/SKILL.md +160 -0
  18. package/skills/oracle-grillme/references/ADR-FORMAT.md +47 -0
  19. package/skills/oracle-grillme/references/CONTEXT-FORMAT.md +63 -0
  20. package/skills/oracle-security/SKILL.md +225 -0
  21. package/skills/oracle-security/references/security-patterns.md +236 -0
  22. package/skills/oracle-security/references/threat-modeling-guide.md +137 -0
  23. package/skills/spec-finish/SKILL.md +2 -5
  24. package/skills/spec-implement/SKILL.md +1 -1
  25. package/skills/code-conventional-commit/evals/evals.json +0 -23
  26. package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/commit-message.txt +0 -4
  27. package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/eval_metadata.json +0 -6
  28. package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/eval_metadata.json +0 -6
  29. package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/validation-result.txt +0 -16
  30. package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/commit-message.txt +0 -8
  31. package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/eval_metadata.json +0 -6
  32. package/skills/code-conventional-commit/workspace/iteration-1/report.html +0 -1325
  33. package/skills/code-git-worktrees/SKILL.md +0 -218
  34. package/skills/code-perf/SKILL.md +0 -163
  35. package/skills/code-perf/references/common-bottlenecks.md +0 -124
  36. package/skills/code-perf/references/optimization-patterns.md +0 -167
  37. package/skills/code-perf/references/profiling-tools.md +0 -126
  38. package/skills/code-security/SKILL.md +0 -183
  39. package/skills/code-security/references/owasp-top-10.md +0 -129
  40. package/skills/code-security/references/security-tools.md +0 -102
  41. package/skills/code-security/references/vulnerability-patterns.md +0 -129
  42. package/skills/code-stacked-commit/SKILL.md +0 -155
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/martinffx/atelier/compare/v1.1.0...v1.2.0) (2026-05-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * **code-debug:** upgrade to six-phase diagnose workflow ([62dec10](https://github.com/martinffx/atelier/commit/62dec1045555947462a447f4579e83b0dee63d17))
9
+ * **code-debug:** upgrade to six-phase diagnose workflow ([8df277d](https://github.com/martinffx/atelier/commit/8df277d425ca16dfa63a8bf1949003e3e6aaf87c))
10
+ * **code-handoff:** add code-handoff skill ([5ab6f5f](https://github.com/martinffx/atelier/commit/5ab6f5f5d890b024718e3b69103b23c3eb1205ef))
11
+ * **oracle-architect:** add vocabulary, evaluation heuristics, and interface design reference ([7c528d3](https://github.com/martinffx/atelier/commit/7c528d308ebc98929cfc6be17e8d5c7444b36607))
12
+ * **oracle-architect:** add vocabulary, evaluation heuristics, and interface design reference ([63ee753](https://github.com/martinffx/atelier/commit/63ee75380c4d4be92708539173534566f2033dea))
13
+ * **oracle-security:** add security architecture and threat modeling skill ([8fcbd87](https://github.com/martinffx/atelier/commit/8fcbd87943bcb23d51480ed9e9bd702f19817096))
14
+ * **oracle-security:** add security architecture and threat modeling skill ([69b6fdc](https://github.com/martinffx/atelier/commit/69b6fdcdf1f2b7732fb339cbf1d64c1fb7252eb7))
15
+ * **skills:** add code-handoff skill ([012f467](https://github.com/martinffx/atelier/commit/012f4676d48c7f6799361ca6bdfef12f33a8849e))
16
+ * **skills:** add oracle-doubt skill ([adf118b](https://github.com/martinffx/atelier/commit/adf118be197da43195c9ddd052b53f8c714405b5))
17
+ * **skills:** add oracle-doubt skill for adversarial review ([447673e](https://github.com/martinffx/atelier/commit/447673eb7904e4d28306360f64329f7874db5b2b))
18
+
19
+ ## [1.1.0](https://github.com/martinffx/atelier/compare/v1.0.2...v1.1.0) (2026-05-23)
20
+
21
+
22
+ ### Features
23
+
24
+ * **skills:** add oracle-grillme socratic interrogation skill ([6ad5ce5](https://github.com/martinffx/atelier/commit/6ad5ce52428863b51fec83880ce8083bb80aa3a0))
25
+ * **skills:** add oracle-grillme socratic interrogation skill ([fd21606](https://github.com/martinffx/atelier/commit/fd2160639b82ba335963bec3128d9c6a5b5801b6))
26
+ * **skills:** add PR creation workflow to code-commit ([25bb826](https://github.com/martinffx/atelier/commit/25bb8264364cb1c5ee843baea0127eaba3935c78))
27
+
3
28
  ## [1.0.2](https://github.com/martinffx/atelier/compare/v1.0.1...v1.0.2) (2026-05-23)
4
29
 
5
30
 
package/README.md CHANGED
@@ -160,6 +160,9 @@ Analytical skills that provide patterns, principles, and deep reasoning. These a
160
160
 
161
161
  - `oracle-architect` — DDD, hexagonal architecture, component design
162
162
  - `oracle-challenge` — Challenge assumptions, validate decisions
163
+ - `oracle-doubt` — Adversarial review of non-trivial decisions
164
+ - `oracle-grillme` — Socratic interrogation of plans against domain model
165
+ - `oracle-security` — Security architecture and threat modeling
163
166
  - `oracle-testing` — Stub-driven TDD, layer boundary testing
164
167
  - `oracle-thinkdeep` — Extended sequential reasoning for complex problems
165
168
 
@@ -191,13 +194,11 @@ Technology-specific patterns and best practices. These are like having a senior
191
194
 
192
195
  Task-specific tools you invoke when you need them.
193
196
 
194
- - `code-review` — Multi-agent code review with specialized reviewers
197
+ - `code-commit` — Generate and validate conventional commits
195
198
  - `code-debug` — Systematic debugging workflow
196
199
  - `code-docs` — README, API docs, changelog generation
197
- - `code-security` — Security audit and vulnerability detection
198
- - `code-perf` — Performance profiling and optimization
199
- - `code-git-worktrees` — Isolated git worktrees for feature work
200
- - `code-stacked-commit` — Manage stacked commits with Graphite
200
+ - `code-handoff` — Compact conversation into handoff document
201
+ - `code-review` — Multi-agent code review with specialized reviewers
201
202
  - `code-subagents` — Dispatch patterns for parallel implementation
202
203
 
203
204
  Skills are auto-invoked based on their description when you work with relevant technologies. No commands needed—just install and AI agents will use them when appropriate.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@martinffx/atelier",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Personal development toolkit - spec-driven development, code quality, deep thinking, and ecosystem patterns",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: code-conventional-commit
2
+ name: code-commit
3
3
  description: Generate and validate conventional commit messages following the conventionalcommits.org spec. Use whenever the user wants to commit code, mentions commit messages, git commit, or asks to create a commit. Triggers on "commit", "git commit", "conventional", or when reviewing commit message format.
4
4
  user-invocable: true
5
5
  ---
@@ -76,6 +76,21 @@ When user asks to validate or check a commit message:
76
76
  4. Check subject follows rules (lowercase, imperative, no period)
77
77
  5. Flag any issues found
78
78
 
79
+ ### 3. Create Pull Request
80
+
81
+ When user wants to open a PR or after finishing commits on a feature branch:
82
+
83
+ 1. Verify on a feature branch (not main): `git branch --show-current`
84
+ 2. Check for project PR template: `ls .github/PULL_REQUEST_TEMPLATE.md`
85
+ 3. Push branch if needed: `git push -u origin <branch>`
86
+ 4. Create PR via `gh pr create`:
87
+ - Use `--fill` if commits are clean (auto-populates title/body)
88
+ - Use `--draft` for work-in-progress
89
+ - Use interactive mode if body needs custom content
90
+ 5. Show the PR URL to the user
91
+
92
+ See [references/pr-workflow.md](references/pr-workflow.md) for full workflow details.
93
+
79
94
  ## Input Methods
80
95
 
81
96
  | Input | Action |
@@ -0,0 +1,145 @@
1
+ # Pull Request Workflow
2
+
3
+ Creating GitHub pull requests via the `gh` CLI.
4
+
5
+ ## Prerequisites
6
+
7
+ - `gh` CLI installed and authenticated: `gh auth status`
8
+ - Remote `origin` points to GitHub: `git remote -v`
9
+ - On a feature branch (not main): `git branch --show-current`
10
+
11
+ ## Check for Project Template
12
+
13
+ Before creating a PR, check if the project has its own PR template:
14
+
15
+ ```bash
16
+ # Check for PR template in .github/
17
+ ls .github/PULL_REQUEST_TEMPLATE.md 2>/dev/null || echo "No project template found"
18
+ ```
19
+
20
+ **If found:** Use it. The `gh pr create` command will automatically pick it up.
21
+
22
+ **If not found:** Use the minimal template below.
23
+
24
+ ---
25
+
26
+ ## Create Pull Request
27
+
28
+ ### Option 1: Auto-fill from commits (recommended)
29
+
30
+ ```bash
31
+ gh pr create --fill
32
+ ```
33
+
34
+ This uses the commit messages as the PR title and body. Best when commits are clean and conventional.
35
+
36
+ ### Option 2: Interactive
37
+
38
+ ```bash
39
+ gh pr create
40
+ ```
41
+
42
+ Opens an editor with the template. Fill in title and body interactively.
43
+
44
+ ### Option 3: Inline (for simple PRs)
45
+
46
+ ```bash
47
+ gh pr create --title "feat(auth): add JWT authentication" --body "Implements token-based auth with refresh support."
48
+ ```
49
+
50
+ ---
51
+
52
+ ## PR Title Format
53
+
54
+ Follow conventional commit style for PR titles:
55
+
56
+ ```
57
+ <type>(<scope>): <description>
58
+ ```
59
+
60
+ Examples:
61
+ - `feat(api): add user profile endpoint`
62
+ - `fix(db): resolve connection pool leak`
63
+ - `docs(readme): update installation instructions`
64
+
65
+ ---
66
+
67
+ ## PR Body Template (fallback if no project template)
68
+
69
+ ```markdown
70
+ ## Description
71
+ <!-- What does this PR do? -->
72
+
73
+ ## Changes
74
+ <!-- What changed? -->
75
+
76
+ ## Testing
77
+ <!-- How was this tested? -->
78
+
79
+ ## Checklist
80
+ - [ ] Tests pass
81
+ - [ ] Commits follow conventional format
82
+ - [ ] Documentation updated (if needed)
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Linking Issues
88
+
89
+ Add issue references in the PR body:
90
+
91
+ ```markdown
92
+ Closes #123
93
+ Fixes #456
94
+ Relates to #789
95
+ ```
96
+
97
+ This auto-closes linked issues when the PR merges.
98
+
99
+ ---
100
+
101
+ ## Draft PRs
102
+
103
+ For work-in-progress PRs:
104
+
105
+ ```bash
106
+ gh pr create --draft
107
+ ```
108
+
109
+ Mark as ready later:
110
+
111
+ ```bash
112
+ gh pr ready <pr-number>
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Review Requests
118
+
119
+ Request reviewers after creating the PR:
120
+
121
+ ```bash
122
+ gh pr edit <pr-number> --add-reviewer username
123
+ ```
124
+
125
+ Or add via the GitHub web UI.
126
+
127
+ ---
128
+
129
+ ## Verify PR Created
130
+
131
+ ```bash
132
+ gh pr view --web # Open in browser
133
+ gh pr status # Show PR status
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Common Mistakes
139
+
140
+ | Mistake | Fix |
141
+ |---------|-----|
142
+ | PR from main branch | Switch to feature branch first |
143
+ | No remote | `git remote add origin <url>` |
144
+ | Unpushed commits | `git push -u origin <branch>` |
145
+ | PR body is empty | Use `--fill` or write a description |
@@ -1,262 +1,190 @@
1
1
  ---
2
2
  name: code-debug
3
3
  description: >
4
- Systematic debugging workflow and techniques. Use when something is broken, not working as
5
- expected, or throwing errors. Covers reproduction, isolation, hypothesis formation, fix
6
- implementation, and verification. Also triggers on "why does X fail", "debug this", "this
7
- is broken", or when encountering errors or unexpected behavior.
4
+ Disciplined diagnosis loop for hard bugs and performance regressions.
5
+ Reproduce → minimise → hypothesise → instrument → fix → regression-test.
6
+ Use when user says "diagnose this" / "debug this", reports a bug, says
7
+ something is broken/throwing/failing, or describes a performance regression.
8
8
  user-invocable: true
9
9
  ---
10
10
 
11
11
  # Code Debug
12
12
 
13
- Systematic debugging workflow to find and fix bugs efficiently. Never guess — always
14
- narrow down the problem through systematic elimination.
13
+ A discipline for hard bugs. Skip phases only when explicitly justified.
15
14
 
16
- ## The Debugging Mindset
17
-
18
- | Bad | Good |
19
- |-----|------|
20
- | "I think it's..." | "Let me verify..." |
21
- | Changing random things | Binary search narrowing |
22
- | Hoping it'll work | Verifying each hypothesis |
23
- | Moving on after it works | Adding regression test |
24
-
25
- ## The Five-Step Workflow
26
-
27
- ### Step 1: Reproduce
28
-
29
- Create the smallest possible reproduction case.
30
-
31
- **Questions to answer:**
32
- - What exactly triggers the bug?
33
- - Can I make it happen on demand?
34
- - What's the minimal input that causes it?
35
-
36
- **Techniques:**
37
- - Extract exact steps from bug report
38
- - Remove unrelated factors
39
- - Create a minimal test case
40
-
41
- **Output:** "I can reproduce the bug by [exact steps]."
42
-
43
- ---
44
-
45
- ### Step 2: Isolate
46
-
47
- Narrow down where the bug lives using binary search.
48
-
49
- **Binary search strategies:**
50
- - Comment out half the code → does it still fail?
51
- - Isolate by layer: is it the UI, service, or data layer?
52
- - Isolate by file: which file contains the bug?
53
- - Isolate by function: which function causes the issue?
54
-
55
- **Git bisect** (for regression bugs):
56
- ```bash
57
- git bisect start
58
- git bisect bad # current commit is broken
59
- git bisect good <last-working-commit>
60
- # Run tests, mark good/bad
61
- git bisect reset # done
62
- ```
63
-
64
- **Output:** "The bug is in [specific file/function/component]."
15
+ When exploring the codebase, use the project's domain glossary to get a clear
16
+ mental model of the relevant modules, and check ADRs in the area you're touching.
65
17
 
66
18
  ---
67
19
 
68
- ### Step 3: Form Hypothesis
20
+ ## Phase 1 — Build a feedback loop
69
21
 
70
- Make a testable guess about the root cause.
22
+ **This is the skill.** Everything else is mechanical. If you have a fast,
23
+ deterministic, agent-runnable pass/fail signal for the bug, you will find the
24
+ cause — bisection, hypothesis-testing, and instrumentation all just consume
25
+ that signal. If you don't have one, no amount of staring at code will save you.
71
26
 
72
- **Good hypothesis:**
73
- - Specific: "The user ID is undefined because..."
74
- - Testable: Can verify with a test or log
75
- - Grounded: Based on evidence, not guess
27
+ Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to
28
+ give up.**
76
29
 
77
- **Questions to ask:**
78
- - Why does this happen?
79
- - What are the preconditions?
80
- - What's the actual vs expected behavior?
81
- - What changed recently?
30
+ ### Ways to construct one — try them in roughly this order
82
31
 
83
- **Output:** "I hypothesize that [root cause] because [evidence]."
32
+ 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
33
+ 2. **Curl / HTTP script** against a running dev server.
34
+ 3. **CLI invocation** with a fixture input, diffing stdout against a known-good
35
+ snapshot.
36
+ 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI,
37
+ asserts on DOM/console/network.
38
+ 5. **Replay a captured trace.** Save a real network request / payload / event
39
+ log to disk; replay it through the code path in isolation.
40
+ 6. **Throwaway harness.** Spin up a minimal subset of the system (one service,
41
+ mocked deps) that exercises the bug code path with a single function call.
42
+ 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000
43
+ random inputs and look for the failure mode.
44
+ 8. **Bisection harness.** If the bug appeared between two known states (commit,
45
+ dataset, version), automate "boot at state X, check, repeat" so you can
46
+ `git bisect run` it.
47
+ 9. **Differential loop.** Run the same input through old-version vs new-version
48
+ (or two configs) and diff outputs.
49
+ 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with
50
+ a structured script so the loop is still structured. Captured output feeds
51
+ back to you.
84
52
 
85
- ---
53
+ Build the right feedback loop, and the bug is 90% fixed.
86
54
 
87
- ### Step 4: Fix
55
+ ### Iterate on the loop itself
88
56
 
89
- Implement the fix based on your hypothesis.
57
+ Treat the loop as a product. Once you have _a_ loop, ask:
90
58
 
91
- **Rules:**
92
- - Make minimal changes
93
- - Don't refactor while fixing (separate concerns)
94
- - Write failing test first if possible
95
- - Consider edge cases
59
+ - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
60
+ - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
61
+ - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
96
62
 
97
- **Fix patterns:**
98
- - **Missing value** → Add null check or default
99
- - **Wrong value** → Correct the logic
100
- - **Exception** → Handle the error case
101
- - **Logic error** → Fix the condition
63
+ A 30-second flaky loop is barely better than no loop. A 2-second deterministic
64
+ loop is a debugging superpower.
102
65
 
103
- **Output:** "Fix applied: [brief description]."
66
+ ### Non-deterministic bugs
104
67
 
105
- ---
68
+ The goal is not a clean repro but a **higher reproduction rate**. Loop the
69
+ trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps.
70
+ A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's
71
+ debuggable.
106
72
 
107
- ### Step 5: Verify
73
+ ### When you genuinely cannot build a loop
108
74
 
109
- Confirm the fix works and doesn't break anything.
75
+ Stop and say so explicitly. List what you tried. Ask the user for:
76
+ (a) access to whatever environment reproduces it,
77
+ (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or
78
+ (c) permission to add temporary production instrumentation.
110
79
 
111
- **Verification steps:**
112
- 1. Run the reproduction case → should pass now
113
- 2. Run related tests → should pass
114
- 3. Run full test suite → should pass
115
- 4. Add regression test → prevents future breakage
80
+ Do **not** proceed to hypothesise without a loop.
116
81
 
117
- **Output:** "Fix verified. Tests passing. Regression test added."
82
+ **Do not proceed to Phase 2 until you have a loop you believe in.**
118
83
 
119
84
  ---
120
85
 
121
- ## Debugging Techniques
86
+ ## Phase 2 — Reproduce
122
87
 
123
- ### Print Debugging
88
+ Run the loop. Watch the bug appear.
124
89
 
125
- Quick and dirty, but sometimes the fastest way.
90
+ Confirm:
126
91
 
127
- **When to use:**
128
- - Quick checks in development
129
- - When debugger isn't available
130
- - Understanding flow in unfamiliar code
92
+ - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
93
+ - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
94
+ - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
131
95
 
132
- **Best practices:**
133
- - Print at entry/exit of functions
134
- - Print variable values at key points
135
- - Remove print statements before committing
136
- - Consider structured logging instead
96
+ **Do not proceed until you reproduce the bug.**
137
97
 
138
- ### Debugger
98
+ ---
139
99
 
140
- More powerful than print debugging.
100
+ ## Phase 3 — Hypothesise
141
101
 
142
- **When to use:**
143
- - Complex state to inspect
144
- - Stepping through logic
145
- - Evaluating expressions in context
102
+ Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis
103
+ generation anchors on the first plausible idea.
146
104
 
147
- **See references/language-tools.md for language-specific debugger commands.**
105
+ Each hypothesis must be **falsifiable**: state the prediction it makes.
148
106
 
149
- ### Logging
107
+ > Format: "If `<X>` is the cause, then `<changing Y>` will make the bug disappear / `<changing Z>` will make it worse."
150
108
 
151
- Better than print for production issues.
109
+ If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
152
110
 
153
- **Strategies:**
154
- - Add context: request ID, user ID, correlation IDs
155
- - Log at appropriate levels: DEBUG, INFO, WARN, ERROR
156
- - Don't log sensitive data
157
- - Structured logging (JSON) for easier parsing
111
+ **Show the ranked list to the user before testing.** They often have domain
112
+ knowledge that re-ranks instantly ("we just deployed a change to #3"), or know
113
+ hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't
114
+ block on it — proceed with your ranking if the user is AFK.
158
115
 
159
- **See references/techniques.md for logging patterns.**
116
+ ---
160
117
 
161
- ### Binary Search
118
+ ## Phase 4 — Instrument
162
119
 
163
- Halving the search space.
120
+ Each probe must map to a specific prediction from Phase 3. **Change one variable
121
+ at a time.**
164
122
 
165
- **Strategies:**
166
- - Comment out code blocks
167
- - Test with half the data
168
- - Compare working vs broken configurations
169
- - Git bisect for regressions
123
+ Tool preference:
170
124
 
171
- ### Rubber Ducking
125
+ 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
126
+ 2. **Targeted logs** at the boundaries that distinguish hypotheses.
127
+ 3. Never "log everything and grep".
172
128
 
173
- Explain the problem out loud (or to a rubber duck).
129
+ **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at
130
+ the end becomes a single grep. Untagged logs survive; tagged logs die.
174
131
 
175
- **Process:**
176
- 1. Describe the problem in detail
177
- 2. Explain what you expect to happen
178
- 3. Explain what's actually happening
179
- 4. Often the solution becomes clear mid-explanation
132
+ **Perf branch.** For performance regressions, logs are usually wrong. Instead:
133
+ establish a baseline measurement (timing harness, `performance.now()`, profiler,
134
+ query plan), then bisect. Measure first, fix second.
180
135
 
181
136
  ---
182
137
 
183
- ## Common Bug Patterns
138
+ ## Phase 5 — Fix + regression test
184
139
 
185
- ### Null/Undefined Errors
140
+ Write the regression test **before the fix** — but only if there is a
141
+ **correct seam** for it.
186
142
 
187
- **Symptoms:** Cannot read property X of undefined
188
-
189
- **Debug approach:**
190
- 1. Find where the value becomes undefined
191
- 2. Trace back where it should come from
192
- 3. Add guard or fix source
193
-
194
- **Fix patterns:**
195
- ```javascript
196
- // Before
197
- const name = user.profile.name;
198
-
199
- // After
200
- const name = user?.profile?.name ?? 'Unknown';
201
- // or
202
- if (!user?.profile) return;
203
- const name = user.profile.name;
204
- ```
143
+ A correct seam is one where the test exercises the **real bug pattern** as it
144
+ occurs at the call site. If the only available seam is too shallow (single-caller
145
+ test when the bug needs multiple callers, unit test that can't replicate the
146
+ chain that triggered the bug), a regression test there gives false confidence.
205
147
 
206
- ### Race Conditions
148
+ **If no correct seam exists, that itself is the finding.** Note it. The codebase
149
+ architecture is preventing the bug from being locked down. Flag this for the
150
+ next phase.
207
151
 
208
- **Symptoms:** Intermittent failures, flaky tests
152
+ If a correct seam exists:
209
153
 
210
- **Debug approach:**
211
- 1. Identify async operations
212
- 2. Find timing dependencies
213
- 3. Add delays or force ordering
154
+ 1. Turn the minimised repro into a failing test at that seam.
155
+ 2. Watch it fail.
156
+ 3. Apply the fix.
157
+ 4. Watch it pass.
158
+ 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
214
159
 
215
- **Fix patterns:**
216
- - Use async/await properly
217
- - Add proper synchronization
218
- - Consider immutable state
219
-
220
- ### Logic Errors
221
-
222
- **Symptoms:** Wrong output, wrong behavior
223
-
224
- **Debug approach:**
225
- 1. Trace through the logic manually
226
- 2. Compare expected vs actual at each step
227
- 3. Find the first step that diverges
160
+ ---
228
161
 
229
- **Fix patterns:**
230
- - Fix the condition
231
- - Correct the calculation
232
- - Update the state correctly
162
+ ## Phase 6 — Cleanup + post-mortem
233
163
 
234
- ### Performance Issues
164
+ Required before declaring done:
235
165
 
236
- **Symptoms:** Slow, memory leaks, timeouts
166
+ - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
167
+ - [ ] Regression test passes (or absence of seam is documented)
168
+ - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
169
+ - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
170
+ - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
237
171
 
238
- **Debug approach:**
239
- 1. Measure first (don't guess)
240
- 2. Identify hot paths
241
- 3. Optimize the bottleneck
172
+ **Then ask: what would have prevented this bug?**
242
173
 
243
- **See code-perf skill for detailed performance debugging.**
174
+ If the answer involves architectural change (no good test seam, tangled callers,
175
+ hidden coupling) flag this as a codebase health finding for the team.
244
176
 
245
177
  ---
246
178
 
247
- ## Skill Loading
179
+ ## References
248
180
 
249
- Check available skills for additional debugging support:
250
-
251
- - If dealing with performance issues → load code-perf
252
- - If security vulnerability suspected → load code-security
253
- - If debugging tests → load oracle-testing
254
-
255
- ---
181
+ - **Language-specific tools** → `references/language-tools.md`
182
+ - **Common bug patterns** → `references/bug-patterns.md`
183
+ - **Logging & techniques** → `references/techniques.md`
256
184
 
257
185
  ## Output Format
258
186
 
259
- After each debugging session, summarize:
187
+ After each debugging session, summarise:
260
188
 
261
189
  ```
262
190
  ## Debug Summary
@@ -265,7 +193,7 @@ After each debugging session, summarize:
265
193
  **Root Cause:** [What actually was wrong]
266
194
  **Fix:** [How you fixed it]
267
195
  **Verification:** [Test results]
268
- **Prevention:** [Regression test added?]
196
+ **Prevention:** [Regression test added? Architectural finding?]
269
197
  ```
270
198
 
271
199
  This helps future-you understand what happened.