@martinffx/atelier 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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +285 -0
- package/agents/architect.md +38 -0
- package/agents/oracle.md +40 -0
- package/agents/recon.md +39 -0
- package/dist/atelier.js +33082 -0
- package/package.json +44 -0
- package/skills/code-conventional-commit/SKILL.md +134 -0
- package/skills/code-conventional-commit/evals/evals.json +23 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/commit-message.txt +4 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-0/with_skill/outputs/eval_metadata.json +6 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/eval_metadata.json +6 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-1/with_skill/outputs/validation-result.txt +16 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/commit-message.txt +8 -0
- package/skills/code-conventional-commit/workspace/iteration-1/eval-2/with_skill/outputs/eval_metadata.json +6 -0
- package/skills/code-conventional-commit/workspace/iteration-1/report.html +1325 -0
- package/skills/code-debug/SKILL.md +271 -0
- package/skills/code-debug/references/language-tools.md +139 -0
- package/skills/code-debug/references/techniques.md +117 -0
- package/skills/code-docs/SKILL.md +171 -0
- package/skills/code-docs/references/api-docs.md +116 -0
- package/skills/code-docs/references/changelog.md +64 -0
- package/skills/code-docs/references/readme-structure.md +94 -0
- package/skills/code-git-worktrees/SKILL.md +218 -0
- package/skills/code-perf/SKILL.md +163 -0
- package/skills/code-perf/references/common-bottlenecks.md +124 -0
- package/skills/code-perf/references/optimization-patterns.md +167 -0
- package/skills/code-perf/references/profiling-tools.md +126 -0
- package/skills/code-review/SKILL.md +78 -0
- package/skills/code-review/references/output.md +200 -0
- package/skills/code-review/references/reviewers.md +719 -0
- package/skills/code-review/references/rq.md +357 -0
- package/skills/code-review/references/rs.md +30 -0
- package/skills/code-security/SKILL.md +183 -0
- package/skills/code-security/references/owasp-top-10.md +129 -0
- package/skills/code-security/references/security-tools.md +102 -0
- package/skills/code-security/references/vulnerability-patterns.md +129 -0
- package/skills/code-stacked-commit/SKILL.md +155 -0
- package/skills/code-subagents/SKILL.md +184 -0
- package/skills/code-subagents/references/code-quality-reviewer-prompt.md +48 -0
- package/skills/code-subagents/references/implementor-prompt.md +79 -0
- package/skills/code-subagents/references/spec-reviewer-prompt.md +62 -0
- package/skills/oracle-architect/SKILL.md +246 -0
- package/skills/oracle-architect/references/api-design.md +345 -0
- package/skills/oracle-architect/references/data-modeling.md +318 -0
- package/skills/oracle-architect/references/ddd-patterns.md +247 -0
- package/skills/oracle-challenge/SKILL.md +126 -0
- package/skills/oracle-testing/SKILL.md +237 -0
- package/skills/oracle-testing/references/anti-patterns.md +618 -0
- package/skills/oracle-testing/references/boundaries.md +579 -0
- package/skills/oracle-testing/references/core-testing.md +691 -0
- package/skills/oracle-testing/references/edge-testing.md +794 -0
- package/skills/oracle-testing/references/stub-driven-tdd.md +322 -0
- package/skills/oracle-thinkdeep/SKILL.md +164 -0
- package/skills/python-architecture/SKILL.md +148 -0
- package/skills/python-architecture/references/data-modeling.md +558 -0
- package/skills/python-architecture/references/ddd.md +569 -0
- package/skills/python-architecture/references/functional-core.md +337 -0
- package/skills/python-build-tools/SKILL.md +153 -0
- package/skills/python-build-tools/references/basedpyright.md +321 -0
- package/skills/python-build-tools/references/ruff.md +225 -0
- package/skills/python-build-tools/references/uv.md +257 -0
- package/skills/python-fastapi/SKILL.md +184 -0
- package/skills/python-fastapi/references/api-design.md +563 -0
- package/skills/python-fastapi/references/dependencies.md +479 -0
- package/skills/python-fastapi/references/middleware.md +475 -0
- package/skills/python-fastapi/references/validation.md +497 -0
- package/skills/python-modern-python/SKILL.md +201 -0
- package/skills/python-modern-python/references/async.md +76 -0
- package/skills/python-modern-python/references/pattern-matching.md +89 -0
- package/skills/python-modern-python/references/typing.md +96 -0
- package/skills/python-monorepo/SKILL.md +146 -0
- package/skills/python-monorepo/references/docker.md +515 -0
- package/skills/python-monorepo/references/namespace-packages.md +426 -0
- package/skills/python-monorepo/references/workspace-config.md +341 -0
- package/skills/python-sqlalchemy/SKILL.md +119 -0
- package/skills/python-sqlalchemy/references/async.md +51 -0
- package/skills/python-sqlalchemy/references/models.md +67 -0
- package/skills/python-sqlalchemy/references/queries.md +57 -0
- package/skills/python-temporal/SKILL.md +128 -0
- package/skills/python-temporal/references/patterns.md +87 -0
- package/skills/python-temporal/references/testing.md +54 -0
- package/skills/python-testing/SKILL.md +161 -0
- package/skills/python-testing/references/boundaries.md +449 -0
- package/skills/python-testing/references/mocking.md +449 -0
- package/skills/python-testing/references/pytest.md +524 -0
- package/skills/spec-brainstorm/SKILL.md +325 -0
- package/skills/spec-finish/SKILL.md +159 -0
- package/skills/spec-implement/SKILL.md +296 -0
- package/skills/spec-orchestrator/SKILL.md +156 -0
- package/skills/spec-plan/SKILL.md +248 -0
- package/skills/typescript-api-design/SKILL.md +396 -0
- package/skills/typescript-api-design/references/error-responses.md +469 -0
- package/skills/typescript-build-tools/SKILL.md +447 -0
- package/skills/typescript-build-tools/references/biome.md +436 -0
- package/skills/typescript-build-tools/references/bun.md +432 -0
- package/skills/typescript-build-tools/references/turborepo.md +426 -0
- package/skills/typescript-build-tools/references/vitest.md +518 -0
- package/skills/typescript-drizzle-orm/SKILL.md +398 -0
- package/skills/typescript-drizzle-orm/references/cloudflare.md +392 -0
- package/skills/typescript-drizzle-orm/references/entity-pattern.md +412 -0
- package/skills/typescript-drizzle-orm/references/postgresql.md +191 -0
- package/skills/typescript-drizzle-orm/references/repository-pattern.md +479 -0
- package/skills/typescript-drizzle-orm/references/sqlite.md +291 -0
- package/skills/typescript-dynamodb-toolbox/SKILL.md +370 -0
- package/skills/typescript-dynamodb-toolbox/references/entity-layer.md +574 -0
- package/skills/typescript-dynamodb-toolbox/references/error-handling.md +495 -0
- package/skills/typescript-dynamodb-toolbox/references/modeling.md +332 -0
- package/skills/typescript-dynamodb-toolbox/references/repository-layer.md +631 -0
- package/skills/typescript-dynamodb-toolbox/references/testing.md +718 -0
- package/skills/typescript-dynamodb-toolbox/references/transactions.md +423 -0
- package/skills/typescript-effect-ts/SKILL.md +341 -0
- package/skills/typescript-effect-ts/references/core.md +412 -0
- package/skills/typescript-effect-ts/references/error-handling.md +468 -0
- package/skills/typescript-effect-ts/references/resources.md +476 -0
- package/skills/typescript-effect-ts/references/schema.md +536 -0
- package/skills/typescript-effect-ts/references/services.md +461 -0
- package/skills/typescript-fastify/SKILL.md +405 -0
- package/skills/typescript-fastify/references/plugins.md +329 -0
- package/skills/typescript-fastify/references/typeid.md +315 -0
- package/skills/typescript-functional-patterns/SKILL.md +402 -0
- package/skills/typescript-functional-patterns/references/adts.md +497 -0
- package/skills/typescript-functional-patterns/references/branded-types.md +542 -0
- package/skills/typescript-functional-patterns/references/migration-guide.md +695 -0
- package/skills/typescript-functional-patterns/references/option-result.md +585 -0
- package/skills/typescript-testing/SKILL.md +353 -0
- package/skills/typescript-testing/references/mocking.md +675 -0
- package/skills/typescript-testing/references/msw.md +852 -0
- package/skills/typescript-testing/references/snapshot-testing.md +774 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-debug
|
|
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.
|
|
8
|
+
user-invocable: true
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Code Debug
|
|
12
|
+
|
|
13
|
+
Systematic debugging workflow to find and fix bugs efficiently. Never guess — always
|
|
14
|
+
narrow down the problem through systematic elimination.
|
|
15
|
+
|
|
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]."
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### Step 3: Form Hypothesis
|
|
69
|
+
|
|
70
|
+
Make a testable guess about the root cause.
|
|
71
|
+
|
|
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
|
|
76
|
+
|
|
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?
|
|
82
|
+
|
|
83
|
+
**Output:** "I hypothesize that [root cause] because [evidence]."
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
### Step 4: Fix
|
|
88
|
+
|
|
89
|
+
Implement the fix based on your hypothesis.
|
|
90
|
+
|
|
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
|
|
96
|
+
|
|
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
|
|
102
|
+
|
|
103
|
+
**Output:** "Fix applied: [brief description]."
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### Step 5: Verify
|
|
108
|
+
|
|
109
|
+
Confirm the fix works and doesn't break anything.
|
|
110
|
+
|
|
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
|
|
116
|
+
|
|
117
|
+
**Output:** "Fix verified. Tests passing. Regression test added."
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Debugging Techniques
|
|
122
|
+
|
|
123
|
+
### Print Debugging
|
|
124
|
+
|
|
125
|
+
Quick and dirty, but sometimes the fastest way.
|
|
126
|
+
|
|
127
|
+
**When to use:**
|
|
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
|
|
139
|
+
|
|
140
|
+
More powerful than print debugging.
|
|
141
|
+
|
|
142
|
+
**When to use:**
|
|
143
|
+
- Complex state to inspect
|
|
144
|
+
- Stepping through logic
|
|
145
|
+
- Evaluating expressions in context
|
|
146
|
+
|
|
147
|
+
**See references/language-tools.md for language-specific debugger commands.**
|
|
148
|
+
|
|
149
|
+
### Logging
|
|
150
|
+
|
|
151
|
+
Better than print for production issues.
|
|
152
|
+
|
|
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
|
|
158
|
+
|
|
159
|
+
**See references/techniques.md for logging patterns.**
|
|
160
|
+
|
|
161
|
+
### Binary Search
|
|
162
|
+
|
|
163
|
+
Halving the search space.
|
|
164
|
+
|
|
165
|
+
**Strategies:**
|
|
166
|
+
- Comment out code blocks
|
|
167
|
+
- Test with half the data
|
|
168
|
+
- Compare working vs broken configurations
|
|
169
|
+
- Git bisect for regressions
|
|
170
|
+
|
|
171
|
+
### Rubber Ducking
|
|
172
|
+
|
|
173
|
+
Explain the problem out loud (or to a rubber duck).
|
|
174
|
+
|
|
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
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Common Bug Patterns
|
|
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
|
|
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
|
+
```
|
|
205
|
+
|
|
206
|
+
### Race Conditions
|
|
207
|
+
|
|
208
|
+
**Symptoms:** Intermittent failures, flaky tests
|
|
209
|
+
|
|
210
|
+
**Debug approach:**
|
|
211
|
+
1. Identify async operations
|
|
212
|
+
2. Find timing dependencies
|
|
213
|
+
3. Add delays or force ordering
|
|
214
|
+
|
|
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
|
|
228
|
+
|
|
229
|
+
**Fix patterns:**
|
|
230
|
+
- Fix the condition
|
|
231
|
+
- Correct the calculation
|
|
232
|
+
- Update the state correctly
|
|
233
|
+
|
|
234
|
+
### Performance Issues
|
|
235
|
+
|
|
236
|
+
**Symptoms:** Slow, memory leaks, timeouts
|
|
237
|
+
|
|
238
|
+
**Debug approach:**
|
|
239
|
+
1. Measure first (don't guess)
|
|
240
|
+
2. Identify hot paths
|
|
241
|
+
3. Optimize the bottleneck
|
|
242
|
+
|
|
243
|
+
**See code-perf skill for detailed performance debugging.**
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Skill Loading
|
|
248
|
+
|
|
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
|
+
---
|
|
256
|
+
|
|
257
|
+
## Output Format
|
|
258
|
+
|
|
259
|
+
After each debugging session, summarize:
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
## Debug Summary
|
|
263
|
+
|
|
264
|
+
**Problem:** [One sentence]
|
|
265
|
+
**Root Cause:** [What actually was wrong]
|
|
266
|
+
**Fix:** [How you fixed it]
|
|
267
|
+
**Verification:** [Test results]
|
|
268
|
+
**Prevention:** [Regression test added?]
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
This helps future-you understand what happened.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Debugging Tools by Language
|
|
2
|
+
|
|
3
|
+
## Node.js
|
|
4
|
+
|
|
5
|
+
### Node Inspector / Chrome DevTools
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Start with debugging
|
|
9
|
+
node --inspect server.js
|
|
10
|
+
|
|
11
|
+
# Break on first line
|
|
12
|
+
node --inspect-brk server.js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then open chrome://inspect in Chrome.
|
|
16
|
+
|
|
17
|
+
### VS Code Debugging
|
|
18
|
+
|
|
19
|
+
Create .vscode/launch.json:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"type": "node",
|
|
24
|
+
"request": "launch",
|
|
25
|
+
"name": "Debug Server",
|
|
26
|
+
"program": "${workspaceFolder}/server.js",
|
|
27
|
+
"console": "integratedTerminal"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### ndb
|
|
32
|
+
|
|
33
|
+
Better debugging for Node:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install -g ndb
|
|
37
|
+
ndb server.js
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### console.table
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
const users = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}];
|
|
44
|
+
console.table(users);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Python
|
|
50
|
+
|
|
51
|
+
### pdb
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import pdb
|
|
55
|
+
|
|
56
|
+
def calculate():
|
|
57
|
+
x = 10
|
|
58
|
+
pdb.set_trace() # Break here
|
|
59
|
+
y = x * 2
|
|
60
|
+
return y
|
|
61
|
+
|
|
62
|
+
# Commands: n (next), s (step), p x (print), l (list), w (where), c (continue)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### ipdb (better pdb)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install ipdb
|
|
69
|
+
import ipdb; ipdb.set_trace()
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### VS Code
|
|
73
|
+
|
|
74
|
+
Just set breakpoint and press F5.
|
|
75
|
+
|
|
76
|
+
### PyCharm
|
|
77
|
+
|
|
78
|
+
Right-click → Debug.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Go
|
|
83
|
+
|
|
84
|
+
### Delve
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Install
|
|
88
|
+
go install github.com/go-delve/delve/cmd/dlv@latest
|
|
89
|
+
|
|
90
|
+
# Run
|
|
91
|
+
dlv debug main.go
|
|
92
|
+
|
|
93
|
+
# Commands: n (next), s (step), p x (print), bt (backtrace), c (continue)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### VS Code
|
|
97
|
+
|
|
98
|
+
Just set breakpoint and press F5.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Rust
|
|
103
|
+
|
|
104
|
+
### LLDB with VS Code
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"type": "lldb",
|
|
109
|
+
"request": "launch",
|
|
110
|
+
"program": "${workspaceFolder}/target/debug/myapp",
|
|
111
|
+
"args": ["--arg1", "value"]
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Rust Analyzer
|
|
116
|
+
|
|
117
|
+
Hover over variable → "Debug" button.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Browser (JavaScript)
|
|
122
|
+
|
|
123
|
+
### Chrome DevTools
|
|
124
|
+
|
|
125
|
+
1. F12 → Sources tab
|
|
126
|
+
2. Find file
|
|
127
|
+
3. Set breakpoint
|
|
128
|
+
4. Refresh page
|
|
129
|
+
|
|
130
|
+
### Firefox DevTools
|
|
131
|
+
|
|
132
|
+
1. F12 → Debugger tab
|
|
133
|
+
2. Find file
|
|
134
|
+
3. Set breakpoint
|
|
135
|
+
4. Refresh page
|
|
136
|
+
|
|
137
|
+
### VS Code
|
|
138
|
+
|
|
139
|
+
Use "Debug JavaScript" or "Debug Edge" configuration.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Debugging Techniques
|
|
2
|
+
|
|
3
|
+
## Print Debugging
|
|
4
|
+
|
|
5
|
+
### When to Use
|
|
6
|
+
- Quick checks in development
|
|
7
|
+
- When debugger isn't available
|
|
8
|
+
- Understanding flow in unfamiliar code
|
|
9
|
+
- Minimal reproducible cases
|
|
10
|
+
|
|
11
|
+
### Best Practices
|
|
12
|
+
|
|
13
|
+
**Do:**
|
|
14
|
+
- Print at function entry/exit to trace execution
|
|
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))
|
|
18
|
+
|
|
19
|
+
**Don't:**
|
|
20
|
+
- Leave print statements in production code
|
|
21
|
+
- Print sensitive data (passwords, tokens)
|
|
22
|
+
- Over-print (noise obscures signal)
|
|
23
|
+
- Print in tight loops (use breakpoints instead)
|
|
24
|
+
|
|
25
|
+
### Structured Logging
|
|
26
|
+
|
|
27
|
+
Better than console.log for production:
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
const logger = {
|
|
31
|
+
debug: (msg, meta) => console.debug(JSON.stringify({ level: 'debug', msg, ...meta })),
|
|
32
|
+
info: (msg, meta) => console.info(JSON.stringify({ level: 'info', msg, ...meta })),
|
|
33
|
+
warn: (msg, meta) => console.warn(JSON.stringify({ level: 'warn', msg, ...meta })),
|
|
34
|
+
error: (msg, meta) => console.error(JSON.stringify({ level: 'error', msg, ...meta })),
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Console Methods
|
|
39
|
+
|
|
40
|
+
| Method | Use |
|
|
41
|
+
|--------|-----|
|
|
42
|
+
| console.log | General output |
|
|
43
|
+
| console.debug | Debug info |
|
|
44
|
+
| console.info | Informational |
|
|
45
|
+
| console.warn | Warnings |
|
|
46
|
+
| console.error | Errors |
|
|
47
|
+
| console.table | Arrays/objects in table format |
|
|
48
|
+
| console.trace | Stack trace |
|
|
49
|
+
| console.time/timeEnd | Timing |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Binary Search Debugging
|
|
54
|
+
|
|
55
|
+
### Code Binary Search
|
|
56
|
+
|
|
57
|
+
Comment out half the code to find where the bug is.
|
|
58
|
+
|
|
59
|
+
### Git Bisect
|
|
60
|
+
|
|
61
|
+
For regression bugs:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git bisect start
|
|
65
|
+
git bisect bad
|
|
66
|
+
git bisect good v1.2.3
|
|
67
|
+
# Run your test, mark good/bad
|
|
68
|
+
git bisect reset
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Rubber Ducking
|
|
74
|
+
|
|
75
|
+
### The Process
|
|
76
|
+
|
|
77
|
+
1. Describe the problem in detail
|
|
78
|
+
2. Explain expected behavior
|
|
79
|
+
3. Explain actual behavior
|
|
80
|
+
4. Walk through the code line by line
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Logging Strategies
|
|
85
|
+
|
|
86
|
+
### What to Log
|
|
87
|
+
|
|
88
|
+
| Log This | Don't Log This |
|
|
89
|
+
|----------|----------------|
|
|
90
|
+
| Request/response with IDs | Full request bodies |
|
|
91
|
+
| Key decisions in code | Every loop iteration |
|
|
92
|
+
| Error details with context | Stack traces |
|
|
93
|
+
| Performance timing | Large data dumps |
|
|
94
|
+
| User actions | Sensitive data (PII, passwords) |
|
|
95
|
+
|
|
96
|
+
### Context to Include
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
logger.error('Request failed', {
|
|
100
|
+
endpoint: '/api/users',
|
|
101
|
+
method: 'POST',
|
|
102
|
+
statusCode: 500,
|
|
103
|
+
userId: user?.id,
|
|
104
|
+
requestId: req.headers['x-request-id'],
|
|
105
|
+
duration: Date.now() - startTime,
|
|
106
|
+
errorMessage: error.message
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Log Levels
|
|
111
|
+
|
|
112
|
+
| Level | When |
|
|
113
|
+
|-------|------|
|
|
114
|
+
| DEBUG | Detailed debugging info |
|
|
115
|
+
| INFO | Normal operation events |
|
|
116
|
+
| WARN | Something unexpected, but handled |
|
|
117
|
+
| ERROR | Operation failed |
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-docs
|
|
3
|
+
description: >
|
|
4
|
+
Documentation generation for code projects. Use when updating docs, writing README, generating
|
|
5
|
+
API docs, creating changelog, or when the user mentions documentation, docs, readme, api docs,
|
|
6
|
+
or any documentation task.
|
|
7
|
+
user-invocable: true
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Code Docs
|
|
11
|
+
|
|
12
|
+
Documentation generation and maintenance for code projects.
|
|
13
|
+
|
|
14
|
+
## When to Document
|
|
15
|
+
|
|
16
|
+
**Always update docs when:**
|
|
17
|
+
- Adding new features
|
|
18
|
+
- Changing existing behavior
|
|
19
|
+
- Updating configuration
|
|
20
|
+
- Breaking changes
|
|
21
|
+
|
|
22
|
+
**Docs should live:**
|
|
23
|
+
- Near the code (docstrings, comments)
|
|
24
|
+
- In the repo (README, docs folder)
|
|
25
|
+
- Generated (API docs, type docs)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Doc Types
|
|
30
|
+
|
|
31
|
+
### README
|
|
32
|
+
|
|
33
|
+
Project overview, setup, usage. See references/readme-structure.md
|
|
34
|
+
|
|
35
|
+
**Template:**
|
|
36
|
+
```markdown
|
|
37
|
+
# Project Name
|
|
38
|
+
|
|
39
|
+
Brief description (one line).
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
3-5 commands to get running.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Detailed setup steps.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Code examples.
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
Link to full API docs.
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
58
|
+
|
|
59
|
+
How to contribute.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### API Documentation
|
|
65
|
+
|
|
66
|
+
See references/api-docs.md for:
|
|
67
|
+
- TypeDoc (JavaScript/TypeScript)
|
|
68
|
+
- Sphinx (Python)
|
|
69
|
+
- godoc (Go)
|
|
70
|
+
- JSDoc (JavaScript)
|
|
71
|
+
|
|
72
|
+
### Changelog
|
|
73
|
+
|
|
74
|
+
See references/changelog.md for Keep a Changelog format.
|
|
75
|
+
|
|
76
|
+
**Sections:**
|
|
77
|
+
- Added
|
|
78
|
+
- Changed
|
|
79
|
+
- Deprecated
|
|
80
|
+
- Removed
|
|
81
|
+
- Fixed
|
|
82
|
+
- Security
|
|
83
|
+
|
|
84
|
+
### Architecture Docs
|
|
85
|
+
|
|
86
|
+
See references/architecture-docs.md for:
|
|
87
|
+
- ADRs (Architecture Decision Records)
|
|
88
|
+
- Diagrams
|
|
89
|
+
- System overviews
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Generation Commands
|
|
94
|
+
|
|
95
|
+
### TypeScript/JavaScript
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# TypeDoc
|
|
99
|
+
npx typedoc --out docs src/index.ts
|
|
100
|
+
|
|
101
|
+
# JSDoc
|
|
102
|
+
npx jsdoc src/ -d docs/
|
|
103
|
+
|
|
104
|
+
# API Extractor (monorepos)
|
|
105
|
+
npx api-extractor run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Python
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Sphinx
|
|
112
|
+
sphinx-build -b html docs docs/_build
|
|
113
|
+
|
|
114
|
+
# pdoc
|
|
115
|
+
pdoc --output-dir docs src/
|
|
116
|
+
|
|
117
|
+
# mkdocs
|
|
118
|
+
mkdocs serve
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Go
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# godoc
|
|
125
|
+
godoc -http=:6060
|
|
126
|
+
|
|
127
|
+
# swag (OpenAPI from comments)
|
|
128
|
+
swag init -g cmd/server/main.go
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Workflow
|
|
134
|
+
|
|
135
|
+
### 1. Identify what needs docs
|
|
136
|
+
|
|
137
|
+
- New files/features → update relevant doc
|
|
138
|
+
- Breaking change → update CHANGELOG
|
|
139
|
+
- New public API → update API docs
|
|
140
|
+
|
|
141
|
+
### 2. Generate/Update
|
|
142
|
+
|
|
143
|
+
- Run doc generators
|
|
144
|
+
- Update manual docs
|
|
145
|
+
- Verify examples work
|
|
146
|
+
|
|
147
|
+
### 3. Verify
|
|
148
|
+
|
|
149
|
+
- Links work
|
|
150
|
+
- Examples run
|
|
151
|
+
- Build passes
|
|
152
|
+
|
|
153
|
+
### 4. Commit
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
docs: update API documentation
|
|
157
|
+
|
|
158
|
+
Generated via typedoc.
|
|
159
|
+
Added: new /users endpoint
|
|
160
|
+
Changed: authentication section
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Best Practices
|
|
166
|
+
|
|
167
|
+
1. **Write docs in the code** - Docstrings, comments
|
|
168
|
+
2. **Generate where possible** - Don't duplicate
|
|
169
|
+
3. **Keep README minimal** - Link to detailed docs
|
|
170
|
+
4. **Version with code** - Docs in same repo/PR
|
|
171
|
+
5. **Test examples** - Ensure they run
|