|
| 1 | +# Spec-Kit Cleanup Extension |
| 2 | + |
| 3 | +Post-implementation quality gate that reviews changes, fixes small issues (scout rule), creates tasks for medium issues, and generates analysis for large issues. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +specify extension add cleanup |
| 9 | +``` |
| 10 | + |
| 11 | +Or install from repository directly: |
| 12 | + |
| 13 | +```bash |
| 14 | +specify extension add --from https://github.com/dsrednicki/spec-kit-cleanup/archive/refs/tags/v1.0.0.zip |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +After completing implementation with `/speckit.implement`, run the cleanup command: |
| 20 | + |
| 21 | +```bash |
| 22 | +/speckit.cleanup |
| 23 | +``` |
| 24 | + |
| 25 | +Or use the full command name: |
| 26 | + |
| 27 | +```bash |
| 28 | +/speckit.cleanup.run |
| 29 | +``` |
| 30 | + |
| 31 | +## What It Does |
| 32 | + |
| 33 | +The cleanup command performs a final quality gate after implementation: |
| 34 | + |
| 35 | +1. **Reviews all implementation changes** - Analyzes files modified during implementation |
| 36 | +2. **Detects issues by severity**: |
| 37 | + - **CRITICAL**: Security vulnerabilities requiring immediate attention (halts execution) |
| 38 | + - **LARGE**: Architecture concerns requiring team discussion |
| 39 | + - **MEDIUM**: Code quality issues requiring follow-up tasks |
| 40 | + - **SMALL**: Mechanical fixes that can be applied immediately |
| 41 | +3. **Applies fixes with user confirmation** - Small issues are fixed following the Scout Rule |
| 42 | +4. **Creates tech debt tasks** - Medium issues become follow-up tasks in tasks.md |
| 43 | +5. **Generates analysis reports** - Large issues get detailed analysis in tech-debt-report.md |
| 44 | + |
| 45 | +## Issue Detection |
| 46 | + |
| 47 | +### Small Issues (Auto-fixable) |
| 48 | + |
| 49 | +| Category | Patterns | |
| 50 | +|----------|----------| |
| 51 | +| Debug statements | `console.log`, `print()`, `debugger`, `breakpoint()`, `pdb.set_trace()` | |
| 52 | +| Dead code | Unused imports, unreachable code after `return`/`throw` | |
| 53 | +| Dev remnants | `localhost` URLs, `TODO` without ticket reference | |
| 54 | + |
| 55 | +### Medium Issues (Task Creation) |
| 56 | + |
| 57 | +- Missing error handling on external calls |
| 58 | +- Code duplication (same logic in 2-3 locations) |
| 59 | +- Missing documentation on public API |
| 60 | +- Disabled tests without explanation |
| 61 | +- Long functions (>50 lines with high complexity) |
| 62 | + |
| 63 | +### Large Issues (Analysis Required) |
| 64 | + |
| 65 | +- Circular dependencies between modules |
| 66 | +- Business logic in wrong layer |
| 67 | +- Performance anti-patterns (N+1 queries, missing pagination) |
| 68 | +- Security design issues (SQL injection patterns, unsanitized HTML) |
| 69 | + |
| 70 | +### Critical Issues (Halt) |
| 71 | + |
| 72 | +- Hardcoded credentials/secrets |
| 73 | +- Disabled authentication checks |
| 74 | + |
| 75 | +## Outputs |
| 76 | + |
| 77 | +| Artifact | Description | |
| 78 | +|----------|-------------| |
| 79 | +| Direct fixes | Small issues fixed in-place (with user confirmation) | |
| 80 | +| tasks.md | Tech Debt Tasks section appended for medium issues | |
| 81 | +| tech-debt-report.md | Detailed analysis for large issues with options | |
| 82 | + |
| 83 | +## Configuration |
| 84 | + |
| 85 | +Copy `config-template.yml` to `cleanup-config.yml` and customize: |
| 86 | + |
| 87 | +```yaml |
| 88 | +severity_thresholds: |
| 89 | + long_function_lines: 50 |
| 90 | + deep_nesting_levels: 4 |
| 91 | + |
| 92 | +auto_fix: |
| 93 | + debug_statements: true |
| 94 | + unused_imports: true |
| 95 | + dead_code: false |
| 96 | +``` |
| 97 | +
|
| 98 | +## Workflow Integration |
| 99 | +
|
| 100 | +The cleanup command integrates with the Spec Kit workflow: |
| 101 | +
|
| 102 | +``` |
| 103 | +/speckit.specify → /speckit.plan → /speckit.tasks → /speckit.implement → /speckit.cleanup |
| 104 | + │ |
| 105 | + ▼ |
| 106 | + /speckit.implement (for tech debt tasks) |
| 107 | +``` |
| 108 | + |
| 109 | +## Operating Principles |
| 110 | + |
| 111 | +- **Scout Rule**: "Always leave the code cleaner than you found it" |
| 112 | +- **Constitution Compliance**: All actions respect project constitution principles |
| 113 | +- **Non-Destructive**: Always confirms before modifying, rolls back on validation failure |
| 114 | +- **Idempotent**: Safe to run multiple times |
| 115 | + |
| 116 | +## Requirements |
| 117 | + |
| 118 | +- Spec Kit >= 0.1.0 |
| 119 | +- Completed implementation (tasks.md with completed tasks) |
| 120 | + |
| 121 | +## License |
| 122 | + |
| 123 | +MIT License - Copyright (c) 2026 Dominik Srednicki |
0 commit comments