@codeharbor/agent-playbook 0.1.0 → 0.1.1
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/package.json +5 -2
- package/skills/api-designer/README.md +36 -0
- package/skills/api-designer/SKILL.md +232 -0
- package/skills/api-designer/references/graphql-patterns.md +12 -0
- package/skills/api-designer/references/rest-patterns.md +17 -0
- package/skills/api-designer/scripts/generate_api.py +87 -0
- package/skills/api-designer/scripts/validate_api.py +48 -0
- package/skills/api-documenter/README.md +41 -0
- package/skills/api-documenter/SKILL.md +209 -0
- package/skills/api-documenter/references/examples/README.md +3 -0
- package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
- package/skills/api-documenter/references/openapi-template.yaml +5 -0
- package/skills/api-documenter/scripts/generate_openapi.py +84 -0
- package/skills/api-documenter/scripts/validate_openapi.py +45 -0
- package/skills/architecting-solutions/README.md +22 -0
- package/skills/architecting-solutions/SKILL.md +459 -0
- package/skills/auto-trigger/README.md +23 -0
- package/skills/auto-trigger/SKILL.md +183 -0
- package/skills/code-reviewer/README.md +59 -0
- package/skills/code-reviewer/SKILL.md +220 -0
- package/skills/code-reviewer/references/checklist.md +80 -0
- package/skills/code-reviewer/references/patterns.md +226 -0
- package/skills/code-reviewer/references/security.md +88 -0
- package/skills/code-reviewer/scripts/review_checklist.py +191 -0
- package/skills/commit-helper/README.md +58 -0
- package/skills/commit-helper/SKILL.md +159 -0
- package/skills/commit-helper/references/conventional-commits.md +68 -0
- package/skills/commit-helper/references/examples.md +125 -0
- package/skills/commit-helper/references/scopes.md +49 -0
- package/skills/commit-helper/scripts/validate_commit.py +70 -0
- package/skills/create-pr/README.md +182 -0
- package/skills/create-pr/SKILL.md +340 -0
- package/skills/debugger/README.md +53 -0
- package/skills/debugger/SKILL.md +239 -0
- package/skills/debugger/references/checklist.md +7 -0
- package/skills/debugger/references/errors.md +6 -0
- package/skills/debugger/references/patterns.md +5 -0
- package/skills/debugger/scripts/debug_report.py +77 -0
- package/skills/deployment-engineer/README.md +40 -0
- package/skills/deployment-engineer/SKILL.md +242 -0
- package/skills/deployment-engineer/references/kubernetes.md +23 -0
- package/skills/deployment-engineer/references/monitoring.md +14 -0
- package/skills/deployment-engineer/references/pipelines.md +12 -0
- package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
- package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
- package/skills/documentation-engineer/README.md +41 -0
- package/skills/documentation-engineer/SKILL.md +164 -0
- package/skills/documentation-engineer/references/api-template.md +22 -0
- package/skills/documentation-engineer/references/readme-template.md +25 -0
- package/skills/documentation-engineer/references/style-guide.md +13 -0
- package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
- package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
- package/skills/figma-designer/README.md +222 -0
- package/skills/figma-designer/SKILL.md +407 -0
- package/skills/figma-designer/references/example-output.md +86 -0
- package/skills/performance-engineer/README.md +42 -0
- package/skills/performance-engineer/SKILL.md +236 -0
- package/skills/performance-engineer/references/checklist.md +6 -0
- package/skills/performance-engineer/references/monitoring.md +5 -0
- package/skills/performance-engineer/references/optimization.md +7 -0
- package/skills/performance-engineer/scripts/perf_report.py +64 -0
- package/skills/performance-engineer/scripts/profile.py +63 -0
- package/skills/planning-with-files/README.md +27 -0
- package/skills/planning-with-files/SKILL.md +103 -0
- package/skills/prd-implementation-precheck/README.md +97 -0
- package/skills/prd-implementation-precheck/SKILL.md +112 -0
- package/skills/prd-planner/README.md +102 -0
- package/skills/prd-planner/SKILL.md +449 -0
- package/skills/prd-planner/references/edge-case-analysis.md +111 -0
- package/skills/qa-expert/README.md +37 -0
- package/skills/qa-expert/SKILL.md +225 -0
- package/skills/qa-expert/references/gates.md +11 -0
- package/skills/qa-expert/references/metrics.md +6 -0
- package/skills/qa-expert/references/strategy.md +11 -0
- package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
- package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
- package/skills/refactoring-specialist/README.md +37 -0
- package/skills/refactoring-specialist/SKILL.md +283 -0
- package/skills/refactoring-specialist/references/checklist.md +6 -0
- package/skills/refactoring-specialist/references/smells.md +6 -0
- package/skills/refactoring-specialist/references/techniques.md +6 -0
- package/skills/security-auditor/README.md +48 -0
- package/skills/security-auditor/SKILL.md +256 -0
- package/skills/security-auditor/references/checklist.md +7 -0
- package/skills/security-auditor/references/owasp.md +12 -0
- package/skills/security-auditor/references/remediation.md +7 -0
- package/skills/security-auditor/scripts/find_secrets.py +58 -0
- package/skills/security-auditor/scripts/security_audit.py +64 -0
- package/skills/self-improving-agent/README.md +136 -0
- package/skills/self-improving-agent/SKILL.md +407 -0
- package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
- package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
- package/skills/self-improving-agent/hooks/session-end.sh +4 -0
- package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
- package/skills/self-improving-agent/references/appendix.md +131 -0
- package/skills/self-improving-agent/templates/correction-template.md +11 -0
- package/skills/self-improving-agent/templates/pattern-template.md +15 -0
- package/skills/self-improving-agent/templates/validation-template.md +14 -0
- package/skills/session-logger/README.md +50 -0
- package/skills/session-logger/SKILL.md +156 -0
- package/skills/skill-router/README.md +155 -0
- package/skills/skill-router/SKILL.md +215 -0
- package/skills/test-automator/README.md +41 -0
- package/skills/test-automator/SKILL.md +202 -0
- package/skills/test-automator/references/best-practices.md +6 -0
- package/skills/test-automator/references/examples/README.md +3 -0
- package/skills/test-automator/references/examples/unit-test-example.md +8 -0
- package/skills/test-automator/references/mocking.md +5 -0
- package/skills/test-automator/scripts/coverage_report.py +59 -0
- package/skills/test-automator/scripts/generate_test.py +66 -0
- package/skills/workflow-orchestrator/README.md +20 -0
- package/skills/workflow-orchestrator/SKILL.md +342 -0
- package/src/cli.js +25 -10
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-pr
|
|
3
|
+
description: Creates pull requests with bilingual documentation updates. Use when user asks to create PR, make a pull request, or submit changes for review. Automatically updates both English and Chinese README files.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, AskUserQuestion
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Create PR
|
|
8
|
+
|
|
9
|
+
A skill for creating pull requests with automatic bilingual documentation updates. This skill ensures that both English and Chinese documentation stay in sync when code changes are submitted.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
This skill activates when you:
|
|
14
|
+
- Ask to create a pull request or PR
|
|
15
|
+
- Say "submit my changes" or "push and create PR"
|
|
16
|
+
- Mention "make a PR" or "open a pull request"
|
|
17
|
+
- Want to submit code for review
|
|
18
|
+
|
|
19
|
+
## PR Creation Workflow
|
|
20
|
+
|
|
21
|
+
### Step 1: Analyze Changes
|
|
22
|
+
|
|
23
|
+
Examine all changes in the current branch:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git status
|
|
27
|
+
git diff
|
|
28
|
+
git log --oneline main..HEAD
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Identify:
|
|
32
|
+
- **Modified files**: What was changed?
|
|
33
|
+
- **New files**: What was added?
|
|
34
|
+
- **Deleted files**: What was removed?
|
|
35
|
+
- **Impact area**: Which skills or features are affected?
|
|
36
|
+
|
|
37
|
+
### Step 2: Determine Documentation Updates
|
|
38
|
+
|
|
39
|
+
### Check for Skill Changes
|
|
40
|
+
|
|
41
|
+
First, detect if any skills were changed:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Check if skills/ directory has changes
|
|
45
|
+
git diff --name-only main..HEAD | grep "^skills/"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Decision Matrix
|
|
49
|
+
|
|
50
|
+
| Change Type | Documentation Action |
|
|
51
|
+
|-------------|---------------------|
|
|
52
|
+
| New skill added | Add to skills table in both EN and CN README |
|
|
53
|
+
| Skill description changed | Update description in skills table |
|
|
54
|
+
| Skill removed | Remove from skills table |
|
|
55
|
+
| Skill hooks changed | Update Auto-Trigger column in skills table |
|
|
56
|
+
| Internal skill logic only | Skip README update |
|
|
57
|
+
| Bug fix with no user impact | Skip README update |
|
|
58
|
+
|
|
59
|
+
### Auto-Trigger Changes Require Update
|
|
60
|
+
|
|
61
|
+
If a skill's `hooks:` front matter was modified, the **Auto-Trigger** column in the Skills Catalog must be updated:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Check if hooks were modified
|
|
65
|
+
git diff main..HEAD -- skills/*/SKILL.md | grep -E "^\+.*hooks:|^\+.*trigger:"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If hooks changed → Update README.md and README.zh-CN.md Auto-Trigger column.
|
|
69
|
+
|
|
70
|
+
### Step 3: Draft Commit Message
|
|
71
|
+
|
|
72
|
+
Use the `commit-helper` format:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
<type>(<scope>): <subject>
|
|
76
|
+
|
|
77
|
+
<body>
|
|
78
|
+
|
|
79
|
+
<footer>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Types:
|
|
83
|
+
- `feat`: New skill or feature
|
|
84
|
+
- `fix`: Bug fix or correction
|
|
85
|
+
- `docs`: Documentation only changes
|
|
86
|
+
- `refactor`: Code refactoring
|
|
87
|
+
- `chore`: Maintenance tasks
|
|
88
|
+
|
|
89
|
+
### Step 4: Create the Pull Request
|
|
90
|
+
|
|
91
|
+
Run the following sequence:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 1. Stage and commit changes
|
|
95
|
+
git add .
|
|
96
|
+
git commit -m "commit message"
|
|
97
|
+
|
|
98
|
+
# 2. Push to remote
|
|
99
|
+
git push -u origin <branch-name>
|
|
100
|
+
|
|
101
|
+
# 3: Create PR using gh CLI
|
|
102
|
+
gh pr create \
|
|
103
|
+
--title "PR title" \
|
|
104
|
+
--body "PR description"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Step 5: Update Documentation (If Required)
|
|
108
|
+
|
|
109
|
+
After creating the PR, update both README files:
|
|
110
|
+
|
|
111
|
+
**README.md** (English):
|
|
112
|
+
- Add new skills to appropriate category table
|
|
113
|
+
- Update project structure if needed
|
|
114
|
+
- Keep language switch link at top
|
|
115
|
+
|
|
116
|
+
**README.zh-CN.md** (Chinese):
|
|
117
|
+
- Mirror all English changes
|
|
118
|
+
- Translate skill descriptions
|
|
119
|
+
- Maintain same structure and formatting
|
|
120
|
+
|
|
121
|
+
### Step 6: Update Changelog (Optional)
|
|
122
|
+
|
|
123
|
+
For significant changes, add to CHANGELOG.md:
|
|
124
|
+
|
|
125
|
+
```markdown
|
|
126
|
+
## [Version] - YYYY-MM-DD
|
|
127
|
+
|
|
128
|
+
### Added
|
|
129
|
+
- New skill: skill-name
|
|
130
|
+
|
|
131
|
+
### Fixed
|
|
132
|
+
- Fixed issue in skill-name
|
|
133
|
+
|
|
134
|
+
### Changed
|
|
135
|
+
- Updated skill-name with new features
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Documentation Update Guidelines
|
|
139
|
+
|
|
140
|
+
### Skills Catalog Update Template
|
|
141
|
+
|
|
142
|
+
When adding or modifying skills, use this format for the Skills Catalog:
|
|
143
|
+
|
|
144
|
+
**English (README.md):**
|
|
145
|
+
```markdown
|
|
146
|
+
### Category Name
|
|
147
|
+
|
|
148
|
+
| Skill | Description | Auto-Trigger |
|
|
149
|
+
|-------|-------------|--------------|
|
|
150
|
+
| **[skill-name](./skills/skill-name/)** | Brief description | Manual / Auto / Background / (keyword: "...") |
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Chinese (README.zh-CN.md):**
|
|
154
|
+
```markdown
|
|
155
|
+
### 类别名称
|
|
156
|
+
|
|
157
|
+
| 技能 | 描述 | 自动触发 |
|
|
158
|
+
|------|------|----------|
|
|
159
|
+
| **[skill-name](./skills/skill-name/)** | 简短描述 | 手动 / 自动 / 后台 / (关键词:"...") |
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Auto-Trigger Column Values
|
|
163
|
+
|
|
164
|
+
| Value | Meaning | Example |
|
|
165
|
+
|-------|---------|---------|
|
|
166
|
+
| `Manual` | User must invoke | Most development skills |
|
|
167
|
+
| `Auto` | Triggers automatically after any skill | session-logger |
|
|
168
|
+
| `Background` | Runs non-blocking after related skill | self-improving-agent |
|
|
169
|
+
| `After skill updates` | Only triggers when skills are modified | create-pr |
|
|
170
|
+
| `(keyword: "...")` | Activates on specific keyword | prd-planner (keyword: "PRD") |
|
|
171
|
+
|
|
172
|
+
### When to Update README
|
|
173
|
+
|
|
174
|
+
**Always update when:**
|
|
175
|
+
- Adding a new skill
|
|
176
|
+
- Removing a skill
|
|
177
|
+
- Changing skill names or descriptions
|
|
178
|
+
- Restructuring the skills directory
|
|
179
|
+
|
|
180
|
+
**Consider updating when:**
|
|
181
|
+
- Adding significant features to existing skills
|
|
182
|
+
- Changing installation instructions
|
|
183
|
+
- Modifying project structure
|
|
184
|
+
|
|
185
|
+
**Skip updating when:**
|
|
186
|
+
- Internal code refactoring with no user impact
|
|
187
|
+
- Minor typo fixes
|
|
188
|
+
- Test file changes
|
|
189
|
+
|
|
190
|
+
### Bilingual Update Format
|
|
191
|
+
|
|
192
|
+
When adding a new skill to the skills table:
|
|
193
|
+
|
|
194
|
+
**English (README.md):**
|
|
195
|
+
```markdown
|
|
196
|
+
| **[skill-name](./skills/skill-name/)** | Brief skill description |
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Chinese (README.zh-CN.md):**
|
|
200
|
+
```markdown
|
|
201
|
+
| **[skill-name](./skills/skill-name/)** | 技能简短描述 |
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Language Switch Link
|
|
205
|
+
|
|
206
|
+
Both README files must have the language switch at the top:
|
|
207
|
+
|
|
208
|
+
**README.md:**
|
|
209
|
+
```markdown
|
|
210
|
+
English | [简体中文](./README.zh-CN.md)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**README.zh-CN.md:**
|
|
214
|
+
```markdown
|
|
215
|
+
[English](./README.md) | 简体中文
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## PR Description Template
|
|
219
|
+
|
|
220
|
+
When creating a PR, use this template:
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
## Summary
|
|
224
|
+
|
|
225
|
+
<Brief description of what this PR does>
|
|
226
|
+
|
|
227
|
+
## Changes
|
|
228
|
+
|
|
229
|
+
- [ ] New skill added
|
|
230
|
+
- [ ] Existing skill modified
|
|
231
|
+
- [ ] Documentation updated
|
|
232
|
+
- [ ] Tests added/updated
|
|
233
|
+
|
|
234
|
+
## Skills Affected
|
|
235
|
+
|
|
236
|
+
- `skill-name`: Description of change
|
|
237
|
+
|
|
238
|
+
## Documentation
|
|
239
|
+
|
|
240
|
+
- [x] README.md updated
|
|
241
|
+
- [x] README.zh-CN.md updated
|
|
242
|
+
- [ ] CHANGELOG.md updated (if applicable)
|
|
243
|
+
|
|
244
|
+
## Test Plan
|
|
245
|
+
|
|
246
|
+
- [ ] Skill tested in Claude Code
|
|
247
|
+
- [ ] Documentation links verified
|
|
248
|
+
- [ ] Bilingual translations checked
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Common Scenarios
|
|
256
|
+
|
|
257
|
+
### Scenario 1: Adding a New Skill
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# 1. Create skill files
|
|
261
|
+
mkdir -p skills/new-skill
|
|
262
|
+
touch skills/new-skill/SKILL.md
|
|
263
|
+
touch skills/new-skill/README.md
|
|
264
|
+
|
|
265
|
+
# 2. Create symlink
|
|
266
|
+
ln -s ~/path/to/agent-playbook/skills/new-skill/SKILL.md ~/.claude/skills/new-skill.md
|
|
267
|
+
|
|
268
|
+
# 3. Update README.md (add to skills table)
|
|
269
|
+
# 4. Update README.zh-CN.md (add to skills table with translation)
|
|
270
|
+
|
|
271
|
+
# 5. Commit and push
|
|
272
|
+
git add skills/new-skill/ README.md README.zh-CN.md
|
|
273
|
+
git commit -m "feat: add new-skill for ..."
|
|
274
|
+
git push -u origin feature/add-new-skill
|
|
275
|
+
|
|
276
|
+
# 6. Create PR
|
|
277
|
+
gh pr create --title "feat: add new-skill" --body "..."
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Scenario 2: Modifying an Existing Skill
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# 1. Make changes to skill
|
|
284
|
+
vim skills/existing-skill/SKILL.md
|
|
285
|
+
|
|
286
|
+
# 2. Check if description changed
|
|
287
|
+
git diff skills/existing-skill/SKILL.md
|
|
288
|
+
|
|
289
|
+
# 3. If description changed, update README files
|
|
290
|
+
# 4. Commit, push, create PR
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Scenario 3: Bug Fix Only
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# 1. Fix the bug
|
|
297
|
+
vim skills/some-skill/SKILL.md
|
|
298
|
+
|
|
299
|
+
# 2. Commit and push (no README update needed)
|
|
300
|
+
git add skills/some-skill/SKILL.md
|
|
301
|
+
git commit -m "fix: correct typo in some-skill"
|
|
302
|
+
git push
|
|
303
|
+
|
|
304
|
+
# 3. Create PR
|
|
305
|
+
gh pr create --title "fix: correct typo in some-skill"
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Verification Checklist
|
|
309
|
+
|
|
310
|
+
Before creating the PR, verify:
|
|
311
|
+
|
|
312
|
+
- [ ] All changes are committed
|
|
313
|
+
- [ ] Branch is pushed to remote
|
|
314
|
+
- [ ] Commit messages follow Conventional Commits
|
|
315
|
+
- [ ] README.md is updated if needed
|
|
316
|
+
- [ ] README.zh-CN.md is updated if needed
|
|
317
|
+
- [ ] Language switch links are present in both READMEs
|
|
318
|
+
- [ ] New skills have symlinks created
|
|
319
|
+
- [ ] PR title is clear and descriptive
|
|
320
|
+
- [ ] PR description includes summary and changes
|
|
321
|
+
|
|
322
|
+
## Quick Reference
|
|
323
|
+
|
|
324
|
+
| Command | Purpose |
|
|
325
|
+
|---------|---------|
|
|
326
|
+
| `git status` | Check current state |
|
|
327
|
+
| `git diff` | See unstaged changes |
|
|
328
|
+
| `git log main..HEAD` | See branch commits |
|
|
329
|
+
| `git add .` | Stage all changes |
|
|
330
|
+
| `git commit -m "msg"` | Commit with message |
|
|
331
|
+
| `git push -u origin branch` | Push to remote |
|
|
332
|
+
| `gh pr create` | Create pull request |
|
|
333
|
+
|
|
334
|
+
## Tips
|
|
335
|
+
|
|
336
|
+
1. **Commit first, PR later**: Always commit changes before creating PR
|
|
337
|
+
2. **Small PRs**: Keep PRs focused on a single change
|
|
338
|
+
3. **Clear titles**: Use Conventional Commits in PR titles
|
|
339
|
+
4. **Bilingual sync**: Always update both README files together
|
|
340
|
+
5. **Test skills**: Verify skills work before submitting PR
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Debugger
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for systematic debugging and issue resolution.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
When encountering an error or bug:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
You: This function is throwing an error
|
|
15
|
+
You: Debug this code
|
|
16
|
+
You: Why isn't this working?
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The skill will:
|
|
20
|
+
1. Analyze the error message
|
|
21
|
+
2. Trace the root cause
|
|
22
|
+
3. Provide debugging steps
|
|
23
|
+
4. Suggest fixes
|
|
24
|
+
|
|
25
|
+
## Debugging Process
|
|
26
|
+
|
|
27
|
+
| Phase | Description |
|
|
28
|
+
|-------|-------------|
|
|
29
|
+
| **Understand** | Reproduce and understand the problem |
|
|
30
|
+
| **Isolate** | Narrow down the source of the issue |
|
|
31
|
+
| **Analyze** | Determine root cause |
|
|
32
|
+
| **Fix** | Implement and verify the solution |
|
|
33
|
+
|
|
34
|
+
## Common Error Types
|
|
35
|
+
|
|
36
|
+
| Error | Cause | Solution |
|
|
37
|
+
|-------|-------|----------|
|
|
38
|
+
| TypeError | Wrong type, null reference | Add null check, verify type |
|
|
39
|
+
| ReferenceError | Variable not defined | Check imports, scope |
|
|
40
|
+
| NetworkError | Connection issues | Check endpoint, CORS |
|
|
41
|
+
| TimeoutError | Request too slow | Optimize query, increase timeout |
|
|
42
|
+
|
|
43
|
+
## Scripts
|
|
44
|
+
|
|
45
|
+
Generate debug report:
|
|
46
|
+
```bash
|
|
47
|
+
python scripts/debug_report.py "<error-message>"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Resources
|
|
51
|
+
|
|
52
|
+
- [Debugging Best Practices](https://google.github.io/eng-practices/debugging/)
|
|
53
|
+
- [Systematic Debugging](https://www.amazon.com/Debugging-Software-Technical-Charles-Schooleary/dp/0132519560)
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: debugger
|
|
3
|
+
description: Advanced debugging specialist for diagnosing and resolving code issues. Use when user encounters bugs, errors, unexpected behavior, or mentions debugging.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Bash, Grep, Glob
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Debugger
|
|
8
|
+
|
|
9
|
+
An advanced debugging specialist that helps diagnose and resolve code issues systematically.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
Activates when you:
|
|
14
|
+
- Report an error or bug
|
|
15
|
+
- Mention "debug this" or "help debug"
|
|
16
|
+
- Describe unexpected behavior
|
|
17
|
+
- Ask why something isn't working
|
|
18
|
+
|
|
19
|
+
## Debugging Process
|
|
20
|
+
|
|
21
|
+
### Phase 1: Understand the Problem
|
|
22
|
+
|
|
23
|
+
1. **Reproduce the issue**
|
|
24
|
+
- What are the exact steps to reproduce?
|
|
25
|
+
- What is the expected behavior?
|
|
26
|
+
- What is the actual behavior?
|
|
27
|
+
- What error messages appear?
|
|
28
|
+
|
|
29
|
+
2. **Gather context**
|
|
30
|
+
```bash
|
|
31
|
+
# Check recent changes
|
|
32
|
+
git log --oneline -10
|
|
33
|
+
|
|
34
|
+
# Check error logs
|
|
35
|
+
tail -f logs/error.log
|
|
36
|
+
|
|
37
|
+
# Check environment
|
|
38
|
+
env | grep -i debug
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Phase 2: Isolate the Issue
|
|
42
|
+
|
|
43
|
+
1. **Locate the error source**
|
|
44
|
+
- Stack trace analysis
|
|
45
|
+
- Error code lookup
|
|
46
|
+
- Log correlation
|
|
47
|
+
|
|
48
|
+
2. **Narrow down scope**
|
|
49
|
+
- Binary search (comment out half)
|
|
50
|
+
- Minimize reproduction case
|
|
51
|
+
- Identify affected components
|
|
52
|
+
|
|
53
|
+
### Phase 3: Analyze the Root Cause
|
|
54
|
+
|
|
55
|
+
#### Common Error Categories
|
|
56
|
+
|
|
57
|
+
| Category | Symptoms | Investigation Steps |
|
|
58
|
+
|----------|----------|---------------------|
|
|
59
|
+
| **Null/Undefined** | "Cannot read X of undefined" | Trace the variable origin |
|
|
60
|
+
| **Type Errors** | "X is not a function" | Check actual vs expected type |
|
|
61
|
+
| **Async Issues** | Race conditions, timing | Check promise handling, async/await |
|
|
62
|
+
| **State Issues** | Stale data, wrong state | Trace state mutations |
|
|
63
|
+
| **Network** | Timeouts, connection refused | Check endpoints, CORS, auth |
|
|
64
|
+
| **Environment** | Works locally, not in prod | Compare env vars, versions |
|
|
65
|
+
| **Memory** | Leaks, OOM | Profile memory usage |
|
|
66
|
+
| **Concurrency** | Deadlocks, race conditions | Check locks, shared state |
|
|
67
|
+
|
|
68
|
+
### Phase 4: Form Hypotheses
|
|
69
|
+
|
|
70
|
+
For each potential cause:
|
|
71
|
+
1. Form a hypothesis
|
|
72
|
+
2. Create a test to validate
|
|
73
|
+
3. Run the test
|
|
74
|
+
4. Confirm or reject
|
|
75
|
+
|
|
76
|
+
### Phase 5: Fix and Verify
|
|
77
|
+
|
|
78
|
+
1. **Implement the fix**
|
|
79
|
+
2. **Add logging if needed**
|
|
80
|
+
3. **Test the fix**
|
|
81
|
+
4. **Add regression test**
|
|
82
|
+
|
|
83
|
+
## Debugging Commands
|
|
84
|
+
|
|
85
|
+
### General Debugging
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Find recently modified files
|
|
89
|
+
find . -type f -mtime -1 -name "*.js" -o -name "*.ts" -o -name "*.py"
|
|
90
|
+
|
|
91
|
+
# Grep for error patterns
|
|
92
|
+
grep -r "ERROR\|FATAL\|Exception" logs/
|
|
93
|
+
|
|
94
|
+
# Search for suspicious patterns
|
|
95
|
+
grep -r "TODO\|FIXME\|XXX" src/
|
|
96
|
+
|
|
97
|
+
# Check for console.log left in code
|
|
98
|
+
grep -r "console\.log\|debugger" src/
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Language-Specific
|
|
102
|
+
|
|
103
|
+
**JavaScript/TypeScript:**
|
|
104
|
+
```bash
|
|
105
|
+
# Run with debug output
|
|
106
|
+
NODE_DEBUG=* node app.js
|
|
107
|
+
|
|
108
|
+
# Check syntax
|
|
109
|
+
node -c file.js
|
|
110
|
+
|
|
111
|
+
# Run tests in debug mode
|
|
112
|
+
npm test -- --inspect-brk
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Python:**
|
|
116
|
+
```bash
|
|
117
|
+
# Run with pdb
|
|
118
|
+
python -m pdb script.py
|
|
119
|
+
|
|
120
|
+
# Check syntax
|
|
121
|
+
python -m py_compile script.py
|
|
122
|
+
|
|
123
|
+
# Verbose mode
|
|
124
|
+
python -v script.py
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Go:**
|
|
128
|
+
```bash
|
|
129
|
+
# Race detection
|
|
130
|
+
go run -race main.go
|
|
131
|
+
|
|
132
|
+
# Debug build
|
|
133
|
+
go build -gcflags="-N -l"
|
|
134
|
+
|
|
135
|
+
# Profile
|
|
136
|
+
go test -cpuprofile=cpu.prof
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Common Debugging Patterns
|
|
140
|
+
|
|
141
|
+
### Pattern 1: Divide and Conquer
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
# When you don't know where the bug is:
|
|
145
|
+
def process():
|
|
146
|
+
step1()
|
|
147
|
+
step2()
|
|
148
|
+
step3()
|
|
149
|
+
step4()
|
|
150
|
+
|
|
151
|
+
# Comment out half:
|
|
152
|
+
def process():
|
|
153
|
+
step1()
|
|
154
|
+
# step2()
|
|
155
|
+
# step3()
|
|
156
|
+
# step4()
|
|
157
|
+
|
|
158
|
+
# If bug disappears, uncomment half of commented:
|
|
159
|
+
def process():
|
|
160
|
+
step1()
|
|
161
|
+
step2()
|
|
162
|
+
# step3()
|
|
163
|
+
# step4()
|
|
164
|
+
|
|
165
|
+
# Continue until you isolate the bug
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Pattern 2: Add Logging
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// Before (mysterious failure):
|
|
172
|
+
async function getUser(id: string) {
|
|
173
|
+
const user = await db.find(id);
|
|
174
|
+
return transform(user);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// After (with logging):
|
|
178
|
+
async function getUser(id: string) {
|
|
179
|
+
console.log('[DEBUG] getUser called with id:', id);
|
|
180
|
+
const user = await db.find(id);
|
|
181
|
+
console.log('[DEBUG] db.find returned:', user);
|
|
182
|
+
const result = transform(user);
|
|
183
|
+
console.log('[DEBUG] transform returned:', result);
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Pattern 3: Minimal Reproduction
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Complex code with bug:
|
|
192
|
+
function processBatch(items, options) {
|
|
193
|
+
// 100 lines of complex logic
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Create minimal reproduction:
|
|
197
|
+
function processBatch(items, options) {
|
|
198
|
+
console.log('Items:', items.length);
|
|
199
|
+
console.log('Options:', options);
|
|
200
|
+
// Test with minimal data
|
|
201
|
+
return processBatch([items[0]], options);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Error Message Analysis
|
|
206
|
+
|
|
207
|
+
### Common Error Messages
|
|
208
|
+
|
|
209
|
+
| Error | Likely Cause | Solution |
|
|
210
|
+
|-------|--------------|----------|
|
|
211
|
+
| `Cannot read property 'X' of undefined` | Accessing property on null/undefined | Add null check, use optional chaining |
|
|
212
|
+
| `X is not a function` | Wrong type, shadowing | Check typeof, verify import |
|
|
213
|
+
| `Unexpected token` | Syntax error | Check line before error, validate syntax |
|
|
214
|
+
| `Module not found` | Import path wrong | Check relative path, verify file exists |
|
|
215
|
+
| `EADDRINUSE` | Port already in use | Kill existing process, use different port |
|
|
216
|
+
| `Connection refused` | Service not running | Start service, check port |
|
|
217
|
+
| `Timeout` | Request too slow | Increase timeout, check network |
|
|
218
|
+
|
|
219
|
+
## Debugging Checklist
|
|
220
|
+
|
|
221
|
+
- [ ] I can reproduce the issue consistently
|
|
222
|
+
- [ ] I have identified the exact error location
|
|
223
|
+
- [ ] I understand the root cause
|
|
224
|
+
- [ ] I have a proposed fix
|
|
225
|
+
- [ ] The fix doesn't break existing functionality
|
|
226
|
+
- [ ] I've added a test to prevent regression
|
|
227
|
+
|
|
228
|
+
## Scripts
|
|
229
|
+
|
|
230
|
+
Generate a debug report:
|
|
231
|
+
```bash
|
|
232
|
+
python scripts/debug_report.py <error-message>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## References
|
|
236
|
+
|
|
237
|
+
- `references/checklist.md` - Debugging checklist
|
|
238
|
+
- `references/patterns.md` - Common debugging patterns
|
|
239
|
+
- `references/errors.md` - Error message reference
|