devflow-kit 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +47 -13
  3. package/dist/commands/init.d.ts.map +1 -1
  4. package/dist/commands/init.js +72 -31
  5. package/dist/commands/init.js.map +1 -1
  6. package/dist/commands/uninstall.d.ts.map +1 -1
  7. package/dist/commands/uninstall.js +17 -28
  8. package/dist/commands/uninstall.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/claude/CLAUDE.md +76 -8
  11. package/src/claude/agents/devflow/audit-architecture.md +67 -1
  12. package/src/claude/agents/devflow/audit-complexity.md +67 -1
  13. package/src/claude/agents/devflow/audit-database.md +67 -1
  14. package/src/claude/agents/devflow/audit-dependencies.md +67 -1
  15. package/src/claude/agents/devflow/audit-documentation.md +66 -0
  16. package/src/claude/agents/devflow/audit-performance.md +67 -1
  17. package/src/claude/agents/devflow/audit-security.md +67 -1
  18. package/src/claude/agents/devflow/audit-tests.md +67 -1
  19. package/src/claude/agents/devflow/audit-typescript.md +66 -0
  20. package/src/claude/agents/devflow/debug.md +475 -0
  21. package/src/claude/agents/devflow/project-state.md +419 -0
  22. package/src/claude/agents/devflow/release.md +283 -8
  23. package/src/claude/commands/devflow/code-review.md +51 -12
  24. package/src/claude/commands/devflow/debug.md +29 -201
  25. package/src/claude/commands/devflow/devlog.md +211 -172
  26. package/src/claude/commands/devflow/implement.md +507 -0
  27. package/src/claude/skills/devflow/code-smell/SKILL.md +428 -0
  28. package/src/claude/skills/devflow/debug/SKILL.md +119 -0
  29. package/src/claude/skills/devflow/error-handling/SKILL.md +597 -0
  30. package/src/claude/skills/devflow/input-validation/SKILL.md +514 -0
  31. package/src/claude/skills/devflow/pattern-check/SKILL.md +238 -0
  32. package/src/claude/skills/devflow/research/SKILL.md +135 -0
  33. package/src/claude/skills/devflow/test-design/SKILL.md +384 -0
@@ -0,0 +1,428 @@
1
+ ---
2
+ name: code-smell
3
+ description: Automatically detect anti-patterns, fake solutions, and workarounds when implementing functionality. Use when adding new features, reviewing code changes, or when suspicious patterns appear. Enforces honest, production-ready solutions.
4
+ allowed-tools: Read, Grep, Glob
5
+ ---
6
+
7
+ # Code Smell Skill
8
+
9
+ ## Purpose
10
+
11
+ Detect and prevent anti-patterns that indicate fake solutions or workarounds:
12
+ 1. **Hardcoded data** - Simulating functionality instead of implementing
13
+ 2. **Missing labels** - Workarounds without clear documentation
14
+ 3. **Fake solutions** - Code that pretends to work but doesn't
15
+ 4. **Magic values** - Unexplained constants and configuration
16
+
17
+ ## When This Skill Activates
18
+
19
+ Automatically triggers when:
20
+ - New functionality is being implemented
21
+ - Code changes are being made
22
+ - Mock data or test fixtures appear outside tests
23
+ - Comments suggesting temporary solutions
24
+ - Configuration or constants are added
25
+
26
+ ## Critical Anti-Patterns
27
+
28
+ ### 1. Hardcoded Data Detection (FAKE SOLUTIONS)
29
+
30
+ **CRITICAL**: Never hardcode responses to simulate working functionality.
31
+
32
+ ```typescript
33
+ // ❌ VIOLATION: Fake solution pretending to work
34
+ async function getUserProfile(userId: string): Promise<UserProfile> {
35
+ // HACK: Hardcoded response until API is ready
36
+ return {
37
+ id: userId,
38
+ name: "John Doe",
39
+ email: "john@example.com",
40
+ avatar: "https://example.com/default.jpg"
41
+ };
42
+ }
43
+
44
+ // ❌ VIOLATION: Mock data masquerading as real functionality
45
+ async function fetchRecommendations(userId: string): Promise<Product[]> {
46
+ // TODO: Connect to recommendation engine
47
+ return [
48
+ { id: "1", name: "Product 1", price: 99.99 },
49
+ { id: "2", name: "Product 2", price: 149.99 }
50
+ ];
51
+ }
52
+
53
+ // ✅ CORRECT: Honest implementation or explicit mock
54
+ async function getUserProfile(userId: string): Promise<Result<UserProfile, Error>> {
55
+ try {
56
+ const response = await api.get(`/users/${userId}`);
57
+ return { ok: true, value: response.data };
58
+ } catch (error) {
59
+ return { ok: false, error };
60
+ }
61
+ }
62
+
63
+ // ✅ CORRECT: Clearly labeled mock for testing
64
+ // MOCK: For development only, not production-ready
65
+ async function getUserProfileMock(userId: string): Promise<UserProfile> {
66
+ return {
67
+ id: userId,
68
+ name: "Test User",
69
+ email: "test@example.com"
70
+ };
71
+ }
72
+ ```
73
+
74
+ **Detection patterns:**
75
+ - Hardcoded return objects in business functions
76
+ - Static arrays/objects returned from "fetch" functions
77
+ - Functions with only return statements (no actual logic)
78
+ - Comments like "TODO: implement" with fake data below
79
+ - Default values that look like real data
80
+
81
+ ### 2. Missing Label Detection (UNDOCUMENTED WORKAROUNDS)
82
+
83
+ **CRITICAL**: All workarounds, hacks, and temporary solutions MUST be labeled.
84
+
85
+ ```typescript
86
+ // ❌ VIOLATION: Workaround without label
87
+ function processPayment(amount: number): boolean {
88
+ // Skip validation for now
89
+ return true;
90
+ }
91
+
92
+ // ❌ VIOLATION: Temporary fix without documentation
93
+ async function syncData() {
94
+ await sleep(1000); // Wait for previous operation
95
+ await performSync();
96
+ }
97
+
98
+ // ❌ VIOLATION: Hack without explanation
99
+ function getUserPermissions(userId: string): string[] {
100
+ if (userId === "admin") return ["*"]; // Give admin all permissions
101
+ return ["read"];
102
+ }
103
+
104
+ // ✅ CORRECT: Clearly labeled workaround
105
+ function processPayment(amount: number): boolean {
106
+ // TEMPORARY: Validation disabled until payment gateway integration complete
107
+ // TODO: Add amount validation, currency checks, fraud detection
108
+ // Target: Sprint 23 (2025-11-15)
109
+ // Ticket: PAY-456
110
+ return true;
111
+ }
112
+
113
+ // ✅ CORRECT: Documented hack with rationale
114
+ async function syncData() {
115
+ // HACK: Sleep required due to race condition in legacy sync system
116
+ // Root cause: Event system doesn't guarantee order
117
+ // Proper fix: Implement event sequencing (3-week effort)
118
+ // Acceptable: Race condition occurs <0.1% of operations
119
+ await sleep(1000);
120
+ await performSync();
121
+ }
122
+
123
+ // ✅ CORRECT: Explicit exception with justification
124
+ function getUserPermissions(userId: string): string[] {
125
+ // ARCHITECTURE EXCEPTION: Hardcoded admin check
126
+ // Justification: Permission system must work if database is down
127
+ // Security review: Approved 2025-09-01 (ticket SEC-789)
128
+ if (userId === "admin") return ["*"];
129
+ return ["read"];
130
+ }
131
+ ```
132
+
133
+ **Required labels:**
134
+ - `HACK:` - Workaround for specific problem
135
+ - `MOCK:` - Fake data for testing/development
136
+ - `TODO:` - Work that needs to be done
137
+ - `TEMPORARY:` - Short-term solution with deadline
138
+ - `NOT-PRODUCTION:` - Code that should never ship
139
+ - `ARCHITECTURE EXCEPTION:` - Violates pattern with justification
140
+
141
+ **Detection patterns:**
142
+ - Comments without required labels
143
+ - Suspicious code without documentation
144
+ - Empty catch blocks without explanation
145
+ - Early returns without rationale
146
+ - Magic numbers without explanation
147
+
148
+ ### 3. Fake Functionality Detection (DECEPTIVE CODE)
149
+
150
+ **CRITICAL**: Code must actually work or be clearly marked as non-functional.
151
+
152
+ ```typescript
153
+ // ❌ VIOLATION: Pretending to validate but doing nothing
154
+ function validateEmail(email: string): boolean {
155
+ // Just accept anything for now
156
+ return true;
157
+ }
158
+
159
+ // ❌ VIOLATION: Fake error handling
160
+ async function sendEmail(to: string, subject: string, body: string): Promise<void> {
161
+ try {
162
+ // TODO: Implement SMTP
163
+ console.log(`Email sent to ${to}`);
164
+ } catch (error) {
165
+ // Ignore errors
166
+ }
167
+ }
168
+
169
+ // ❌ VIOLATION: Simulated async operation
170
+ async function fetchData(url: string): Promise<any> {
171
+ await new Promise(resolve => setTimeout(resolve, 100)); // Fake loading time
172
+ return { success: true, data: [] }; // Fake response
173
+ }
174
+
175
+ // ✅ CORRECT: Honest unimplemented function
176
+ function validateEmail(email: string): Result<boolean, Error> {
177
+ return {
178
+ ok: false,
179
+ error: new Error('NOT-IMPLEMENTED: Email validation pending regex pattern approval')
180
+ };
181
+ }
182
+
183
+ // ✅ CORRECT: Real implementation or clear mock
184
+ // MOCK: Email service for development (replace before production)
185
+ async function sendEmailMock(to: string, subject: string, body: string): Promise<Result<void, Error>> {
186
+ console.log(`[MOCK EMAIL] To: ${to}, Subject: ${subject}`);
187
+ return { ok: true, value: undefined };
188
+ }
189
+
190
+ // Real implementation
191
+ async function sendEmailReal(to: string, subject: string, body: string): Promise<Result<void, Error>> {
192
+ try {
193
+ await smtpClient.send({ to, subject, body });
194
+ return { ok: true, value: undefined };
195
+ } catch (error) {
196
+ return { ok: false, error: error as Error };
197
+ }
198
+ }
199
+ ```
200
+
201
+ **Detection patterns:**
202
+ - Functions that return `true` with no logic
203
+ - Empty try/catch blocks
204
+ - Console.log masquerading as functionality
205
+ - setTimeout used to simulate async operations
206
+ - Functions with only TODO comments inside
207
+
208
+ ### 4. Magic Value Detection (UNEXPLAINED CONSTANTS)
209
+
210
+ **CRITICAL**: All magic values must be explained with constants or comments.
211
+
212
+ ```typescript
213
+ // ❌ VIOLATION: Magic numbers
214
+ function calculateDiscount(price: number, userLevel: number): number {
215
+ if (userLevel >= 5) {
216
+ return price * 0.15;
217
+ } else if (userLevel >= 3) {
218
+ return price * 0.10;
219
+ }
220
+ return 0;
221
+ }
222
+
223
+ // ❌ VIOLATION: Magic strings
224
+ function getUserRole(userId: string): string {
225
+ const user = getUser(userId);
226
+ if (user.permissions.includes("admin_access")) {
227
+ return "admin";
228
+ }
229
+ return "user";
230
+ }
231
+
232
+ // ❌ VIOLATION: Magic configuration
233
+ setTimeout(() => {
234
+ retryOperation();
235
+ }, 5000);
236
+
237
+ // ✅ CORRECT: Named constants with documentation
238
+ const USER_LEVEL_THRESHOLD = {
239
+ PREMIUM: 5, // Premium tier: $50/month subscribers
240
+ STANDARD: 3, // Standard tier: $20/month subscribers
241
+ FREE: 0 // Free tier
242
+ } as const;
243
+
244
+ const DISCOUNT_RATE = {
245
+ PREMIUM: 0.15, // 15% discount for premium users
246
+ STANDARD: 0.10, // 10% discount for standard users
247
+ NONE: 0
248
+ } as const;
249
+
250
+ function calculateDiscount(price: number, userLevel: number): number {
251
+ if (userLevel >= USER_LEVEL_THRESHOLD.PREMIUM) {
252
+ return price * DISCOUNT_RATE.PREMIUM;
253
+ } else if (userLevel >= USER_LEVEL_THRESHOLD.STANDARD) {
254
+ return price * DISCOUNT_RATE.STANDARD;
255
+ }
256
+ return DISCOUNT_RATE.NONE;
257
+ }
258
+
259
+ // ✅ CORRECT: Explicit role constants
260
+ enum UserRole {
261
+ ADMIN = "admin",
262
+ USER = "user"
263
+ }
264
+
265
+ const PERMISSION_ROLE_MAP = {
266
+ "admin_access": UserRole.ADMIN,
267
+ "user_access": UserRole.USER
268
+ } as const;
269
+
270
+ // ✅ CORRECT: Configuration with rationale
271
+ const RETRY_CONFIG = {
272
+ // Retry after 5 seconds to allow rate limit reset
273
+ // Based on API documentation: 10 requests per minute
274
+ DELAY_MS: 5000,
275
+ MAX_ATTEMPTS: 3
276
+ } as const;
277
+ ```
278
+
279
+ **Detection patterns:**
280
+ - Numeric literals in business logic (except 0, 1, -1)
281
+ - String literals compared in conditionals
282
+ - Unexplained timeouts or delays
283
+ - Array indices without explanation
284
+ - Percentage or ratio calculations without constants
285
+
286
+ ## Code Smell Report Format
287
+
288
+ ```markdown
289
+ 🚨 CODE SMELLS DETECTED
290
+
291
+ ## 🔴 CRITICAL - Fake Solution
292
+ **File**: src/services/user.ts:45
293
+ **Issue**: Hardcoded user data pretending to fetch from API
294
+ **Evidence**:
295
+ ```typescript
296
+ async function getUserProfile(userId: string) {
297
+ return { id: userId, name: "John Doe", email: "john@example.com" };
298
+ }
299
+ ```
300
+ **Problem**: This code pretends to work but returns fake data
301
+ **Impact**: Will fail in production, misleads other developers
302
+ **Action**: Either implement real API call or label as MOCK
303
+
304
+ ## 🔴 CRITICAL - Unlabeled Workaround
305
+ **File**: src/utils/sync.ts:23
306
+ **Issue**: Sleep statement without explanation
307
+ **Evidence**:
308
+ ```typescript
309
+ await sleep(1000);
310
+ await performSync();
311
+ ```
312
+ **Problem**: Workaround without documentation of why it's needed
313
+ **Required**: Add HACK: label explaining race condition
314
+ **Action**: Document the workaround or fix the root cause
315
+
316
+ ## 🔴 CRITICAL - Deceptive Validation
317
+ **File**: src/validation/email.ts:12
318
+ **Issue**: Validation function that doesn't validate
319
+ **Evidence**:
320
+ ```typescript
321
+ function validateEmail(email: string): boolean {
322
+ return true; // Accept anything for now
323
+ }
324
+ ```
325
+ **Problem**: Function name promises validation but does nothing
326
+ **Impact**: Security risk, data quality issues
327
+ **Action**: Implement validation or return NotImplementedError
328
+
329
+ ## 🟡 HIGH - Magic Values
330
+ **File**: src/billing/discount.ts:34
331
+ **Issue**: Unexplained discount percentages
332
+ **Evidence**:
333
+ ```typescript
334
+ if (userLevel >= 5) return price * 0.15;
335
+ ```
336
+ **Problem**: Magic numbers without explanation
337
+ **Action**: Extract to named constants with documentation
338
+
339
+ ## 📊 Summary
340
+ - **Critical**: 8 fake solutions detected
341
+ - **Critical**: 5 unlabeled workarounds
342
+ - **High**: 12 magic values
343
+ - **Files affected**: 9
344
+
345
+ ## 🛑 HONESTY CHECK FAILED
346
+
347
+ This code violates the "NO FAKE SOLUTIONS" principle:
348
+ - Functions pretend to work but return hardcoded data
349
+ - Workarounds exist without clear documentation
350
+ - Magic values indicate rushed implementation
351
+
352
+ ## ✅ Required Actions
353
+
354
+ 1. **Label all workarounds** - Add HACK:/TEMPORARY:/MOCK: labels
355
+ 2. **Remove fake solutions** - Implement real functionality or mark as NOT-PRODUCTION
356
+ 3. **Document magic values** - Extract to named constants
357
+ 4. **Be transparent** - If something doesn't work, say so clearly
358
+
359
+ ## 🎯 Example Fix
360
+
361
+ Before:
362
+ ```typescript
363
+ async function getRecommendations(userId: string) {
364
+ return [{ id: "1", name: "Product 1" }];
365
+ }
366
+ ```
367
+
368
+ After (honest):
369
+ ```typescript
370
+ // MOCK: Recommendations service not yet implemented
371
+ // TODO: Integrate with ML recommendation engine (ticket: REC-123)
372
+ // Target: Sprint 25
373
+ // NOT-PRODUCTION: This will fail in production
374
+ async function getRecommendationsMock(userId: string): Promise<Product[]> {
375
+ return [
376
+ { id: "1", name: "Mock Product 1", price: 99.99 }
377
+ ];
378
+ }
379
+
380
+ // Proper implementation
381
+ async function getRecommendations(userId: string): Promise<Result<Product[], Error>> {
382
+ return {
383
+ ok: false,
384
+ error: new Error('NOT-IMPLEMENTED: Awaiting ML service deployment')
385
+ };
386
+ }
387
+ ```
388
+ ```
389
+
390
+ ## Integration with Quality Gates
391
+
392
+ This skill prevents:
393
+ - Merging fake functionality to main branch
394
+ - Deploying unlabeled workarounds to production
395
+ - Shipping code that pretends to work
396
+ - Accumulating technical debt without documentation
397
+
398
+ ## Red Flags - Immediate Stop
399
+
400
+ Stop immediately if you detect:
401
+ - Multiple fake solutions in same PR
402
+ - Production code with MOCK: labels
403
+ - Security-critical functions returning true without logic
404
+ - Database operations with hardcoded responses
405
+ - API clients returning static data
406
+
407
+ ## Success Criteria
408
+
409
+ Code passes smell check when:
410
+ - ✅ No hardcoded return data in business logic
411
+ - ✅ All workarounds have required labels
412
+ - ✅ All fake/mock code clearly marked
413
+ - ✅ Magic values extracted to named constants
414
+ - ✅ Comments include rationale and timeline
415
+ - ✅ Functions do what their names promise
416
+
417
+ ## Philosophy Enforcement
418
+
419
+ This skill enforces the core principle:
420
+
421
+ **"NO FAKE SOLUTIONS - Never hardcode responses or data to simulate working functionality"**
422
+
423
+ Code must either:
424
+ 1. Work correctly (real implementation)
425
+ 2. Fail honestly (return error explaining what's missing)
426
+ 3. Be clearly labeled (MOCK:, TEMPORARY:, NOT-PRODUCTION:)
427
+
428
+ No middle ground. No deception.
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: debug
3
+ description: Auto-launch systematic debugging when errors, crashes, or failures occur. Use when encountering exceptions, failed tests, build errors, or unexpected behavior that needs investigation.
4
+ allowed-tools: Task
5
+ ---
6
+
7
+ # Debug Skill - Auto-Dispatcher
8
+
9
+ **Purpose**: Detect when systematic debugging is needed and auto-launch the debug agent.
10
+
11
+ ## When to Activate
12
+
13
+ Auto-activates when:
14
+ - Errors or exceptions encountered
15
+ - Tests failing
16
+ - Build/compilation errors
17
+ - Application crashes
18
+ - Unexpected behavior needs investigation
19
+ - User mentions "broken", "not working", "failing"
20
+
21
+ ## Lightweight Assessment
22
+
23
+ ```markdown
24
+ Quick check (don't do heavy analysis):
25
+ 1. Is this a simple typo/syntax error? → Fix inline
26
+ 2. Is this a complex/unclear issue? → Launch debug agent
27
+ 3. Are there multiple potential causes? → Launch debug agent
28
+ ```
29
+
30
+ ## Decision Logic
31
+
32
+ **Fix inline** (simple issues):
33
+ - Syntax errors with clear fix
34
+ - Typos in variable names
35
+ - Missing imports
36
+ - Simple logic errors
37
+
38
+ **Launch debug agent** (complex issues):
39
+ - Unknown root cause
40
+ - Multiple symptoms
41
+ - Intermittent failures
42
+ - Performance degradation
43
+ - System-level issues
44
+ - Requires investigation
45
+
46
+ ## Auto-Launch Debug Agent
47
+
48
+ When debugging is needed:
49
+
50
+ ```
51
+ I've detected [error type] that requires systematic debugging.
52
+
53
+ **Issue**: [brief description]
54
+ **Symptoms**: [what's happening]
55
+
56
+ Launching debug agent for systematic investigation...
57
+ ```
58
+
59
+ Then launch the debug agent using Task tool:
60
+
61
+ ```
62
+ Task(
63
+ subagent_type="debug",
64
+ description="Debug systematic analysis",
65
+ prompt="Systematically debug the following issue: [issue description].
66
+
67
+ Current symptoms: [symptoms]
68
+ Error messages: [if any]
69
+ Context: [relevant context]"
70
+ )
71
+ ```
72
+
73
+ ## Post-Agent Summary
74
+
75
+ After agent completes, summarize key findings:
76
+
77
+ ```markdown
78
+ 🔍 **Debug Session Complete**
79
+
80
+ **Root Cause**: [from agent findings]
81
+ **Fix Applied**: [solution]
82
+ **Prevention**: [how to avoid]
83
+ **Documentation**: `.docs/debug/[session-id].md`
84
+ ```
85
+
86
+ ## Examples
87
+
88
+ **Example 1: Simple - Fix Inline**
89
+ ```
90
+ User: "Getting error: Cannot find module 'fs'"
91
+ Skill: "Missing import. Adding: import fs from 'fs'"
92
+ [Fixes inline, no agent needed]
93
+ ```
94
+
95
+ **Example 2: Complex - Launch Agent**
96
+ ```
97
+ User: "Tests passing locally but failing in CI"
98
+ Skill: "This requires investigation of environment differences.
99
+ Launching debug agent..."
100
+ [Launches debug agent for systematic analysis]
101
+ ```
102
+
103
+ **Example 3: Unclear - Launch Agent**
104
+ ```
105
+ User: "App crashes randomly after 5 minutes"
106
+ Skill: "Intermittent crash requires systematic debugging.
107
+ Launching debug agent to investigate..."
108
+ [Launches debug agent]
109
+ ```
110
+
111
+ ## Key Points
112
+
113
+ - **Lightweight**: Skill does minimal assessment (~20 lines)
114
+ - **Smart dispatch**: Knows when to fix vs investigate
115
+ - **No heavy analysis**: Delegates to debug agent
116
+ - **Autonomous**: Auto-launches without asking
117
+ - **Clean context**: Main session stays focused
118
+
119
+ This keeps the main session clean while ensuring systematic debugging happens when needed.