Code Audit & Cleanup Specialist

VerifiedSafe

Audits a project to find unused code while protecting critical entrypoints, integrations, and dynamic calls. Produces evidence-based risk reports and reversible cleanup plans. Helps when you need to identify dead code, reduce technical debt, or evaluate legacy modules without risking stability.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#code-audit#unused-code#technical-debt#cleanup#safety

Recommended for

Automated summary

Audits the project to identify unused code while strictly protecting entrypoints, integrations, and dynamic calls. Generates evidence-based risk reports and reversible cleanup plans.

Strengths

  • Explicit protection of critical entrypoints (routes, jobs, webhooks, CLI) and dynamic calls.
  • Rigorous risk classification with evidence (grep, reference search).
  • Generates detailed reports and phased cleanup plans (deprecate → observe → remove).

Limitations

  • Requires deep understanding of the codebase to correctly classify ambiguous items.
  • May miss indirect usage in highly dynamic frameworks (complex metaprogramming).
  • Cleanup plan is theoretical; manual validation by the user is required for each removal.
When to use it

Use this skill when you need a structured, safe audit of dead code with evidence and a gradual removal plan.

When not to use it

Do not use for immediate refactoring without human validation, or if you prefer a more aggressive code removal approach.

Security analysis

Safe
Quality score92/100

The skill describes a passive auditing process using grep, find, and LSP. It does not instruct execution of destructive or exfiltrating commands. It emphasizes reversible changes and never deletes code without explicit user approval. No dangerous patterns like curl|sh or disabling safety are present.

No concerns found

How this analysis is made

Examples

Full project audit
Audit this project for unused code. Generate a report and cleanup plan.
Spot-check a module
Find dead code in the src/features directory. Only flag items that are safe to remove.
Risk assessment of specific files
Run a code audit on lib/tasks/ and app/controllers/ to identify unused methods and constants.

name: auditing-code description: Audits the project to identify unused code while strictly protecting entrypoints, integrations, and dynamic calls. Generates evidence-based risk reports and reversible cleanup plans.

Code Audit & Cleanup Specialist

Mission

To reduce technical debt and cognitive load for both humans and AI agents by identifying unused code, WITHOUT altering the system's behavior or risking stability. We prioritize safety, reversibility, and explicit evidence over aggressive cleanup.

When to use this skill

  • When the user requests a code audit, cleanup, or identification of "dead code".
  • When evaluating legacy modules for refactoring.
  • Trigger phases: AUDIT (Mapping), ASSESS (Risk Classification), REPORT (Evidence), PLAN (Cleanup Strategy).

Workflow

Copy this checklist to task.md:

  • [ ] Phase 1: Protection & Mapping
    • [ ] Identify Critical Entrypoints (Routes, Jobs, Webhooks, CLI, AI Agents).
    • [ ] Map potentially unused items (using grep, find, LSP).
  • [ ] Phase 2: Risk Assessment & Evidence
    • [ ] Classify strictly: SAFE, CAUTION, or KEEP.
    • [ ] Collect usage evidence for every item (or lack thereof).
    • [ ] Validate against "Dynamic Use" exclusions (Reflection, strings).
  • [ ] Phase 3: Reporting
    • [ ] Generate audit_report.md (Human/AI readable).
    • [ ] Provide summary metrics.
  • [ ] Phase 4: Cleanup Strategy
    • [ ] Create cleanup_plan.md (Strategy: Deprecate -> Observe -> Remove).
    • [ ] WAIT for explicit user approval.

Instructions

1. Protection Rules (The "Red Lines")

NEVER classify as SAFE if the item matches these criteria. Must be KEEP or CAUTION.

| Category | Protection Rule | Trigger Pattern Examples | | :------------- | :------------------------------------- | :----------------------------------------------- | | Routes/API | Public controllers, API endpoints. | routes.rb, *Controller, API::* | | Async Jobs | Background workers, schedulers. | Sidekiq::Worker, ApplicationJob, cron.yaml | | Webhooks | External callbacks, event handlers. | handle_webhook, on_*, stripe_event | | CLI/Tasks | Rake tasks, scripts, console commands. | lib/tasks/*.rake, bin/* | | Dynamic | Feature flags, ENV-driven logic. | ENV['FEATURE_*'], Features.enabled? | | Meta-Prog | Reflection/String-based calls. | send(params[:method]), constantize | | AI Agents | Tools/Skills used by Agents. | class *Tool, scenarios/*.yaml |

2. Risk Classification Logic

Every item must be tagged with a risk level.

  • ✅ SAFE:

    • Strictly internal (private methods, local vars).
    • 0 references found in entire codebase (grep check).
    • Not an entrypoint or potential meta-programming target.
    • Constraint: Must verify removal doesn't break syntax.
  • ⚠️ CAUTION:

    • Public methods with no explicit callers.
    • Constants/Classes that "look" like headers or strict types.
    • CSS classes (could be constructed strings).
    • Requirement: Needs implicit usage check.
  • ❌ KEEP:

    • Valid references found.
    • Any item executing external I/O or integrations.
    • Test helpers (crucial for verifying correctness).
    • Core configuration.

3. Evidence Requirement

The skill MUST prove why an item is unused.

  • BAD: "Variable x looks unused."
  • GOOD: "Variable x defined at line 10. grep -r 'x' . returned only the definition. Local scope confirmed."

4. Reporting Format

Output to audit_report.md.

# Audit Report: [Scope Name]

## Executive Summary

- **Total Scanned**: 50 items
- **✅ Safe to Remove**: 5
- **⚠️ Caution**: 2
- **❌ Keep**: 43

## Detailed Findings

| File/Context          | Item Type | Name/Snippet  | Risk       | Evidence/Rationale                                              |
| :-------------------- | :-------- | :------------ | :--------- | :-------------------------------------------------------------- |
| `app/models/user.rb`  | Method    | `legacy_auth` | ✅ SAFE    | Defined but never called. Grep returned 0 hits. Not a callback. |
| `app/views/home.html` | CSS Class | `.old-banner` | ⚠️ CAUTION | No static usage, but class name might be dynamic in JS.         |
| `app/jobs/mail.rb`    | Class     | `DailyMail`   | ❌ KEEP    | Inherits ApplicationJob. Likely called via Redis/Sidekiq.       |

## Recommendations

- [ ] Safe items can be removed immediately.
- [ ] Caution items should be commented out or logged first.

5. Cleanup Strategy (Incremental)

NEVER delete code in the audit phase. Propose a plan in cleanup_plan.md:

  1. Level 1 (Safe): Delete dead private methods, unused local variables.
  2. Level 2 (Deprecate): Add ActiveSupport::Deprecation warning or log "Unused code reached" for CAUTION items.
  3. Level 3 (Observe): Monitor logs for 1 week.
  4. Level 4 (Remove): Delete after established silence.
  5. Level 5 (Commit & Monitor):
    • Commit changes with reversible message: git commit -m "refactor: remove unused [item] - reversible"
    • Monitor production logs for 48h
    • Keep rollback plan ready: git revert HEAD

Anti-Patterns

  • Deleting files without a rollback plan.
  • Trusting grep blindly on short strings (too many collisions) or huge projects (dynamic imports).
  • Removing Database Migrations (historic record).
  • Removing Tests just because they verify "unused" code (the test proves the code exists, not that it's useful).

Validation Checklist

Before proposing removal of any item, verify:

  • [ ] Item is NOT in routes.rb or called by external systems
  • [ ] Item is NOT inherited from framework base classes (ApplicationJob, ApplicationController)
  • [ ] Item is NOT used in string interpolation or send() calls
  • [ ] Item is NOT a callback (before**, after*, around_)
  • [ ] Item is NOT accessed via ENV variables or feature flags
  • [ ] Removal does NOT break tests (run test suite after each deletion)

Output Files

This skill generates:

  • audit_report.md - Evidence-based findings
  • cleanup_plan.md - Phased removal strategy (only after user approval)
  • rollback_plan.md - Emergency recovery steps

Never execute deletions without explicit user confirmation.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/code-audit-cleanup-specialist-mm8o52ds/download' --output '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md.part' && mv '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md.part' '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md' && test -s '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/auditing-code' && cp -R '.skill-downloads/code-audit-cleanup-specialist-mm8o52ds' '.claude/skills/auditing-code'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/code-audit-cleanup-specialist-mm8o52ds'

openskills read 'code-audit-cleanup-specialist-mm8o52ds'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/code-audit-cleanup-specialist-mm8o52ds/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills