Code Cleanup
Overview
Performs post-review cosmetic cleanup to make code production-ready. This workflow is now integrated as Phase T-7 of /skill:specs-kit-task-implementation. It can also be invoked manually using --action=cleanup.
Input: docs/specs/[id]/tasks/TASK-XXX.md (reviewed status)
Output: Cleaned code, task marked completed
When to Use
- Use when asked to clean up code, polish, finalize, tidy up, or remove technical debt after review approval.
- Use to prepare code for completion: remove debug logs, dead code, optimize imports, and improve readability.
- Use as the final quality gate in the specification-driven development workflow.
- Not for refactoring logic or fixing bugs — focused solely on cosmetic and hygiene cleanup.
Arguments
| Argument |
Required |
Description |
--task |
Yes |
Path to task file |
--action |
No |
Set to cleanup for manual invocation |
Best Practices
- Clean, not change: Only remove or reorganize — never change functionality
- Preserve behavior: Code must work exactly the same after cleanup
- Use project tools: Discover and run the formatter/linter the project already configures (
package.json scripts, Maven/Gradle plugins, composer scripts, pyproject.toml tooling, .pre-commit-config.yaml)
- Use a checklist: Track progress through all 8 phases
- Stop on failure: If tests fail, stop and report — do not proceed
Instructions
Phase 1: Task Verification
Parse the skill arguments for parameters:
--task (required): Task ID or file path
--spec (optional): Spec folder path (used with task ID)
Support two formats:
- Format 1 (direct path):
--task=docs/specs/001-feature/tasks/TASK-001.md
- Format 2 (spec+task):
--spec=docs/specs/001-feature --task=TASK-001
If Format 2 is used, construct the task file path as: {spec}/tasks/{task}.md
Read the task file. Verify:
- Status is
reviewed, implemented, or completed (an earlier cleanup may
have already stamped completed, which the loop treats as terminal)
- Review report
TASK-XXX--review.md exists and is approved
If not reviewed → stop and tell user to run /skill:specs-kit-task-review first
Extract task ID, title, and provides files
Phase 2: Identify Files to Clean
- Read
TASK-XXX--review.md for files created/modified
- Read task
provides field for file paths
- Verify files exist; build cleanup list
- Categorize: source files, test files, config files
Phase 3: Technical Debt Removal
Search files for temporary/debug artifacts with Grep:
console.log, System.out.println, print(, // DEBUG:, // temp, // hack
- Resolved
TODO/FIXME comments (keep unresolved ones)
Review context for each finding. Remove confirmed debt and document what was removed.
Phase 4: Import Optimization
- Discover and run the project's own import tooling from its configuration (
package.json scripts, Maven/Gradle plugins, composer scripts, pyproject.toml, .pre-commit-config.yaml)
- Manually remove unused imports if no tool is configured
- Document files changed
Phase 5: Code Readability Improvements
- Discover and run the project's own formatter/linter from its configuration (
package.json scripts, Maven/Gradle plugins, composer scripts, pyproject.toml, .pre-commit-config.yaml)
- If no formatter is configured: fix indentation, break long lines (>120), fix spacing
- Remove dead code only if obviously safe
- Document changes
Phase 6: Documentation Verification
- Verify class/file headers and public API docs
- Check remaining TODOs are still valid and have context
- Remove or update outdated comments
- Document documentation changes
Phase 7: Final Verification
- Run linters if available
- Run tests if available
- Verify no logic or signature changes were introduced
- If tests fail → stop and report failures
Phase 8: Task Completion
Update the task status:
- Add a
## Cleanup Summary section to the task file
- Check any remaining boxes in the DoD section
- Inside the loop, hooks update status to
reviewed (the canonical terminal the loop
expects) and stamp reviewed_date + cleanup_date.
- Standalone run (outside the loop): no hook fires, so edit the frontmatter yourself —
set
status: reviewed and stamp reviewed_date + cleanup_date (YYYY-MM-DD).
Only pending, implemented, reviewed, completed are valid values; anything else
(e.g. done) makes the task file fail to load and blocks run/refresh for the whole spec.
Append ## Cleanup Summary to task file with:
- Files cleaned
- Changes made
- Verification checklist (linters, tests, no functionality changes)
Mark all todos complete
Examples
Spring Boot Cleanup
/skill:specs-kit-task-implementation --task="docs/specs/001-user-auth/tasks/TASK-001.md" --action=cleanup
Actions:
- Verify TASK-001 status is
reviewed
- Files:
UserController.java, UserService.java, UserRepository.java
- Remove 5
System.out.println and 2 resolved TODOs
- Run
./mvnw spotless:apply
- Run
./mvnw test -q
- Mark task
reviewed
TypeScript Cleanup
/skill:specs-kit-task-implementation --task="docs/specs/002-dashboard/tasks/TASK-003.md" --action=cleanup
Actions:
- Verify TASK-003 status is
reviewed
- Files:
Dashboard.tsx, useDashboard.ts, Dashboard.test.tsx
- Remove 8
console.log statements
- Run
npm run lint:fix and npm run format
- Run
npm test
- Mark task
reviewed
Constraints and Warnings
- Never change logic or signatures during cleanup
- Stop immediately and report if tests fail
- Verify behavior is unchanged before marking complete
1---2name: specs-kit-code-cleanup3description: Provides final code cleanup after task review approval. Removes debug logs, temporary comments, dead code, optimizes imports, and improves readability. Use when asked to clean up code, polish, finalize, tidy up, remove technical debt, or prepare code for completion after review. Not for refactoring logic or fixing bugs—focused solely on cosmetic and hygiene cleanup.4---56# Code Cleanup78## Overview910Performs post-review cosmetic cleanup to make code production-ready. This workflow is now integrated as Phase T-7 of `/skill:specs-kit-task-implementation`. It can also be invoked manually using `--action=cleanup`.1112**Input**: `docs/specs/[id]/tasks/TASK-XXX.md` (reviewed status) 13**Output**: Cleaned code, task marked `completed`1415## When to Use1617- Use when asked to clean up code, polish, finalize, tidy up, or remove technical debt after review approval.18- Use to prepare code for completion: remove debug logs, dead code, optimize imports, and improve readability.19- Use as the final quality gate in the specification-driven development workflow.20- Not for refactoring logic or fixing bugs — focused solely on cosmetic and hygiene cleanup.2122## Arguments2324| Argument | Required | Description |25|----------|----------|-------------|26| `--task` | Yes | Path to task file |27| `--action`| No | Set to `cleanup` for manual invocation |2829## Best Practices3031- **Clean, not change**: Only remove or reorganize — never change functionality32- **Preserve behavior**: Code must work exactly the same after cleanup33- **Use project tools**: Discover and run the formatter/linter the project already configures (`package.json` scripts, Maven/Gradle plugins, `composer` scripts, `pyproject.toml` tooling, `.pre-commit-config.yaml`)34- **Use a checklist**: Track progress through all 8 phases35- **Stop on failure**: If tests fail, stop and report — do not proceed3637## Instructions3839### Phase 1: Task Verification40411. Parse the skill arguments for parameters:42 - `--task` (required): Task ID or file path43 - `--spec` (optional): Spec folder path (used with task ID)44 45 **Support two formats**:46 - Format 1 (direct path): `--task=docs/specs/001-feature/tasks/TASK-001.md`47 - Format 2 (spec+task): `--spec=docs/specs/001-feature --task=TASK-001`48 49 If Format 2 is used, construct the task file path as: `{spec}/tasks/{task}.md`50512. Read the task file. Verify:52 - Status is `reviewed`, `implemented`, or `completed` (an earlier cleanup may53 have already stamped `completed`, which the loop treats as terminal)54 - Review report `TASK-XXX--review.md` exists and is approved553. If not reviewed → stop and tell user to run `/skill:specs-kit-task-review` first564. Extract task ID, title, and `provides` files5758### Phase 2: Identify Files to Clean59601. Read `TASK-XXX--review.md` for files created/modified612. Read task `provides` field for file paths623. Verify files exist; build cleanup list634. Categorize: source files, test files, config files6465### Phase 3: Technical Debt Removal6667Search files for temporary/debug artifacts with Grep:68- `console.log`, `System.out.println`, `print(`, `// DEBUG:`, `// temp`, `// hack`69- Resolved `TODO`/`FIXME` comments (keep unresolved ones)7071Review context for each finding. Remove confirmed debt and document what was removed.7273### Phase 4: Import Optimization74751. Discover and run the project's own import tooling from its configuration (`package.json` scripts, Maven/Gradle plugins, `composer` scripts, `pyproject.toml`, `.pre-commit-config.yaml`)762. Manually remove unused imports if no tool is configured773. Document files changed7879### Phase 5: Code Readability Improvements80811. Discover and run the project's own formatter/linter from its configuration (`package.json` scripts, Maven/Gradle plugins, `composer` scripts, `pyproject.toml`, `.pre-commit-config.yaml`)822. If no formatter is configured: fix indentation, break long lines (>120), fix spacing833. Remove dead code only if obviously safe844. Document changes8586### Phase 6: Documentation Verification87881. Verify class/file headers and public API docs892. Check remaining TODOs are still valid and have context903. Remove or update outdated comments914. Document documentation changes9293### Phase 7: Final Verification94951. Run linters if available962. Run tests if available973. Verify no logic or signature changes were introduced984. If tests fail → stop and report failures99100### Phase 8: Task Completion1011021. **Update the task status**:103 - Add a `## Cleanup Summary` section to the task file104 - Check any remaining boxes in the DoD section105 - Inside the loop, hooks update status to `reviewed` (the canonical terminal the loop106 expects) and stamp `reviewed_date` + `cleanup_date`.107 - **Standalone run (outside the loop)**: no hook fires, so edit the frontmatter yourself —108 set `status: reviewed` and stamp `reviewed_date` + `cleanup_date` (YYYY-MM-DD).109 Only `pending`, `implemented`, `reviewed`, `completed` are valid values; anything else110 (e.g. `done`) makes the task file fail to load and blocks run/refresh for the whole spec.111 1122. Append `## Cleanup Summary` to task file with:113 - Files cleaned114 - Changes made115 - Verification checklist (linters, tests, no functionality changes)1163. Mark all todos complete117118## Examples119120### Spring Boot Cleanup121122```bash123/skill:specs-kit-task-implementation --task="docs/specs/001-user-auth/tasks/TASK-001.md" --action=cleanup124```125126Actions:1271. Verify TASK-001 status is `reviewed`1282. Files: `UserController.java`, `UserService.java`, `UserRepository.java`1293. Remove 5 `System.out.println` and 2 resolved TODOs1304. Run `./mvnw spotless:apply`1315. Run `./mvnw test -q`1326. Mark task `reviewed`133134### TypeScript Cleanup135136```bash137/skill:specs-kit-task-implementation --task="docs/specs/002-dashboard/tasks/TASK-003.md" --action=cleanup138```139140Actions:1411. Verify TASK-003 status is `reviewed`1422. Files: `Dashboard.tsx`, `useDashboard.ts`, `Dashboard.test.tsx`1433. Remove 8 `console.log` statements1444. Run `npm run lint:fix` and `npm run format`1455. Run `npm test`1466. Mark task `reviewed`147148## Constraints and Warnings149150- Never change logic or signatures during cleanup151- Stop immediately and report if tests fail152- Verify behavior is unchanged before marking complete