@northbridge-security/secureai 0.1.13

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 (50) hide show
  1. package/.claude/README.md +122 -0
  2. package/.claude/commands/architect/clean.md +978 -0
  3. package/.claude/commands/architect/kiss.md +762 -0
  4. package/.claude/commands/architect/review.md +704 -0
  5. package/.claude/commands/catchup.md +90 -0
  6. package/.claude/commands/code.md +115 -0
  7. package/.claude/commands/commit.md +1218 -0
  8. package/.claude/commands/cover.md +1298 -0
  9. package/.claude/commands/fmea.md +275 -0
  10. package/.claude/commands/kaizen.md +312 -0
  11. package/.claude/commands/pr.md +503 -0
  12. package/.claude/commands/todo.md +99 -0
  13. package/.claude/commands/worktree.md +738 -0
  14. package/.claude/commands/wrapup.md +103 -0
  15. package/LICENSE +183 -0
  16. package/README.md +108 -0
  17. package/dist/cli.js +75634 -0
  18. package/docs/agents/devops-reviewer.md +889 -0
  19. package/docs/agents/kiss-simplifier.md +1088 -0
  20. package/docs/agents/typescript.md +8 -0
  21. package/docs/guides/README.md +109 -0
  22. package/docs/guides/agents.clean.arch.md +244 -0
  23. package/docs/guides/agents.clean.arch.ts.md +1314 -0
  24. package/docs/guides/agents.gotask.md +1037 -0
  25. package/docs/guides/agents.markdown.md +1209 -0
  26. package/docs/guides/agents.onepassword.md +285 -0
  27. package/docs/guides/agents.sonar.md +857 -0
  28. package/docs/guides/agents.tdd.md +838 -0
  29. package/docs/guides/agents.tdd.ts.md +1062 -0
  30. package/docs/guides/agents.typesript.md +1389 -0
  31. package/docs/guides/github-mcp.md +1075 -0
  32. package/package.json +130 -0
  33. package/packages/secureai-cli/src/cli.ts +21 -0
  34. package/tasks/README.md +880 -0
  35. package/tasks/aws.yml +64 -0
  36. package/tasks/bash.yml +118 -0
  37. package/tasks/bun.yml +738 -0
  38. package/tasks/claude.yml +183 -0
  39. package/tasks/docker.yml +420 -0
  40. package/tasks/docs.yml +127 -0
  41. package/tasks/git.yml +1336 -0
  42. package/tasks/gotask.yml +132 -0
  43. package/tasks/json.yml +77 -0
  44. package/tasks/markdown.yml +95 -0
  45. package/tasks/onepassword.yml +350 -0
  46. package/tasks/security.yml +102 -0
  47. package/tasks/sonar.yml +437 -0
  48. package/tasks/template.yml +74 -0
  49. package/tasks/vscode.yml +103 -0
  50. package/tasks/yaml.yml +121 -0
@@ -0,0 +1,762 @@
1
+ ---
2
+ description: Analyze code for over-engineering and propose simplifications using KISS principles
3
+ argument-hint: [scope] [--strict] [--apply] [--compare]
4
+ allowed-tools: Task, Read, Write, Bash
5
+ ---
6
+
7
+ # KISS Analysis: $ARGUMENTS
8
+
9
+ **Note**: KISS (Keep It Simple, Stupid) principles and Clean Architecture complement each other. KISS focuses on removing unnecessary complexity and over-engineering, while Clean Architecture ensures proper separation of concerns and testability. Use `/architect:clean` to analyze architecture violations, then `/architect:kiss` to simplify the resulting code. See [Clean Architecture Analysis](./clean.md) for architectural refactoring.
10
+
11
+ ## Phase 0: Parse Arguments
12
+
13
+ Extract from `$ARGUMENTS`:
14
+
15
+ - **Scope**: Optional with smart defaults
16
+ - File path (e.g., `src/utils/auth.ts`) → Analyze specific file
17
+ - Directory path (e.g., `src/`) → Analyze all files in directory
18
+ - Pattern (e.g., `src/**/*.ts`) → Analyze matching files
19
+ - `--diff` or empty → Analyze git-changed files only
20
+ - **--strict**: Fail if complexity thresholds are exceeded
21
+ - **--apply**: Apply suggested changes to worktree (requires review)
22
+ - **--compare**: Compare with previous `.kiss.local.md` report
23
+
24
+ **Smart scope resolution:**
25
+
26
+ ```bash
27
+ # If no scope provided or --diff flag
28
+ if [[ -z "$SCOPE" ]] || [[ "$SCOPE" == "--diff" ]]; then
29
+ MODE="diff"
30
+ SCOPE=$(git diff --name-only origin/main...HEAD 2>/dev/null | grep -E '\.(ts|js|tsx|jsx)$')
31
+ echo "🔍 Analyzing git-changed files only"
32
+ fi
33
+
34
+ # If scope is a single file
35
+ if [[ -f "$SCOPE" ]]; then
36
+ MODE="file"
37
+ echo "📄 Analyzing single file: $SCOPE"
38
+ fi
39
+
40
+ # If scope is a directory
41
+ if [[ -d "$SCOPE" ]]; then
42
+ MODE="directory"
43
+ echo "📁 Analyzing directory: $SCOPE"
44
+ fi
45
+
46
+ # If scope is a pattern
47
+ if [[ "$SCOPE" == *"*"* ]]; then
48
+ MODE="pattern"
49
+ echo "🔎 Analyzing pattern: $SCOPE"
50
+ fi
51
+ ```
52
+
53
+ ## Phase 1: Launch KISS Simplifier Agent
54
+
55
+ Invoke the specialized KISS Simplifier agent (see `docs/agents/kiss-simplifier.md`) to perform analysis.
56
+
57
+ **Agent invocation:**
58
+
59
+ ```typescript
60
+ // Launch agent via Task tool
61
+ await Task({
62
+ subagent_type: "kiss-simplifier",
63
+ description: "Analyze code for over-engineering",
64
+ prompt: `Analyze the following scope for over-engineering and complexity issues:
65
+
66
+ Scope: ${scope}
67
+ Mode: ${mode}
68
+ Strict mode: ${strictMode}
69
+ Apply changes: ${applyChanges}
70
+
71
+ Use KISS principles from detecting-overengineered-code.local.md to identify:
72
+ 1. Dead code and unused exports
73
+ 2. Unnecessary complexity and abstraction
74
+ 3. Architecture violations
75
+ 4. AI-generated patterns (verbose naming, generic comments)
76
+ 5. Outdated patterns (var usage, callback hell, God objects)
77
+
78
+ Create a git worktree for proposed changes at: .worktree/kiss-${timestamp}
79
+
80
+ Report findings with:
81
+ - Issue severity (critical, high, medium, low)
82
+ - Specific code locations
83
+ - Proposed simplifications
84
+ - Worktree diff summary
85
+
86
+ Return findings in structured format for review.`,
87
+ });
88
+ ```
89
+
90
+ **What the agent will do:**
91
+
92
+ 1. Read and understand KISS principles from `detecting-overengineered-code.local.md`
93
+ 2. Run static analysis tools:
94
+ - **knip** for dead code detection
95
+ - **FTA** for complexity metrics
96
+ - **eslint-plugin-sonarjs** for code smells
97
+ - **dependency-cruiser** for architecture issues
98
+ 3. Analyze results against thresholds
99
+ 4. Create git worktree at `.worktree/kiss-${timestamp}`
100
+ 5. Apply proposed simplifications in worktree
101
+ 6. Generate diff and summary
102
+ 7. Report back to Claude Code with structured findings
103
+
104
+ **Agent will NOT:**
105
+
106
+ - Directly modify files in main working tree
107
+ - Commit changes automatically
108
+ - Push changes to remote
109
+ - Delete any code without explicit permission
110
+
111
+ ## Phase 2: Review Agent Findings
112
+
113
+ **Claude Code receives agent report and validates findings:**
114
+
115
+ ### 2.1 Parse Agent Report
116
+
117
+ Extract from agent response:
118
+
119
+ - **Issues found**: List of over-engineering issues with severity
120
+ - **Worktree location**: Path to worktree with proposed changes
121
+ - **Diff summary**: Overview of proposed changes
122
+ - **Metrics**: Complexity scores, dead code count, etc.
123
+
124
+ ### 2.2 Validate Findings Against KISS Principles
125
+
126
+ Claude Code re-reviews the proposed changes using the same KISS principles:
127
+
128
+ **Review checklist:**
129
+
130
+ - [ ] Are simplifications actually simpler? (No over-simplification)
131
+ - [ ] Do changes preserve functionality? (No behavior changes)
132
+ - [ ] Are naming improvements clearer? (Not just shorter)
133
+ - [ ] Does refactoring reduce cognitive complexity? (Measurable improvement)
134
+ - [ ] Are dead code removals safe? (No false positives)
135
+
136
+ **If issues found in agent's recommendations:**
137
+
138
+ ```text
139
+ Agent proposed removing function X, but it's used in tests.
140
+ → Request agent to re-analyze with test file context
141
+
142
+ Agent suggested renaming Y to Z, but Z is less descriptive.
143
+ → Request alternative name that balances brevity and clarity
144
+ ```
145
+
146
+ ### 2.3 Request Refinements (if needed)
147
+
148
+ If Claude Code identifies issues with agent's recommendations:
149
+
150
+ ```typescript
151
+ // Re-invoke agent with feedback
152
+ await Task({
153
+ subagent_type: "kiss-simplifier",
154
+ description: "Refine KISS analysis based on feedback",
155
+ prompt: `Review and refine previous analysis based on feedback:
156
+
157
+ Previous findings: [agent report]
158
+
159
+ Feedback:
160
+ ${feedback}
161
+
162
+ Update worktree with refined changes and report back.`,
163
+ });
164
+ ```
165
+
166
+ Repeat until Claude Code is satisfied with the analysis quality.
167
+
168
+ ## Phase 3: Generate KISS Report
169
+
170
+ **Create `.kiss.local.md` with comprehensive findings:**
171
+
172
+ ````markdown
173
+ # KISS Analysis Report
174
+
175
+ **Generated:** [timestamp ISO]
176
+ **Scope:** [analyzed scope]
177
+ **Mode:** [file | directory | pattern | diff]
178
+ **Worktree:** `.worktree/kiss-[timestamp]`
179
+ **Agent:** kiss-simplifier
180
+ **Reviewed by:** Claude Code
181
+
182
+ ---
183
+
184
+ ## Executive Summary
185
+
186
+ **Total Issues:** [count]
187
+
188
+ - 🔴 Critical: [count] (Blocking complexity)
189
+ - 🟠 High: [count] (Significant over-engineering)
190
+ - 🟡 Medium: [count] (Minor improvements)
191
+ - 🟢 Low: [count] (Nice-to-have)
192
+
193
+ **Potential Impact:**
194
+
195
+ - **Lines removed:** [count]
196
+ - **Complexity reduction:** [score improvement]
197
+ - **Dead code eliminated:** [count] exports/files
198
+
199
+ **Overall Assessment:** [summary]
200
+
201
+ ---
202
+
203
+ ## Detailed Findings
204
+
205
+ ### 🔴 Critical Issues (Must Fix)
206
+
207
+ #### 1. [Issue Title] - [File:Line]
208
+
209
+ **Category:** [Dead Code | Complexity | Architecture | AI Pattern | Legacy]
210
+
211
+ **Severity:** Critical
212
+
213
+ **Current Code:**
214
+
215
+ ```typescript
216
+ [code snippet showing issue]
217
+ ```
218
+
219
+ **Problem:**
220
+ [Explanation of why this is over-engineered]
221
+
222
+ **Proposed Solution:**
223
+
224
+ ```typescript
225
+ [simplified code from worktree]
226
+ ```
227
+
228
+ **Impact:**
229
+
230
+ - Complexity: [before] → [after] ([percentage] reduction)
231
+ - Lines: [before] → [after] ([-X] lines)
232
+
233
+ **Location in worktree:** `.worktree/kiss-[timestamp]/[file-path]`
234
+
235
+ ---
236
+
237
+ [Repeat for each critical issue]
238
+
239
+ ### 🟠 High Priority Issues
240
+
241
+ [Same structure as critical]
242
+
243
+ ### 🟡 Medium Priority Issues
244
+
245
+ [Same structure as critical]
246
+
247
+ ### 🟢 Low Priority Issues
248
+
249
+ [Same structure as critical]
250
+
251
+ ---
252
+
253
+ ## Metrics Summary
254
+
255
+ ### Complexity Analysis (FTA)
256
+
257
+ | File | Before | After | Improvement |
258
+ | ------- | ------- | ------- | ----------- |
259
+ | [file1] | [score] | [score] | [delta]% |
260
+ | [file2] | [score] | [score] | [delta]% |
261
+
262
+ ### Dead Code Detection (knip)
263
+
264
+ - **Unused exports:** [count] found
265
+ - Functions: [count]
266
+ - Types: [count]
267
+ - Classes: [count]
268
+ - **Unused files:** [count] found
269
+ - **Unused dependencies:** [count] found
270
+
271
+ ### Architecture Issues (dependency-cruiser)
272
+
273
+ - **Circular dependencies:** [count]
274
+ - **Layer violations:** [count]
275
+ - **Orphaned modules:** [count]
276
+
277
+ ### Code Smells (eslint-plugin-sonarjs)
278
+
279
+ - **High cognitive complexity:** [count] functions
280
+ - **Duplicate code:** [count] instances
281
+ - **God objects:** [count] files (>500 LOC)
282
+
283
+ ---
284
+
285
+ ## Worktree Changes Overview
286
+
287
+ **Worktree location:** `.worktree/kiss-[timestamp]`
288
+
289
+ **Files modified:** [count]
290
+ **Lines added:** [count]
291
+ **Lines removed:** [count]
292
+ **Net change:** [-X] lines
293
+
294
+ **Diff summary:**
295
+
296
+ ```diff
297
+ [High-level diff showing key changes]
298
+ ```
299
+
300
+ **To review changes:**
301
+
302
+ ```bash
303
+ # View full diff
304
+ git -C .worktree/kiss-[timestamp] diff HEAD
305
+
306
+ # Compare specific file
307
+ git -C .worktree/kiss-[timestamp] diff HEAD -- [file]
308
+
309
+ # Browse worktree
310
+ cd .worktree/kiss-[timestamp]
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Recommendations
316
+
317
+ ### Immediate Actions (Critical Issues)
318
+
319
+ 1. **[Action 1]**
320
+ - Why: [rationale]
321
+ - Impact: [business/technical benefit]
322
+ - Effort: [estimation]
323
+
324
+ 2. **[Action 2]**
325
+ [Same structure]
326
+
327
+ ### Short-term Improvements (High Priority)
328
+
329
+ [Same structure as immediate actions]
330
+
331
+ ### Long-term Enhancements (Medium/Low Priority)
332
+
333
+ [Same structure as immediate actions]
334
+
335
+ ---
336
+
337
+ ## Next Steps
338
+
339
+ You have several options for proceeding with these findings:
340
+
341
+ ### Option 1: Accept Worktree Changes
342
+
343
+ Review and apply changes from the worktree:
344
+
345
+ ```bash
346
+ # Review changes in worktree
347
+ cd .worktree/kiss-[timestamp]
348
+
349
+ # Copy specific files back to main tree
350
+ cp [file] ../../[file]
351
+
352
+ # Or merge all changes
353
+ git -C .worktree/kiss-[timestamp] format-patch HEAD~1
354
+ git am < .worktree/kiss-[timestamp]/0001-*.patch
355
+
356
+ # Clean up worktree when done
357
+ git worktree remove .worktree/kiss-[timestamp]
358
+ ```
359
+
360
+ ### Option 2: Debate and Refine
361
+
362
+ If you disagree with any recommendations:
363
+
364
+ ```text
365
+ /kiss [scope] --compare
366
+
367
+ Review the differences and provide feedback.
368
+ Claude Code will re-invoke the agent with your feedback.
369
+ ```
370
+
371
+ ### Option 3: Convert to Tasks
372
+
373
+ Create Task Master tasks for systematic remediation:
374
+
375
+ ```text
376
+ /task:add "Simplify authentication module per KISS analysis"
377
+ - Reference: .kiss.local.md#auth-complexity
378
+ - Priority: High
379
+ - Complexity: Medium
380
+
381
+ /task:add "Remove dead code identified in utils/"
382
+ - Reference: .kiss.local.md#dead-code-utils
383
+ - Priority: Medium
384
+ - Complexity: Low
385
+ ```
386
+
387
+ ### Option 4: Convert to Bugs
388
+
389
+ For critical issues blocking development:
390
+
391
+ ```text
392
+ /bug "God object UserService exceeds 800 LOC"
393
+ - Reference: .kiss.local.md#god-object-userservice
394
+ - Priority: High
395
+ - Impact: Maintenance burden, testing difficulty
396
+
397
+ /bug "Circular dependency between API and UI layers"
398
+ - Reference: .kiss.local.md#circular-deps
399
+ - Priority: Critical
400
+ - Impact: Build failures, refactoring blocked
401
+ ```
402
+
403
+ ### Option 5: Staged Approach
404
+
405
+ Combine approaches for large refactorings:
406
+
407
+ 1. **Week 1**: Fix critical issues (accept worktree changes)
408
+ 2. **Week 2**: Create tasks for high-priority improvements
409
+ 3. **Week 3**: Address medium-priority issues incrementally
410
+ 4. **Week 4**: Review and document exceptions for low-priority items
411
+
412
+ ---
413
+
414
+ ## Comparison with Previous Report
415
+
416
+ [Only if --compare used]
417
+
418
+ ### Changes Since Last Analysis ([date])
419
+
420
+ **New issues identified:** [count]
421
+ **Issues resolved:** [count]
422
+ **Issues regressed:** [count]
423
+
424
+ ### Metric Trends
425
+
426
+ | Metric | Previous | Current | Trend |
427
+ | --------------- | -------- | ------- | ----- |
428
+ | Avg complexity | [score] | [score] | [↑↓→] |
429
+ | Dead code count | [count] | [count] | [↑↓→] |
430
+ | God objects | [count] | [count] | [↑↓→] |
431
+
432
+ ### Status Changes
433
+
434
+ **Improved:**
435
+
436
+ - [Issue that was fixed]
437
+
438
+ **Regressed:**
439
+
440
+ - [Issue that got worse]
441
+
442
+ **New:**
443
+
444
+ - [Newly identified issue]
445
+
446
+ ---
447
+
448
+ ## Analysis Configuration
449
+
450
+ **Tools used:**
451
+
452
+ - knip v[version] (dead code detection)
453
+ - fta-cli v[version] (complexity analysis)
454
+ - eslint-plugin-sonarjs v[version] (code smells)
455
+ - dependency-cruiser v[version] (architecture)
456
+
457
+ **Thresholds:**
458
+
459
+ - Cyclomatic complexity: >15
460
+ - Cognitive complexity: >20
461
+ - FTA score: <60
462
+ - File size: >500 LOC
463
+
464
+ **Excluded paths:**
465
+
466
+ - `node_modules/**`
467
+ - `dist/**`
468
+ - `**/*.test.ts`
469
+ - `**/*.d.ts`
470
+
471
+ ---
472
+
473
+ ## Agent Performance
474
+
475
+ **Analysis time:** [duration]
476
+ **Files analyzed:** [count]
477
+ **Issues found:** [count]
478
+ **Changes proposed:** [count] files
479
+
480
+ **Agent effectiveness:**
481
+
482
+ - True positives: [count/count] ([percentage]%)
483
+ - False positives: [count] (refined by Claude Code)
484
+ - Suggestions accepted: [count/count] ([percentage]%)
485
+
486
+ ---
487
+
488
+ ## References
489
+
490
+ - **KISS Principles:** `detecting-overengineered-code.local.md`
491
+ - **Agent Documentation:** `docs/agents/kiss-simplifier.md`
492
+ - **Command Documentation:** `docs/commands/architect/kiss.md`
493
+ - **Clean Architecture:** `docs/commands/architect/clean.md` (Complementary architectural analysis)
494
+ - **Worktree Location:** `.worktree/kiss-[timestamp]`
495
+
496
+ ---
497
+
498
+ **Report generated by:** KISS Simplifier Agent (reviewed by Claude Code)
499
+ **Report location:** `.kiss.local.md`
500
+ **Execution time:** [total duration]
501
+ ````
502
+
503
+ ## Phase 4: Present Results to User
504
+
505
+ ### 4.1 Write Report to File
506
+
507
+ ```bash
508
+ # Write report to .kiss.local.md
509
+ cat > .kiss.local.md <<EOF
510
+ [Generated report from Phase 3]
511
+ EOF
512
+ ```
513
+
514
+ ### 4.2 Open in Editor
515
+
516
+ ```bash
517
+ # Open report in VS Code
518
+ code .kiss.local.md
519
+ ```
520
+
521
+ ### 4.3 Console Summary
522
+
523
+ Print concise summary to console:
524
+
525
+ ```text
526
+ 🎯 KISS Analysis Complete
527
+
528
+ Scope: [analyzed scope]
529
+ Issues found: [total count]
530
+ 🔴 Critical: [count]
531
+ 🟠 High: [count]
532
+ 🟡 Medium: [count]
533
+ 🟢 Low: [count]
534
+
535
+ Potential improvements:
536
+ - Remove [count] lines of dead code
537
+ - Reduce complexity by [percentage]%
538
+ - Fix [count] architecture violations
539
+
540
+ Worktree created: .worktree/kiss-[timestamp]
541
+ Report: .kiss.local.md (opened in editor)
542
+
543
+ Next steps:
544
+ 1. Review findings in .kiss.local.md
545
+ 2. Check worktree diff: cd .worktree/kiss-[timestamp] && git diff HEAD
546
+ 3. Choose action:
547
+ - Accept changes (copy from worktree)
548
+ - Debate findings (/kiss --compare)
549
+ - Convert to tasks (/task:add <description>)
550
+ - Convert to bugs (/bug <summary>)
551
+
552
+ Questions?
553
+ - View all changes: git -C .worktree/kiss-[timestamp] diff HEAD
554
+ - Review specific file: git -C .worktree/kiss-[timestamp] show HEAD:[file]
555
+ - Remove worktree: git worktree remove .worktree/kiss-[timestamp]
556
+ ```
557
+
558
+ ### 4.4 Interactive Prompts
559
+
560
+ Ask user for next action:
561
+
562
+ ```text
563
+ What would you like to do next?
564
+
565
+ 1. Review worktree changes in detail
566
+ 2. Accept all worktree changes
567
+ 3. Accept specific files from worktree
568
+ 4. Debate findings and refine
569
+ 5. Convert critical issues to tasks
570
+ 6. Convert critical issues to bugs
571
+ 7. Clean up worktree and exit
572
+
573
+ Enter choice [1-7]:
574
+ ```
575
+
576
+ **Handle user responses:**
577
+
578
+ **Choice 1: Review worktree changes**
579
+
580
+ ```bash
581
+ cd .worktree/kiss-[timestamp]
582
+ git diff HEAD --stat
583
+ git diff HEAD
584
+ ```
585
+
586
+ **Choice 2: Accept all worktree changes**
587
+
588
+ ```bash
589
+ # Confirm with user first
590
+ echo "⚠️ This will overwrite files in your main working tree."
591
+ echo " Worktree: .worktree/kiss-[timestamp]"
592
+ echo " Files affected: [count]"
593
+ read -p "Continue? [y/N] " confirm
594
+
595
+ if [[ "$confirm" == "y" ]]; then
596
+ # Copy files from worktree
597
+ git -C .worktree/kiss-[timestamp] diff --name-only HEAD | while read file; do
598
+ cp ".worktree/kiss-[timestamp]/$file" "$file"
599
+ done
600
+ echo "✓ Changes applied. Review with 'git diff'"
601
+ fi
602
+ ```
603
+
604
+ **Choice 3: Accept specific files**
605
+
606
+ ```bash
607
+ # Show list of changed files
608
+ echo "Select files to apply (space-separated indices):"
609
+ git -C .worktree/kiss-[timestamp] diff --name-only HEAD | nl
610
+ read -p "Files: " selections
611
+
612
+ # Copy selected files
613
+ for idx in $selections; do
614
+ file=$(git -C .worktree/kiss-[timestamp] diff --name-only HEAD | sed -n "${idx}p")
615
+ cp ".worktree/kiss-[timestamp]/$file" "$file"
616
+ echo "✓ Applied: $file"
617
+ done
618
+ ```
619
+
620
+ **Choice 4: Debate findings**
621
+
622
+ ```bash
623
+ echo "Which findings do you disagree with? (Reference by issue number from report)"
624
+ read -p "Issue numbers: " issues
625
+ echo "What are your concerns?"
626
+ read -p "Feedback: " feedback
627
+
628
+ # Re-invoke agent with feedback (Phase 2.3)
629
+ ```
630
+
631
+ **Choice 5: Convert to tasks**
632
+
633
+ ```bash
634
+ echo "Converting critical and high-priority issues to Task Master tasks..."
635
+
636
+ # Parse critical issues from report
637
+ # Create tasks using /task:add for each
638
+
639
+ /task:add "Simplify [module] per KISS analysis" \
640
+ --priority high \
641
+ --reference .kiss.local.md#issue-1
642
+
643
+ echo "✓ Created [count] tasks. View with /task:status"
644
+ ```
645
+
646
+ **Choice 6: Convert to bugs**
647
+
648
+ ```bash
649
+ echo "Converting critical issues to bugs..."
650
+
651
+ # Parse critical issues from report
652
+ # Create bugs using /bug for each
653
+
654
+ /bug "Critical complexity in [file] - [summary]"
655
+ # Reference: .kiss.local.md#issue-1
656
+
657
+ echo "✓ Created [count] bugs. View in .bugs.local.md"
658
+ ```
659
+
660
+ **Choice 7: Clean up and exit**
661
+
662
+ ```bash
663
+ echo "Cleaning up worktree..."
664
+ git worktree remove .worktree/kiss-[timestamp]
665
+ echo "✓ Worktree removed. Report saved to .kiss.local.md"
666
+ ```
667
+
668
+ ## Error Handling
669
+
670
+ **KISS principles file missing:**
671
+
672
+ - Error: "❌ Cannot find detecting-overengineered-code.local.md. This file contains KISS principles for analysis."
673
+ - Exit with status 1
674
+
675
+ **No files in scope:**
676
+
677
+ - Warning: "⚠️ No files found matching scope: [scope]"
678
+ - Exit with status 0
679
+
680
+ **Agent fails to respond:**
681
+
682
+ - Error: "❌ KISS Simplifier agent failed to complete analysis."
683
+ - Show agent error message
684
+ - Exit with status 2
685
+
686
+ **Worktree creation fails:**
687
+
688
+ - Error: "❌ Cannot create git worktree. Ensure git is available and working tree is clean."
689
+ - Suggestion: "Run 'git status' to check for conflicts"
690
+ - Exit with status 3
691
+
692
+ **Static analysis tools missing:**
693
+
694
+ - Warning: "⚠️ Some analysis tools are not installed: [list]"
695
+ - Suggestion: "Install missing tools: bun add -D [tools]"
696
+ - Continue with available tools
697
+
698
+ **Git not available:**
699
+
700
+ - Error: "❌ Git is required for worktree functionality."
701
+ - Exit with status 4
702
+
703
+ **Invalid comparison:**
704
+
705
+ - Warning: "⚠️ --compare flag used but .kiss.local.md not found. Cannot compare."
706
+ - Continue without comparison
707
+
708
+ ## Exit Codes
709
+
710
+ - 0: Analysis completed successfully
711
+ - 1: Missing required files (KISS principles)
712
+ - 2: Agent execution failure
713
+ - 3: Worktree creation failure
714
+ - 4: Git not available
715
+ - 5: User canceled operation
716
+
717
+ ## Quick Reference
718
+
719
+ **Common workflows:**
720
+
721
+ ```bash
722
+ # After seeing complexity warnings
723
+ /kiss src/modules/auth.ts # Analyze specific file
724
+ /kiss src/modules/ # Analyze directory
725
+
726
+ # Before committing
727
+ /kiss # Analyze git-changed files
728
+ /kiss --strict # Fail on threshold violations
729
+
730
+ # Review and refine
731
+ /kiss --compare # Compare with previous analysis
732
+
733
+ # Apply changes
734
+ /kiss --apply # Create worktree and apply changes (still requires review)
735
+ ```
736
+
737
+ **Mode summary:**
738
+
739
+ - File path → Analyze single file
740
+ - Directory path → Analyze all files in directory
741
+ - Pattern → Analyze files matching glob pattern
742
+ - No scope / `--diff` → Analyze git-changed files only
743
+
744
+ **Integration with existing workflows:**
745
+
746
+ ```bash
747
+ # Option 1: Accept changes directly
748
+ /kiss src/
749
+ # Review .kiss.local.md
750
+ # Accept changes from worktree
751
+
752
+ # Option 2: Convert to structured work
753
+ /kiss src/
754
+ # Review findings
755
+ /task:add "Simplify auth module per KISS#1"
756
+ /bug "Critical complexity in UserService"
757
+
758
+ # Option 3: Iterative refinement
759
+ /kiss src/
760
+ # Review and provide feedback
761
+ /kiss src/ --compare # Re-analyze with refinements
762
+ ```