From spectre
Analyzes recent code changes to identify and remove dead code, orphaned artifacts, and remnants from failed implementation branches using parallel subagents for investigation and validation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spectre:spectre-cleanThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded $ARGUMENTS value.
commit_id: Optional starting commit - analyzes all changes from and including this commit through HEAD plus staged/unstaged/untracked — (via ARGUMENTS: $ARGUMENTS)
scope_mode: One of: commit_range, unstaged, context — determines working settarget_out_dir: Optional OUT_DIR overrideout_dir: docs/tasks/{branch_name}analysis_dir: {out_dir}/cleanup_analysisreports_subdir: {analysis_dir}/area_reportsvalidation_subdir: {analysis_dir}/validationsmax_parallel_agents: 4Optional scope specification. If ambiguous, ask user to clarify.
<ARGUMENTS> $ARGUMENTS </ARGUMENTS>
Relevant Files:
package.json — Dependencies contexttsconfig.json — TypeScript configuration.gitignore — Exclusion patterns to respectworking_set.json, initial_findings.md, duplication_report.md, cleanup_summary.md) must never overwrite existing files—if a target exists, create a scoped variant (append scope/task/timestamp) and use that path in messaging.commit_id or commit SHA:
git rev-parse --verify {commit_id}^{commit} 2>/dev/null
git log --name-only --pretty=format: {commit_id}^..HEAD | sort -u
{commit_id}^..HEAD to INCLUDE the commit_id commit itselfgit diff --cached --name-onlygit diff --name-onlygit ls-files --others --exclude-standardgit diff --cached --name-onlygit diff --name-onlygit ls-files --others --exclude-standard1 — From a specific commit (provide SHA)2 — Current unstaged/staged changes only3 — Files we've discussed in this session{analysis_dir}/working_set.json
branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)target_out_dir → OUT_DIR={target_out_dir}OUT_DIR={out_dir}mkdir -p "OUT_DIR/{analysis_dir}/{reports_subdir}"mkdir -p "OUT_DIR/{analysis_dir}/{validation_subdir}"console.log(varName), console.log({var1, var2}).only, skipped tests, test data that should be removedany to bypass type issues{analysis_dir}/initial_findings.md (use a scoped variant like initial_findings_{timestamp}.md if the default exists; never overwrite)
Action — DetectDuplication: Find repeated code patterns in working set
Action — GenerateDuplicationReport: Write {analysis_dir}/duplication_report.md (or a scoped variant if it already exists; do not overwrite)
Format:
## Duplicate Code Clusters
### Cluster 1: {pattern_name} ({instance_count} instances)
- `{file1}:{lines}`
- `{file2}:{lines}`
- `{file3}:{lines}`
**Pattern**: {description}
**Recommendation**: Extract to `{suggested_location}`
**Effort**: {low|medium|high}
Subagent Investigation Instructions Template:
You are investigating recent changes in {area_name} for dead code artifacts.
**Context**: These files were recently modified. Look for artifacts from failed implementation attempts, abandoned branches, or incomplete refactors.
**Files in scope**: {file_list}
**Initial patterns detected**: {patterns_for_area}
**Your task**:
1. Review all files in scope thoroughly
2. For EACH potential issue, verify:
- Is this code actually unused? (check imports, calls, references)
- Is this a remnant from a failed approach? (check git history if needed)
- Could this break something if removed? (check dependencies)
3. Categorize findings:
- SAFE_TO_REMOVE: Confirmed dead code, no dependencies
- NEEDS_VALIDATION: Likely dead but needs confirmation
- KEEP: Actually used or unclear
4. Document evidence for each finding
**Output format**: Markdown report with sections per issue type.
**Critical**: Be conservative. When in doubt, mark NEEDS_VALIDATION.
Save your report to: {reports_subdir}/{area_name}_report.md (if that file exists, append a unique identifier such as `{area_name}_{timestamp}.md`; never overwrite)
{reports_subdir}/{area_name}_report.md (or scoped variant if default exists){reports_subdir}/
Subagent Validation Instructions Template:
You are validating a finding from dead code analysis.
**Original finding**:
{finding_description}
{file_path}:{line_numbers}
{reasoning_from_investigation}
**Your task**:
1. Search codebase for ANY usage (dynamic imports, string refs, reflection)
2. Check test files for usage
3. Verify the code is actually dead, not just indirectly used
4. Determine: CONFIRMED_SAFE, UNSAFE, or UNCERTAIN
**Output format**: Markdown with verdict, evidence, reasoning.
Save to: {validation_subdir}/{task_id}_validation.md (if that file exists, append a unique identifier; never overwrite)
{validation_subdir}/
{analysis_dir}/cleanup_summary.md (or a scoped variant if it already exists; do not overwrite)
{analysis_dir}/removal_tasks/task_{id}.mdrm {file_path}{analysis_dir}/changes_log.md{out_dir} and {analysis_dir}:
working_set.json, initial_findings.md, duplication_report.mdcleanup_summary.md{reports_subdir}/{validation_subdir}/.md or .json artifacts created during this flowgit add {out_dir}/ {analysis_dir}/docs(clean): add cleanup analysis artifacts for {branch_name}@skill-spectre:spectre-guidePurpose: Systematically identify tech debt from eslint-disable comments in the working set.
7a. Collect ESLint Bypasses:
grep -rn "eslint-disable\|@ts-ignore\|@ts-expect-error" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx"
7b. Group by Module: Cluster findings by directory or logical module (files that import each other).
7c. For each group with ≥2 bypasses, dispatch @analyst in parallel:
Analyze ESLint bypasses in: {file_list}
For each bypass:
1. Identify the disabled rule(s)
2. Understand WHY it was disabled (type issue? legacy code? third-party types?)
3. Determine the proper fix (type narrowing, interface update, refactor, etc.)
Output a refactor plan:
- File: path
- Line: number
- Rule: disabled-rule-name
- Reason: why it exists
- Fix: specific refactor steps
- Effort: trivial / moderate / significant
- Risk: low / medium / high
7d. Present Refactor Summary:
Note: This step is diagnostic. Actual refactoring happens in follow-up tasks, not during clean.
npx claudepluginhub codename-inc/spectre --plugin spectreDetects and removes dead code in Repowise-indexed codebases using graph analysis. Presents findings sorted by confidence tier and guides safe deletion.
Detects dead code, fallbacks, deprecated patterns in repos using scanner, git historian, and verifier agents. Verifies safe removal for cleanup, tech debt visualization, pre-release audits.
Finds and safely removes unused exports, dead files, orphaned dependencies, and stale constraints. Use after refactoring or as periodic hygiene.