@jwdobeutechsolutions/dobeutech-claude-code-custom 1.0.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/CLAUDE.md +174 -0
- package/CONTRIBUTING.md +191 -0
- package/README.md +345 -0
- package/agents/accessibility-auditor.md +315 -0
- package/agents/api-designer.md +265 -0
- package/agents/architect.md +211 -0
- package/agents/build-error-resolver.md +532 -0
- package/agents/ci-cd-generator.md +318 -0
- package/agents/code-reviewer.md +104 -0
- package/agents/database-migrator.md +258 -0
- package/agents/deployment-manager.md +296 -0
- package/agents/doc-updater.md +452 -0
- package/agents/docker-specialist.md +293 -0
- package/agents/e2e-runner.md +708 -0
- package/agents/fullstack-architect.md +293 -0
- package/agents/infrastructure-engineer.md +297 -0
- package/agents/integration-tester.md +320 -0
- package/agents/performance-tester.md +243 -0
- package/agents/planner.md +119 -0
- package/agents/refactor-cleaner.md +306 -0
- package/agents/security-reviewer.md +545 -0
- package/agents/tdd-guide.md +280 -0
- package/agents/unit-test-generator.md +290 -0
- package/bin/claude-config.js +290 -0
- package/commands/api-design.md +55 -0
- package/commands/audit-accessibility.md +37 -0
- package/commands/audit-performance.md +38 -0
- package/commands/audit-security.md +43 -0
- package/commands/build-fix.md +29 -0
- package/commands/changelog.md +31 -0
- package/commands/code-review.md +40 -0
- package/commands/deploy.md +51 -0
- package/commands/docs-api.md +41 -0
- package/commands/e2e.md +363 -0
- package/commands/plan.md +113 -0
- package/commands/refactor-clean.md +28 -0
- package/commands/tdd.md +326 -0
- package/commands/test-coverage.md +27 -0
- package/commands/update-codemaps.md +17 -0
- package/commands/update-docs.md +31 -0
- package/hooks/hooks.json +121 -0
- package/mcp-configs/mcp-servers.json +163 -0
- package/package.json +53 -0
- package/rules/agents.md +49 -0
- package/rules/coding-style.md +70 -0
- package/rules/git-workflow.md +45 -0
- package/rules/hooks.md +46 -0
- package/rules/patterns.md +55 -0
- package/rules/performance.md +47 -0
- package/rules/security.md +36 -0
- package/rules/testing.md +30 -0
- package/scripts/install.js +254 -0
- package/skills/backend-patterns.md +582 -0
- package/skills/clickhouse-io.md +429 -0
- package/skills/coding-standards.md +520 -0
- package/skills/frontend-patterns.md +631 -0
- package/skills/project-guidelines-example.md +345 -0
- package/skills/security-review/SKILL.md +494 -0
- package/skills/tdd-workflow/SKILL.md +409 -0
package/commands/tdd.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Enforce test-driven development workflow. Scaffold interfaces, generate tests FIRST, then implement minimal code to pass. Ensure 80%+ coverage.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# TDD Command
|
|
6
|
+
|
|
7
|
+
This command invokes the **tdd-guide** agent to enforce test-driven development methodology.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Scaffold Interfaces** - Define types/interfaces first
|
|
12
|
+
2. **Generate Tests First** - Write failing tests (RED)
|
|
13
|
+
3. **Implement Minimal Code** - Write just enough to pass (GREEN)
|
|
14
|
+
4. **Refactor** - Improve code while keeping tests green (REFACTOR)
|
|
15
|
+
5. **Verify Coverage** - Ensure 80%+ test coverage
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
Use `/tdd` when:
|
|
20
|
+
- Implementing new features
|
|
21
|
+
- Adding new functions/components
|
|
22
|
+
- Fixing bugs (write test that reproduces bug first)
|
|
23
|
+
- Refactoring existing code
|
|
24
|
+
- Building critical business logic
|
|
25
|
+
|
|
26
|
+
## How It Works
|
|
27
|
+
|
|
28
|
+
The tdd-guide agent will:
|
|
29
|
+
|
|
30
|
+
1. **Define interfaces** for inputs/outputs
|
|
31
|
+
2. **Write tests that will FAIL** (because code doesn't exist yet)
|
|
32
|
+
3. **Run tests** and verify they fail for the right reason
|
|
33
|
+
4. **Write minimal implementation** to make tests pass
|
|
34
|
+
5. **Run tests** and verify they pass
|
|
35
|
+
6. **Refactor** code while keeping tests green
|
|
36
|
+
7. **Check coverage** and add more tests if below 80%
|
|
37
|
+
|
|
38
|
+
## TDD Cycle
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
RED → GREEN → REFACTOR → REPEAT
|
|
42
|
+
|
|
43
|
+
RED: Write a failing test
|
|
44
|
+
GREEN: Write minimal code to pass
|
|
45
|
+
REFACTOR: Improve code, keep tests passing
|
|
46
|
+
REPEAT: Next feature/scenario
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Example Usage
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
User: /tdd I need a function to calculate market liquidity score
|
|
53
|
+
|
|
54
|
+
Agent (tdd-guide):
|
|
55
|
+
# TDD Session: Market Liquidity Score Calculator
|
|
56
|
+
|
|
57
|
+
## Step 1: Define Interface (SCAFFOLD)
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// lib/liquidity.ts
|
|
61
|
+
export interface MarketData {
|
|
62
|
+
totalVolume: number
|
|
63
|
+
bidAskSpread: number
|
|
64
|
+
activeTraders: number
|
|
65
|
+
lastTradeTime: Date
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function calculateLiquidityScore(market: MarketData): number {
|
|
69
|
+
// TODO: Implementation
|
|
70
|
+
throw new Error('Not implemented')
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Step 2: Write Failing Test (RED)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// lib/liquidity.test.ts
|
|
78
|
+
import { calculateLiquidityScore } from './liquidity'
|
|
79
|
+
|
|
80
|
+
describe('calculateLiquidityScore', () => {
|
|
81
|
+
it('should return high score for liquid market', () => {
|
|
82
|
+
const market = {
|
|
83
|
+
totalVolume: 100000,
|
|
84
|
+
bidAskSpread: 0.01,
|
|
85
|
+
activeTraders: 500,
|
|
86
|
+
lastTradeTime: new Date()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const score = calculateLiquidityScore(market)
|
|
90
|
+
|
|
91
|
+
expect(score).toBeGreaterThan(80)
|
|
92
|
+
expect(score).toBeLessThanOrEqual(100)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should return low score for illiquid market', () => {
|
|
96
|
+
const market = {
|
|
97
|
+
totalVolume: 100,
|
|
98
|
+
bidAskSpread: 0.5,
|
|
99
|
+
activeTraders: 2,
|
|
100
|
+
lastTradeTime: new Date(Date.now() - 86400000) // 1 day ago
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const score = calculateLiquidityScore(market)
|
|
104
|
+
|
|
105
|
+
expect(score).toBeLessThan(30)
|
|
106
|
+
expect(score).toBeGreaterThanOrEqual(0)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('should handle edge case: zero volume', () => {
|
|
110
|
+
const market = {
|
|
111
|
+
totalVolume: 0,
|
|
112
|
+
bidAskSpread: 0,
|
|
113
|
+
activeTraders: 0,
|
|
114
|
+
lastTradeTime: new Date()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const score = calculateLiquidityScore(market)
|
|
118
|
+
|
|
119
|
+
expect(score).toBe(0)
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Step 3: Run Tests - Verify FAIL
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm test lib/liquidity.test.ts
|
|
128
|
+
|
|
129
|
+
FAIL lib/liquidity.test.ts
|
|
130
|
+
✕ should return high score for liquid market (2 ms)
|
|
131
|
+
Error: Not implemented
|
|
132
|
+
|
|
133
|
+
1 test failed, 0 passed
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
✅ Tests fail as expected. Ready to implement.
|
|
137
|
+
|
|
138
|
+
## Step 4: Implement Minimal Code (GREEN)
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// lib/liquidity.ts
|
|
142
|
+
export function calculateLiquidityScore(market: MarketData): number {
|
|
143
|
+
// Handle zero volume edge case
|
|
144
|
+
if (market.totalVolume === 0) {
|
|
145
|
+
return 0
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Calculate component scores (0-100 scale)
|
|
149
|
+
const volumeScore = Math.min(market.totalVolume / 1000, 100)
|
|
150
|
+
const spreadScore = Math.max(100 - (market.bidAskSpread * 1000), 0)
|
|
151
|
+
const traderScore = Math.min(market.activeTraders / 10, 100)
|
|
152
|
+
|
|
153
|
+
// Recent activity bonus
|
|
154
|
+
const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60)
|
|
155
|
+
const recencyScore = Math.max(100 - (hoursSinceLastTrade * 10), 0)
|
|
156
|
+
|
|
157
|
+
// Weighted average
|
|
158
|
+
const score = (
|
|
159
|
+
volumeScore * 0.4 +
|
|
160
|
+
spreadScore * 0.3 +
|
|
161
|
+
traderScore * 0.2 +
|
|
162
|
+
recencyScore * 0.1
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
return Math.min(Math.max(score, 0), 100) // Clamp to 0-100
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Step 5: Run Tests - Verify PASS
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm test lib/liquidity.test.ts
|
|
173
|
+
|
|
174
|
+
PASS lib/liquidity.test.ts
|
|
175
|
+
✓ should return high score for liquid market (3 ms)
|
|
176
|
+
✓ should return low score for illiquid market (2 ms)
|
|
177
|
+
✓ should handle edge case: zero volume (1 ms)
|
|
178
|
+
|
|
179
|
+
3 tests passed
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
✅ All tests passing!
|
|
183
|
+
|
|
184
|
+
## Step 6: Refactor (IMPROVE)
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// lib/liquidity.ts - Refactored with constants and better readability
|
|
188
|
+
const WEIGHTS = {
|
|
189
|
+
VOLUME: 0.4,
|
|
190
|
+
SPREAD: 0.3,
|
|
191
|
+
TRADERS: 0.2,
|
|
192
|
+
RECENCY: 0.1,
|
|
193
|
+
} as const
|
|
194
|
+
|
|
195
|
+
const SCALE_FACTORS = {
|
|
196
|
+
VOLUME: 1000,
|
|
197
|
+
SPREAD: 1000,
|
|
198
|
+
TRADERS: 10,
|
|
199
|
+
RECENCY_PENALTY: 10,
|
|
200
|
+
} as const
|
|
201
|
+
|
|
202
|
+
function clamp(value: number, min: number, max: number): number {
|
|
203
|
+
return Math.min(Math.max(value, min), max)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function calculateLiquidityScore(market: MarketData): number {
|
|
207
|
+
if (market.totalVolume === 0) return 0
|
|
208
|
+
|
|
209
|
+
const volumeScore = Math.min(market.totalVolume / SCALE_FACTORS.VOLUME, 100)
|
|
210
|
+
const spreadScore = clamp(100 - (market.bidAskSpread * SCALE_FACTORS.SPREAD), 0, 100)
|
|
211
|
+
const traderScore = Math.min(market.activeTraders / SCALE_FACTORS.TRADERS, 100)
|
|
212
|
+
|
|
213
|
+
const hoursSinceLastTrade = (Date.now() - market.lastTradeTime.getTime()) / (1000 * 60 * 60)
|
|
214
|
+
const recencyScore = clamp(100 - (hoursSinceLastTrade * SCALE_FACTORS.RECENCY_PENALTY), 0, 100)
|
|
215
|
+
|
|
216
|
+
const weightedScore =
|
|
217
|
+
volumeScore * WEIGHTS.VOLUME +
|
|
218
|
+
spreadScore * WEIGHTS.SPREAD +
|
|
219
|
+
traderScore * WEIGHTS.TRADERS +
|
|
220
|
+
recencyScore * WEIGHTS.RECENCY
|
|
221
|
+
|
|
222
|
+
return clamp(weightedScore, 0, 100)
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Step 7: Verify Tests Still Pass
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm test lib/liquidity.test.ts
|
|
230
|
+
|
|
231
|
+
PASS lib/liquidity.test.ts
|
|
232
|
+
✓ should return high score for liquid market (3 ms)
|
|
233
|
+
✓ should return low score for illiquid market (2 ms)
|
|
234
|
+
✓ should handle edge case: zero volume (1 ms)
|
|
235
|
+
|
|
236
|
+
3 tests passed
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
✅ Refactoring complete, tests still passing!
|
|
240
|
+
|
|
241
|
+
## Step 8: Check Coverage
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npm test -- --coverage lib/liquidity.test.ts
|
|
245
|
+
|
|
246
|
+
File | % Stmts | % Branch | % Funcs | % Lines
|
|
247
|
+
---------------|---------|----------|---------|--------
|
|
248
|
+
liquidity.ts | 100 | 100 | 100 | 100
|
|
249
|
+
|
|
250
|
+
Coverage: 100% ✅ (Target: 80%)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
✅ TDD session complete!
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## TDD Best Practices
|
|
257
|
+
|
|
258
|
+
**DO:**
|
|
259
|
+
- ✅ Write the test FIRST, before any implementation
|
|
260
|
+
- ✅ Run tests and verify they FAIL before implementing
|
|
261
|
+
- ✅ Write minimal code to make tests pass
|
|
262
|
+
- ✅ Refactor only after tests are green
|
|
263
|
+
- ✅ Add edge cases and error scenarios
|
|
264
|
+
- ✅ Aim for 80%+ coverage (100% for critical code)
|
|
265
|
+
|
|
266
|
+
**DON'T:**
|
|
267
|
+
- ❌ Write implementation before tests
|
|
268
|
+
- ❌ Skip running tests after each change
|
|
269
|
+
- ❌ Write too much code at once
|
|
270
|
+
- ❌ Ignore failing tests
|
|
271
|
+
- ❌ Test implementation details (test behavior)
|
|
272
|
+
- ❌ Mock everything (prefer integration tests)
|
|
273
|
+
|
|
274
|
+
## Test Types to Include
|
|
275
|
+
|
|
276
|
+
**Unit Tests** (Function-level):
|
|
277
|
+
- Happy path scenarios
|
|
278
|
+
- Edge cases (empty, null, max values)
|
|
279
|
+
- Error conditions
|
|
280
|
+
- Boundary values
|
|
281
|
+
|
|
282
|
+
**Integration Tests** (Component-level):
|
|
283
|
+
- API endpoints
|
|
284
|
+
- Database operations
|
|
285
|
+
- External service calls
|
|
286
|
+
- React components with hooks
|
|
287
|
+
|
|
288
|
+
**E2E Tests** (use `/e2e` command):
|
|
289
|
+
- Critical user flows
|
|
290
|
+
- Multi-step processes
|
|
291
|
+
- Full stack integration
|
|
292
|
+
|
|
293
|
+
## Coverage Requirements
|
|
294
|
+
|
|
295
|
+
- **80% minimum** for all code
|
|
296
|
+
- **100% required** for:
|
|
297
|
+
- Financial calculations
|
|
298
|
+
- Authentication logic
|
|
299
|
+
- Security-critical code
|
|
300
|
+
- Core business logic
|
|
301
|
+
|
|
302
|
+
## Important Notes
|
|
303
|
+
|
|
304
|
+
**MANDATORY**: Tests must be written BEFORE implementation. The TDD cycle is:
|
|
305
|
+
|
|
306
|
+
1. **RED** - Write failing test
|
|
307
|
+
2. **GREEN** - Implement to pass
|
|
308
|
+
3. **REFACTOR** - Improve code
|
|
309
|
+
|
|
310
|
+
Never skip the RED phase. Never write code before tests.
|
|
311
|
+
|
|
312
|
+
## Integration with Other Commands
|
|
313
|
+
|
|
314
|
+
- Use `/plan` first to understand what to build
|
|
315
|
+
- Use `/tdd` to implement with tests
|
|
316
|
+
- Use `/build-and-fix` if build errors occur
|
|
317
|
+
- Use `/code-review` to review implementation
|
|
318
|
+
- Use `/test-coverage` to verify coverage
|
|
319
|
+
|
|
320
|
+
## Related Agents
|
|
321
|
+
|
|
322
|
+
This command invokes the `tdd-guide` agent located at:
|
|
323
|
+
`~/.claude/agents/tdd-guide.md`
|
|
324
|
+
|
|
325
|
+
And can reference the `tdd-workflow` skill at:
|
|
326
|
+
`~/.claude/skills/tdd-workflow/`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Test Coverage
|
|
2
|
+
|
|
3
|
+
Analyze test coverage and generate missing tests:
|
|
4
|
+
|
|
5
|
+
1. Run tests with coverage: npm test --coverage or pnpm test --coverage
|
|
6
|
+
|
|
7
|
+
2. Analyze coverage report (coverage/coverage-summary.json)
|
|
8
|
+
|
|
9
|
+
3. Identify files below 80% coverage threshold
|
|
10
|
+
|
|
11
|
+
4. For each under-covered file:
|
|
12
|
+
- Analyze untested code paths
|
|
13
|
+
- Generate unit tests for functions
|
|
14
|
+
- Generate integration tests for APIs
|
|
15
|
+
- Generate E2E tests for critical flows
|
|
16
|
+
|
|
17
|
+
5. Verify new tests pass
|
|
18
|
+
|
|
19
|
+
6. Show before/after coverage metrics
|
|
20
|
+
|
|
21
|
+
7. Ensure project reaches 80%+ overall coverage
|
|
22
|
+
|
|
23
|
+
Focus on:
|
|
24
|
+
- Happy path scenarios
|
|
25
|
+
- Error handling
|
|
26
|
+
- Edge cases (null, undefined, empty)
|
|
27
|
+
- Boundary conditions
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Update Codemaps
|
|
2
|
+
|
|
3
|
+
Analyze the codebase structure and update architecture documentation:
|
|
4
|
+
|
|
5
|
+
1. Scan all source files for imports, exports, and dependencies
|
|
6
|
+
2. Generate token-lean codemaps in the following format:
|
|
7
|
+
- codemaps/architecture.md - Overall architecture
|
|
8
|
+
- codemaps/backend.md - Backend structure
|
|
9
|
+
- codemaps/frontend.md - Frontend structure
|
|
10
|
+
- codemaps/data.md - Data models and schemas
|
|
11
|
+
|
|
12
|
+
3. Calculate diff percentage from previous version
|
|
13
|
+
4. If changes > 30%, request user approval before updating
|
|
14
|
+
5. Add freshness timestamp to each codemap
|
|
15
|
+
6. Save reports to .reports/codemap-diff.txt
|
|
16
|
+
|
|
17
|
+
Use TypeScript/Node.js for analysis. Focus on high-level structure, not implementation details.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Update Documentation
|
|
2
|
+
|
|
3
|
+
Sync documentation from source-of-truth:
|
|
4
|
+
|
|
5
|
+
1. Read package.json scripts section
|
|
6
|
+
- Generate scripts reference table
|
|
7
|
+
- Include descriptions from comments
|
|
8
|
+
|
|
9
|
+
2. Read .env.example
|
|
10
|
+
- Extract all environment variables
|
|
11
|
+
- Document purpose and format
|
|
12
|
+
|
|
13
|
+
3. Generate docs/CONTRIB.md with:
|
|
14
|
+
- Development workflow
|
|
15
|
+
- Available scripts
|
|
16
|
+
- Environment setup
|
|
17
|
+
- Testing procedures
|
|
18
|
+
|
|
19
|
+
4. Generate docs/RUNBOOK.md with:
|
|
20
|
+
- Deployment procedures
|
|
21
|
+
- Monitoring and alerts
|
|
22
|
+
- Common issues and fixes
|
|
23
|
+
- Rollback procedures
|
|
24
|
+
|
|
25
|
+
5. Identify obsolete documentation:
|
|
26
|
+
- Find docs not modified in 90+ days
|
|
27
|
+
- List for manual review
|
|
28
|
+
|
|
29
|
+
6. Show diff summary
|
|
30
|
+
|
|
31
|
+
Single source of truth: package.json and .env.example
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"PreToolUse": [
|
|
5
|
+
{
|
|
6
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"(npm run dev|pnpm( run)? dev|yarn dev|bun run dev)\"",
|
|
7
|
+
"hooks": [
|
|
8
|
+
{
|
|
9
|
+
"type": "command",
|
|
10
|
+
"command": "#!/bin/bash\ninput=$(cat)\ncmd=$(echo \"$input\" | jq -r '.tool_input.command // \"\"')\n\n# Block dev servers that aren't run in tmux\necho '[Hook] BLOCKED: Dev server must run in tmux for log access' >&2\necho '[Hook] Use this command instead:' >&2\necho \"[Hook] tmux new-session -d -s dev 'npm run dev'\" >&2\necho '[Hook] Then: tmux attach -t dev' >&2\nexit 1"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"description": "Block dev servers outside tmux - ensures you can access logs"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"(npm (install|test)|pnpm (install|test)|yarn (install|test)|bun (install|test)|cargo build|make|docker|pytest|vitest|playwright)\"",
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "#!/bin/bash\ninput=$(cat)\nif [ -z \"$TMUX\" ]; then\n echo '[Hook] Consider running in tmux for session persistence' >&2\n echo '[Hook] tmux new -s dev | tmux attach -t dev' >&2\nfi\necho \"$input\""
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"description": "Reminder to use tmux for long-running commands"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"git push\"",
|
|
27
|
+
"hooks": [
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "#!/bin/bash\n# Open editor for review before pushing\necho '[Hook] Review changes before push...' >&2\n# Uncomment your preferred editor:\n# zed . 2>/dev/null\n# code . 2>/dev/null\n# cursor . 2>/dev/null\necho '[Hook] Press Enter to continue with push or Ctrl+C to abort...' >&2\nread -r"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"description": "Pause before git push to review changes"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"git commit\"",
|
|
37
|
+
"hooks": [
|
|
38
|
+
{
|
|
39
|
+
"type": "command",
|
|
40
|
+
"command": "#!/bin/bash\n# Pre-commit security scan\ninput=$(cat)\n\nif git rev-parse --git-dir > /dev/null 2>&1; then\n staged_files=$(git diff --cached --name-only 2>/dev/null || true)\n \n if [ -n \"$staged_files\" ]; then\n echo \"[Hook] Running pre-commit security checks...\" >&2\n \n # Check for secrets\n secrets_found=false\n while IFS= read -r file; do\n if [ -f \"$file\" ]; then\n # Check for common secret patterns\n if grep -qiE '(api[_-]?key|secret|password|token|private[_-]?key)\\s*[:=]\\s*[\"\\']?[a-zA-Z0-9]{20,}' \"$file\" 2>/dev/null; then\n echo \"[Hook] WARNING: Potential secret found in $file\" >&2\n secrets_found=true\n fi\n fi\n done <<< \"$staged_files\"\n \n if [ \"$secrets_found\" = true ]; then\n echo \"[Hook] BLOCKED: Potential secrets detected. Review before committing.\" >&2\n exit 1\n fi\n \n # Check dependency vulnerabilities\n if [ -f \"package.json\" ] || [ -f \"package-lock.json\" ]; then\n echo \"[Hook] Checking for dependency vulnerabilities...\" >&2\n if command -v npm >/dev/null 2>&1; then\n npm audit --audit-level=moderate 2>&1 | head -20 >&2 || true\n fi\n fi\n fi\nfi\n\necho \"$input\""
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"description": "Pre-commit security scan and dependency vulnerability check"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"matcher": "tool == \"Write\" && tool_input.file_path matches \"\\\\.(md|txt)$\" && !(tool_input.file_path matches \"README\\\\.md|CLAUDE\\\\.md|AGENTS\\\\.md|CONTRIBUTING\\\\.md\")",
|
|
47
|
+
"hooks": [
|
|
48
|
+
{
|
|
49
|
+
"type": "command",
|
|
50
|
+
"command": "#!/bin/bash\n# Block creation of unnecessary documentation files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [[ \"$file_path\" =~ \\.(md|txt)$ ]] && [[ ! \"$file_path\" =~ (README|CLAUDE|AGENTS|CONTRIBUTING)\\.md$ ]]; then\n echo \"[Hook] BLOCKED: Unnecessary documentation file creation\" >&2\n echo \"[Hook] File: $file_path\" >&2\n echo \"[Hook] Use README.md for documentation instead\" >&2\n exit 1\nfi\n\necho \"$input\""
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"description": "Block creation of random .md files - keeps docs consolidated"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"PostToolUse": [
|
|
57
|
+
{
|
|
58
|
+
"matcher": "tool == \"Bash\"",
|
|
59
|
+
"hooks": [
|
|
60
|
+
{
|
|
61
|
+
"type": "command",
|
|
62
|
+
"command": "#!/bin/bash\n# Auto-detect PR creation and log useful info\ninput=$(cat)\ncmd=$(echo \"$input\" | jq -r '.tool_input.command')\n\nif echo \"$cmd\" | grep -qE 'gh pr create'; then\n output=$(echo \"$input\" | jq -r '.tool_output.output // \"\"')\n pr_url=$(echo \"$output\" | grep -oE 'https://github.com/[^/]+/[^/]+/pull/[0-9]+')\n \n if [ -n \"$pr_url\" ]; then\n echo \"[Hook] PR created: $pr_url\" >&2\n echo \"[Hook] Checking GitHub Actions status...\" >&2\n repo=$(echo \"$pr_url\" | sed -E 's|https://github.com/([^/]+/[^/]+)/pull/[0-9]+|\\1|')\n pr_num=$(echo \"$pr_url\" | sed -E 's|.*/pull/([0-9]+)|\\1|')\n echo \"[Hook] To review PR: gh pr review $pr_num --repo $repo\" >&2\n fi\nfi\n\necho \"$input\""
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"description": "Log PR URL and provide review command after PR creation"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx|js|jsx)$\"",
|
|
69
|
+
"hooks": [
|
|
70
|
+
{
|
|
71
|
+
"type": "command",
|
|
72
|
+
"command": "#!/bin/bash\n# Auto-format with Prettier after editing JS/TS files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [ -n \"$file_path\" ] && [ -f \"$file_path\" ]; then\n if command -v prettier >/dev/null 2>&1; then\n prettier --write \"$file_path\" 2>&1 | head -5 >&2\n fi\nfi\n\necho \"$input\""
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"description": "Auto-format JS/TS files with Prettier after edits"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx)$\"",
|
|
79
|
+
"hooks": [
|
|
80
|
+
{
|
|
81
|
+
"type": "command",
|
|
82
|
+
"command": "#!/bin/bash\n# Run TypeScript check after editing TS files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [ -n \"$file_path\" ] && [ -f \"$file_path\" ]; then\n dir=$(dirname \"$file_path\")\n project_root=\"$dir\"\n while [ \"$project_root\" != \"/\" ] && [ ! -f \"$project_root/package.json\" ]; do\n project_root=$(dirname \"$project_root\")\n done\n \n if [ -f \"$project_root/tsconfig.json\" ]; then\n cd \"$project_root\" && npx tsc --noEmit --pretty false 2>&1 | grep \"$file_path\" | head -10 >&2 || true\n fi\nfi\n\necho \"$input\""
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"description": "TypeScript check after editing .ts/.tsx files"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"matcher": "tool == \"Edit\" && tool_input.file_path matches \"\\\\.(ts|tsx|js|jsx)$\"",
|
|
89
|
+
"hooks": [
|
|
90
|
+
{
|
|
91
|
+
"type": "command",
|
|
92
|
+
"command": "#!/bin/bash\n# Warn about console.log in edited files\ninput=$(cat)\nfile_path=$(echo \"$input\" | jq -r '.tool_input.file_path // \"\"')\n\nif [ -n \"$file_path\" ] && [ -f \"$file_path\" ]; then\n console_logs=$(grep -n \"console\\\\.log\" \"$file_path\" 2>/dev/null || true)\n \n if [ -n \"$console_logs\" ]; then\n echo \"[Hook] WARNING: console.log found in $file_path\" >&2\n echo \"$console_logs\" | head -5 >&2\n echo \"[Hook] Remove console.log before committing\" >&2\n fi\nfi\n\necho \"$input\""
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"description": "Warn about console.log statements after edits"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"matcher": "tool == \"Bash\" && tool_input.command matches \"git commit\"",
|
|
99
|
+
"hooks": [
|
|
100
|
+
{
|
|
101
|
+
"type": "command",
|
|
102
|
+
"command": "#!/bin/bash\n# Post-commit automation and reminders\ninput=$(cat)\n\nif git rev-parse --git-dir > /dev/null 2>&1; then\n commit_hash=$(git rev-parse HEAD 2>/dev/null || true)\n commit_message=$(git log -1 --pretty=%B 2>/dev/null || true)\n \n if [ -n \"$commit_hash\" ]; then\n echo \"[Hook] Commit $commit_hash created\" >&2\n \n # Auto-generate changelog reminder\n if [ -f \"CHANGELOG.md\" ]; then\n echo \"[Hook] Consider updating CHANGELOG.md\" >&2\n fi\n \n # Check if documentation needs updating\n if echo \"$commit_message\" | grep -qiE '(api|endpoint|route|function|class)'; then\n echo \"[Hook] Consider updating API documentation\" >&2\n fi\n fi\nfi\n\necho \"$input\""
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"description": "Post-commit automation and documentation reminders"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"Stop": [
|
|
109
|
+
{
|
|
110
|
+
"matcher": "*",
|
|
111
|
+
"hooks": [
|
|
112
|
+
{
|
|
113
|
+
"type": "command",
|
|
114
|
+
"command": "#!/bin/bash\n# Final check for console.logs in modified files\ninput=$(cat)\n\nif git rev-parse --git-dir > /dev/null 2>&1; then\n modified_files=$(git diff --name-only HEAD 2>/dev/null | grep -E '\\.(ts|tsx|js|jsx)$' || true)\n \n if [ -n \"$modified_files\" ]; then\n has_console=false\n while IFS= read -r file; do\n if [ -f \"$file\" ]; then\n if grep -q \"console\\.log\" \"$file\" 2>/dev/null; then\n echo \"[Hook] WARNING: console.log found in $file\" >&2\n has_console=true\n fi\n fi\n done <<< \"$modified_files\"\n \n if [ \"$has_console\" = true ]; then\n echo \"[Hook] Remove console.log statements before committing\" >&2\n fi\n fi\nfi\n\necho \"$input\""
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"description": "Final audit for console.log in modified files before session ends"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|