.claude/skills/pm-cleanup/SKILL.md
Analyze codebase for dead code, unused imports, inconsistencies, and structural debt, then scaffold a work package with cleanup tasks. Never modifies code directly — changes flow through the normal implement/test/commit pipeline. Use when the user says "clean up the code", "remove dead code", "tidy up", "find unused code", "code hygiene", or "clean up imports".
npx skillsauth add pinkroosterai/PinkRoosterMcp pm-cleanupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze the codebase for cleanup opportunities — dead code, unused imports,
inconsistencies, and structural debt — then scaffold a tracked work package so
fixes go through the normal /pm-implement pipeline with tests and commits.
The key difference from /pm-audit: audit finds bugs and vulnerabilities that
create Issues. Cleanup finds hygiene debt that creates a single Chore WP with tasks.
Parse $ARGUMENTS for flags:
--dry-run: Show findings without scaffolding a WP--scope <path>: Limit analysis to a specific directory (e.g., src/PinkRooster.Api)--scope src/PinkRooster.Mcppwdmcp__pinkrooster__get_project_status with projectPath set to the directory aboveprojectIdLoad existing issues to avoid creating duplicate cleanup tasks:
mcp__pinkrooster__get_issue_overview with projectId and stateFilter: "Active"mcp__pinkrooster__get_issue_overview with projectId and stateFilter: "Inactive"Compile a deduplication list of existing issue names and descriptions.
Spawn an Explore agent with subagent_type: "Explore" and thoroughness "very thorough":
Analyze the codebase at {project_path}{scope_suffix} for cleanup opportunities.
Focus on these categories:
### 1. Dead Code
- Unused private methods, fields, properties, or classes
- Methods defined on interfaces but never called (check all implementations)
- Unreachable code paths (after unconditional returns, dead branches)
- Commented-out code blocks (>3 lines)
- Unused enum values or constants
### 2. Unused Imports & Dependencies
- Using directives that don't resolve to any symbol in the file
- NuGet/npm packages in project files not referenced by any source file
- Orphaned configuration entries (appsettings keys never read)
### 3. Inconsistent Patterns
- Mixed approaches to the same problem (some files use pattern A, others pattern B)
- Naming convention violations (methods, variables, files not matching project style)
- Duplicated utility code that should be consolidated
### 4. Structural Debt
- Empty files, empty classes, or stub implementations left behind
- Overly large files (>500 lines) that should be split
- Misplaced code (files in wrong directory per project architecture)
- Obsolete test fixtures or mock data
For each finding, report:
1. File path and line number(s)
2. What should be cleaned up (specific, not vague)
3. Category: DeadCode, UnusedImports, Inconsistency, StructuralDebt
4. Effort: Trivial (1-line fix), Small (under 10 lines), Medium (multi-file)
5. Safety: Safe (zero risk), NeedsReview (might affect behavior), Risky (public API)
6. A concrete fix description
Skip trivial style issues a linter handles. Focus on things that reduce maintenance
burden, eliminate confusion, or improve code health.
When the agent completes:
Verify Critical Findings: For any finding marked Medium effort or NeedsReview/Risky safety, read the actual code to confirm the issue is real. Remove false positives.
Cross-reference with existing issues: Check each finding against the deduplication list from Step 2. Skip findings already tracked.
Filter noise: Remove findings that are:
Group by action: Cluster related findings into logical cleanup tasks. For example:
Each group becomes one task in the scaffolded WP. Target 3-8 tasks total — not one task per finding, but not one mega-task for everything either.
Sort by impact: Safe + Trivial/Small first (quick wins), then Medium, then Risky last.
## Codebase Cleanup Analysis
**Scope**: {scope or "entire project"}
**Findings**: {totalCount} across {categoryCount} categories
### Cleanup Tasks (grouped)
| # | Task | Files | Category | Effort | Safety |
|---|------|-------|----------|--------|--------|
| 1 | {grouped task description} | {file count} | {category} | {effort} | {safety} |
| 2 | ... | | | | |
### Skipped ({count})
- {finding} — already tracked as {existingIssueId}
- {finding} — false positive
If --dry-run: Show the table and stop.
"Dry run complete. {taskCount} cleanup tasks identified. Run without --dry-run to scaffold a work package."
If no findings: "Codebase is clean — no cleanup opportunities found in {scope or 'project'}."
Otherwise: Use AskUserQuestion:
For confirmed tasks, call mcp__pinkrooster__scaffold_work_package with:
projectIdname: "Codebase cleanup: {scope or 'project-wide'}"description: Summary of what will be cleaned and whytype: Chorepriority: LowestimatedComplexity: Based on total effort (1-3 for mostly trivial, 4-6 for mixed)estimationRationale: "{N} cleanup tasks across {M} files, mostly {effort level}"phases: Single phase "Cleanup" with:
name: Concise action (e.g., "Remove unused helper methods in StateCascadeService")description: What to remove/change and whyimplementationNotes: Specific file paths, line numbers, and what to dotargetFiles: Actual file paths from the analysis{name: "Solution builds", description: "dotnet build PinkRooster.slnx completes with 0 errors after all cleanup tasks.", verificationMethod: "AutomatedTest"}{name: "Tests pass unchanged", description: "All existing tests pass without modification — cleanup must not change behavior.", verificationMethod: "AutomatedTest"}{name: "No new warnings", description: "Build warning count does not increase after cleanup.", verificationMethod: "AgentReview"}## Scaffolded: {wpId} "Codebase cleanup"
- **Tasks**: {count}
- **Files affected**: {count}
- **Estimated effort**: {complexity}/10
### Task Summary
| # | Task ID | Name | Category | Effort |
|---|---------|------|----------|--------|
| 1 | {taskId} | {name} | {category} | {effort} |
| ... |
### Next Steps
- Implement cleanup: `/pm-implement {wpId}` or `/pm-next`
- View project status: `/pm-status`
- Clean up stale project entities: `/pm-housekeeping`
/pm-implement--dry-run shows findings without scaffoldingtools
Verify acceptance criteria for a phase or entire work package. Runs verification based on each criterion's method (AutomatedTest, Manual, AgentReview) and records results via the MCP tool.
development
Diagnose the root cause of a bug, error, crash, or unexpected behavior. Traces through code, logs, services, database state, and git history to find why something is broken. Researches error messages online for known issues. Produces a diagnosis with evidence and suggested fix. Use when the user reports a problem, error message, stack trace, test failure, or says things like "why is this happening", "this is broken", "I'm getting an error", "something's wrong with...", "debug this", or "figure out why...".
development
Review and prioritize open issues and feature requests. Analyzes severity, age, and codebase impact to recommend priority adjustments and next steps.
tools
Show project status dashboard with issue/FR/WP counts, active items, blocked items, and priority next actions. Use when the user asks about project status, progress, what's happening, what needs attention, or what to work on.