@martinffx/atelier 1.1.0 → 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.
- package/CHANGELOG.md +16 -0
- package/README.md +7 -2
- package/package.json +1 -1
- package/skills/code-debug/SKILL.md +119 -187
- package/skills/code-debug/references/bug-patterns.md +71 -0
- package/skills/code-debug/references/techniques.md +44 -4
- package/skills/code-handoff/SKILL.md +16 -0
- package/skills/oracle-architect/SKILL.md +82 -1
- package/skills/oracle-architect/references/ddd-patterns.md +101 -0
- package/skills/oracle-architect/references/interface-design.md +203 -0
- package/skills/oracle-doubt/SKILL.md +252 -0
- package/skills/oracle-doubt/references/adversarial-prompt.md +47 -0
- package/skills/oracle-security/SKILL.md +225 -0
- package/skills/oracle-security/references/security-patterns.md +236 -0
- package/skills/oracle-security/references/threat-modeling-guide.md +137 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
3
19
|
## [1.1.0](https://github.com/martinffx/atelier/compare/v1.0.2...v1.1.0) (2026-05-23)
|
|
4
20
|
|
|
5
21
|
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ That's it. Your project is now configured for spec-driven development.
|
|
|
29
29
|
|
|
30
30
|
Atelier sets up three things in your project:
|
|
31
31
|
|
|
32
|
-
### 1. Skills (
|
|
32
|
+
### 1. Skills (34 available)
|
|
33
33
|
|
|
34
34
|
Specialized knowledge modules that auto-invoke based on context. Install them via the CLI (`--all` flag) or separately:
|
|
35
35
|
|
|
@@ -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,9 +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-
|
|
197
|
+
- `code-commit` — Generate and validate conventional commits
|
|
195
198
|
- `code-debug` — Systematic debugging workflow
|
|
196
199
|
- `code-docs` — README, API docs, changelog generation
|
|
200
|
+
- `code-handoff` — Compact conversation into handoff document
|
|
201
|
+
- `code-review` — Multi-agent code review with specialized reviewers
|
|
197
202
|
- `code-subagents` — Dispatch patterns for parallel implementation
|
|
198
203
|
|
|
199
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,258 +1,190 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-debug
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
is broken
|
|
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
|
-
|
|
14
|
-
narrow down the problem through systematic elimination.
|
|
13
|
+
A discipline for hard bugs. Skip phases only when explicitly justified.
|
|
15
14
|
|
|
16
|
-
|
|
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]."
|
|
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.
|
|
42
17
|
|
|
43
18
|
---
|
|
44
19
|
|
|
45
|
-
|
|
20
|
+
## Phase 1 — Build a feedback loop
|
|
46
21
|
|
|
47
|
-
|
|
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.
|
|
48
26
|
|
|
49
|
-
**
|
|
50
|
-
|
|
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?
|
|
27
|
+
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to
|
|
28
|
+
give up.**
|
|
54
29
|
|
|
55
|
-
|
|
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
|
-
```
|
|
30
|
+
### Ways to construct one — try them in roughly this order
|
|
63
31
|
|
|
64
|
-
**
|
|
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.
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Step 3: Form Hypothesis
|
|
53
|
+
Build the right feedback loop, and the bug is 90% fixed.
|
|
69
54
|
|
|
70
|
-
|
|
55
|
+
### Iterate on the loop itself
|
|
71
56
|
|
|
72
|
-
|
|
73
|
-
- Specific: "The user ID is undefined because..."
|
|
74
|
-
- Testable: Can verify with a test or log
|
|
75
|
-
- Grounded: Based on evidence, not guess
|
|
57
|
+
Treat the loop as a product. Once you have _a_ loop, ask:
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
- What's the actual vs expected behavior?
|
|
81
|
-
- What changed recently?
|
|
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.)
|
|
82
62
|
|
|
83
|
-
|
|
63
|
+
A 30-second flaky loop is barely better than no loop. A 2-second deterministic
|
|
64
|
+
loop is a debugging superpower.
|
|
84
65
|
|
|
85
|
-
|
|
66
|
+
### Non-deterministic bugs
|
|
86
67
|
|
|
87
|
-
|
|
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.
|
|
88
72
|
|
|
89
|
-
|
|
73
|
+
### When you genuinely cannot build a loop
|
|
90
74
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- Consider edge cases
|
|
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.
|
|
96
79
|
|
|
97
|
-
**
|
|
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
|
|
80
|
+
Do **not** proceed to hypothesise without a loop.
|
|
102
81
|
|
|
103
|
-
**
|
|
82
|
+
**Do not proceed to Phase 2 until you have a loop you believe in.**
|
|
104
83
|
|
|
105
84
|
---
|
|
106
85
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Confirm the fix works and doesn't break anything.
|
|
86
|
+
## Phase 2 — Reproduce
|
|
110
87
|
|
|
111
|
-
|
|
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
|
|
116
|
-
|
|
117
|
-
**Output:** "Fix verified. Tests passing. Regression test added."
|
|
118
|
-
|
|
119
|
-
---
|
|
88
|
+
Run the loop. Watch the bug appear.
|
|
120
89
|
|
|
121
|
-
|
|
90
|
+
Confirm:
|
|
122
91
|
|
|
123
|
-
|
|
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.
|
|
124
95
|
|
|
125
|
-
|
|
96
|
+
**Do not proceed until you reproduce the bug.**
|
|
126
97
|
|
|
127
|
-
|
|
128
|
-
- Quick checks in development
|
|
129
|
-
- When debugger isn't available
|
|
130
|
-
- Understanding flow in unfamiliar code
|
|
131
|
-
|
|
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
|
|
137
|
-
|
|
138
|
-
### Debugger
|
|
98
|
+
---
|
|
139
99
|
|
|
140
|
-
|
|
100
|
+
## Phase 3 — Hypothesise
|
|
141
101
|
|
|
142
|
-
**
|
|
143
|
-
|
|
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
|
-
**
|
|
105
|
+
Each hypothesis must be **falsifiable**: state the prediction it makes.
|
|
148
106
|
|
|
149
|
-
|
|
107
|
+
> Format: "If `<X>` is the cause, then `<changing Y>` will make the bug disappear / `<changing Z>` will make it worse."
|
|
150
108
|
|
|
151
|
-
|
|
109
|
+
If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
|
|
152
110
|
|
|
153
|
-
**
|
|
154
|
-
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
116
|
+
---
|
|
160
117
|
|
|
161
|
-
|
|
118
|
+
## Phase 4 — Instrument
|
|
162
119
|
|
|
163
|
-
|
|
120
|
+
Each probe must map to a specific prediction from Phase 3. **Change one variable
|
|
121
|
+
at a time.**
|
|
164
122
|
|
|
165
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
##
|
|
184
|
-
|
|
185
|
-
### Null/Undefined Errors
|
|
186
|
-
|
|
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
|
|
138
|
+
## Phase 5 — Fix + regression test
|
|
193
139
|
|
|
194
|
-
**
|
|
195
|
-
|
|
196
|
-
// Before
|
|
197
|
-
const name = user.profile.name;
|
|
140
|
+
Write the regression test **before the fix** — but only if there is a
|
|
141
|
+
**correct seam** for it.
|
|
198
142
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const name = user.profile.name;
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Race Conditions
|
|
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.
|
|
207
147
|
|
|
208
|
-
**
|
|
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.
|
|
209
151
|
|
|
210
|
-
|
|
211
|
-
1. Identify async operations
|
|
212
|
-
2. Find timing dependencies
|
|
213
|
-
3. Add delays or force ordering
|
|
152
|
+
If a correct seam exists:
|
|
214
153
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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.
|
|
219
159
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
**Symptoms:** Wrong output, wrong behavior
|
|
160
|
+
---
|
|
223
161
|
|
|
224
|
-
|
|
225
|
-
1. Trace through the logic manually
|
|
226
|
-
2. Compare expected vs actual at each step
|
|
227
|
-
3. Find the first step that diverges
|
|
162
|
+
## Phase 6 — Cleanup + post-mortem
|
|
228
163
|
|
|
229
|
-
|
|
230
|
-
- Fix the condition
|
|
231
|
-
- Correct the calculation
|
|
232
|
-
- Update the state correctly
|
|
164
|
+
Required before declaring done:
|
|
233
165
|
|
|
234
|
-
|
|
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
|
|
235
171
|
|
|
236
|
-
**
|
|
172
|
+
**Then ask: what would have prevented this bug?**
|
|
237
173
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
2. Identify hot paths
|
|
241
|
-
3. Optimize the bottleneck
|
|
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.
|
|
242
176
|
|
|
243
177
|
---
|
|
244
178
|
|
|
245
|
-
##
|
|
179
|
+
## References
|
|
246
180
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
-
|
|
250
|
-
|
|
251
|
-
---
|
|
181
|
+
- **Language-specific tools** → `references/language-tools.md`
|
|
182
|
+
- **Common bug patterns** → `references/bug-patterns.md`
|
|
183
|
+
- **Logging & techniques** → `references/techniques.md`
|
|
252
184
|
|
|
253
185
|
## Output Format
|
|
254
186
|
|
|
255
|
-
After each debugging session,
|
|
187
|
+
After each debugging session, summarise:
|
|
256
188
|
|
|
257
189
|
```
|
|
258
190
|
## Debug Summary
|
|
@@ -261,7 +193,7 @@ After each debugging session, summarize:
|
|
|
261
193
|
**Root Cause:** [What actually was wrong]
|
|
262
194
|
**Fix:** [How you fixed it]
|
|
263
195
|
**Verification:** [Test results]
|
|
264
|
-
**Prevention:** [Regression test added?]
|
|
196
|
+
**Prevention:** [Regression test added? Architectural finding?]
|
|
265
197
|
```
|
|
266
198
|
|
|
267
199
|
This helps future-you understand what happened.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Common Bug Patterns
|
|
2
|
+
|
|
3
|
+
Quick reference for recognising and fixing recurring bug categories.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Null/Undefined Errors
|
|
8
|
+
|
|
9
|
+
**Symptoms:** Cannot read property X of undefined
|
|
10
|
+
|
|
11
|
+
**Debug approach:**
|
|
12
|
+
1. Find where the value becomes undefined
|
|
13
|
+
2. Trace back where it should come from
|
|
14
|
+
3. Add guard or fix source
|
|
15
|
+
|
|
16
|
+
**Fix patterns:**
|
|
17
|
+
```javascript
|
|
18
|
+
// Before
|
|
19
|
+
const name = user.profile.name;
|
|
20
|
+
|
|
21
|
+
// After
|
|
22
|
+
const name = user?.profile?.name ?? 'Unknown';
|
|
23
|
+
// or
|
|
24
|
+
if (!user?.profile) return;
|
|
25
|
+
const name = user.profile.name;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Race Conditions
|
|
31
|
+
|
|
32
|
+
**Symptoms:** Intermittent failures, flaky tests
|
|
33
|
+
|
|
34
|
+
**Debug approach:**
|
|
35
|
+
1. Identify async operations
|
|
36
|
+
2. Find timing dependencies
|
|
37
|
+
3. Add delays or force ordering to confirm
|
|
38
|
+
|
|
39
|
+
**Fix patterns:**
|
|
40
|
+
- Use async/await properly
|
|
41
|
+
- Add proper synchronization
|
|
42
|
+
- Consider immutable state
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Logic Errors
|
|
47
|
+
|
|
48
|
+
**Symptoms:** Wrong output, wrong behaviour
|
|
49
|
+
|
|
50
|
+
**Debug approach:**
|
|
51
|
+
1. Trace through the logic manually
|
|
52
|
+
2. Compare expected vs actual at each step
|
|
53
|
+
3. Find the first step that diverges
|
|
54
|
+
|
|
55
|
+
**Fix patterns:**
|
|
56
|
+
- Fix the condition
|
|
57
|
+
- Correct the calculation
|
|
58
|
+
- Update the state correctly
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Performance Issues
|
|
63
|
+
|
|
64
|
+
**Symptoms:** Slow, memory leaks, timeouts
|
|
65
|
+
|
|
66
|
+
**Debug approach:**
|
|
67
|
+
1. Measure first (don't guess)
|
|
68
|
+
2. Identify hot paths
|
|
69
|
+
3. Optimize the bottleneck
|
|
70
|
+
|
|
71
|
+
**See also:** Phase 4 "Perf branch" in SKILL.md for the disciplined approach.
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
**Do:**
|
|
14
14
|
- Print at function entry/exit to trace execution
|
|
15
15
|
- Print variable values at key decision points
|
|
16
|
-
- Use descriptive labels: console.log('userId:', userId)
|
|
17
|
-
- Print full objects for inspection: console.log(JSON.stringify(data, null, 2))
|
|
16
|
+
- Use descriptive labels: `console.log('userId:', userId)`
|
|
17
|
+
- Print full objects for inspection: `console.log(JSON.stringify(data, null, 2))`
|
|
18
18
|
|
|
19
19
|
**Don't:**
|
|
20
20
|
- Leave print statements in production code
|
|
@@ -22,9 +22,25 @@
|
|
|
22
22
|
- Over-print (noise obscures signal)
|
|
23
23
|
- Print in tight loops (use breakpoints instead)
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Tagged Debug Logs
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
When instrumenting during a debugging session, tag every temporary log with a
|
|
28
|
+
unique prefix so cleanup is trivial:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
console.log('[DEBUG-a4f2] userId:', userId);
|
|
32
|
+
console.log('[DEBUG-a4f2] payload:', payload);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Cleanup: `grep -r '\[DEBUG-' .` → delete all matches.
|
|
36
|
+
|
|
37
|
+
Untagged logs survive; tagged logs die.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Structured Logging
|
|
42
|
+
|
|
43
|
+
Better than `console.log` for production:
|
|
28
44
|
|
|
29
45
|
```javascript
|
|
30
46
|
const logger = {
|
|
@@ -115,3 +131,27 @@ logger.error('Request failed', {
|
|
|
115
131
|
| INFO | Normal operation events |
|
|
116
132
|
| WARN | Something unexpected, but handled |
|
|
117
133
|
| ERROR | Operation failed |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Performance Regression Techniques
|
|
138
|
+
|
|
139
|
+
### The Perf Branch
|
|
140
|
+
|
|
141
|
+
For performance regressions, logs are usually wrong. Instead:
|
|
142
|
+
|
|
143
|
+
1. **Establish a baseline measurement** using one of:
|
|
144
|
+
- Timing harness around the suspect code path
|
|
145
|
+
- `performance.now()` in browser / `process.hrtime()` in Node
|
|
146
|
+
- CPU profiler (Chrome DevTools, `node --prof`, py-spy, etc.)
|
|
147
|
+
- Database query planner (`EXPLAIN ANALYZE`)
|
|
148
|
+
|
|
149
|
+
2. **Bisect** — narrow down which commit / change introduced the regression.
|
|
150
|
+
|
|
151
|
+
3. **Measure first, fix second.** Do not optimise without data.
|
|
152
|
+
|
|
153
|
+
### Hot Path Identification
|
|
154
|
+
|
|
155
|
+
- Profile before guessing
|
|
156
|
+
- Look for O(n²) algorithms, unnecessary renders, blocking operations
|
|
157
|
+
- Check for N+1 queries, unbounded caches, recursive without memoisation
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-handoff
|
|
3
|
+
description: Compact the current conversation into a handoff document for another agent to pick up.
|
|
4
|
+
argument-hint: "What will the next session be used for?"
|
|
5
|
+
user-invocable: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS - not the current workspace.
|
|
9
|
+
|
|
10
|
+
Include a "suggested skills" section in the document, which suggests skills that the agent should invoke.
|
|
11
|
+
|
|
12
|
+
Do not duplicate content already captured in other artifacts (PRDs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
|
|
13
|
+
|
|
14
|
+
Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
|
|
15
|
+
|
|
16
|
+
If the user passed arguments, treat them as a description of what the next session will focus on and tailor the doc accordingly.
|