code-auditor
Code Auditor
Use this skill to analyze a codebase for duplication, dead code, dependency issues, and consolidation opportunities. Prefer conservative findings and make the next cleanup steps obvious.
Core Responsibilities
-
Detect duplicate code
- Scan for repeated logic patterns across files such as color mappings, formatters, validators, and API helpers.
- Identify copy-pasted functions with minor variations.
- Find redundant utility implementations that should be consolidated.
- Detect repeated inline constants, magic numbers, and configuration values.
- Look for similar component patterns that could be abstracted.
-
Identify unused code
- Find exported functions or components that are never imported.
- Detect dead code branches and unreachable logic.
- Identify commented-out code blocks that should be removed.
- Locate orphaned files with no imports.
- Find unused variables, parameters, and type definitions.
-
Audit dependencies
- Cross-reference dependencies against actual imports and runtime usage.
- Identify packages that are installed but never used.
- Find duplicate packages serving the same purpose.
- Detect dependencies that belong in
dependenciesversusdevDependencies. - Flag deprecated or unmaintained packages when evidence is available.
Analysis Workflow
-
Discovery
- Read the project structure to understand the codebase organization.
- Identify the tech stack to contextualize findings.
- Locate utility, helper, and shared-module directories.
- Build a rough mental map of the import graph.
-
Deep scan
- Search for common duplication patterns:
- Color and theme mappings
- Date and time formatting functions
- Number and currency formatters
- Validation logic and regex patterns
- API response transformers
- Error-handling utilities
- String helpers
- Type guards and type utilities
- Search for similar function signatures and repeated inline implementations.
- Compare local implementations against existing shared utilities before calling for abstraction.
- Search for common duplication patterns:
-
Usage analysis
- Trace each utility or helper across the codebase.
- Identify exports with zero real consumers.
- Find local functions that duplicate existing shared helpers.
- Check for circular, redundant, or layered-through-barrel imports.
-
Dependency review
- Read dependency manifests such as
package.json,pyproject.toml, or equivalents. - Search the codebase for actual import, require, and dynamic loading patterns.
- Cross-reference declared dependencies with observed usage.
- Identify overlapping packages and likely removal candidates.
- Read dependency manifests such as
Output Format
Present findings in this structure.
Duplicate Code Found
For each duplication:
- Pattern: What is duplicated
- Locations: Files or code areas involved
- Recommendation: Proposed consolidation approach
- Priority: High, Medium, or Low based on maintenance risk
Unused Code
For each unused item:
- Type: Function, Component, Variable, Type, or File
- Location: File path and relevant symbol or area
- Confidence: High or Medium based on certainty
- Action: Delete or investigate further
Unused Dependencies
For each dependency:
- Package: Name and version when available
- Type: dependency or devDependency
- Action: Remove or verify usage
Consolidation Opportunities
Close with a practical cleanup plan:
- Create or strengthen shared utilities
- Migrate duplicated call sites incrementally
- Delete unused code in a safe order
- Remove unused packages with explicit commands when possible
Guidelines
- Be thorough: Read enough surrounding code to understand whether behavior is truly duplicated or unused.
- Be conservative: Only flag code as unused when the evidence is strong.
- Consider edge cases: Account for dynamic imports, conditional requires, reflection, and framework conventions.
- Respect existing patterns: Recommend refactors that fit the codebase style.
- Prioritize safety: Favor incremental cleanup steps over big-bang rewrites.
- Check tests: Test files may be the only consumers of some utilities.
- Check tooling: Build tools and config files may reference code that app code does not.
- Call out uncertainty: Mark likely false positives for manual review instead of overstating confidence.
Common Pitfalls
- Do not flag framework-required exports such as page components or framework entrypoints.
- Do not assume barrel exports are unused just because the barrel itself is not imported directly.
- Do not recommend removing types that exist for tooling, contracts, or documentation without checking their consumers.
- Do not miss dynamic imports such as
import(),require(), or string-based module loading. - Do not overlook CSS or style imports that affect runtime behavior.
- Do not flag
proxy.tsas dead code in modern Next.js projects simply becausemiddleware.tsused to serve that role.
When Uncertain
If an item cannot be verified confidently:
- State what you verified and what remains uncertain.
- Recommend manual verification steps before deletion.
- Suggest tooling that can improve confidence, such as
knip,depcheck, orts-prune. - If the uncertainty is ecosystem-specific, check the relevant documentation before making a removal recommendation.
More from robinebers/skills
shepherd
Shepherd a GitHub pull request all the way to merge-ready by relentlessly polling status and only acting once all automatic reviewers have finished. NEVER merges without explicit human approval. Use when the user says things like "shepherd this PR", "babysit this PR", "get this PR merge-ready", "wait for Cubic", "wait for Bugbot", or asks to drive a PR through review.
12code-upgrade
Engineering-discipline toolkit for non-technical users working with AI coders. Wields KISS, DRY, YAGNI, fail-fast, and idempotency as commands. Use when the user asks to audit, simplify, clean up, dedupe, or harden code; or says "make this simpler", "any duplicates?", "is this safe to run twice", "explain this app", "find dead code", "simplify the plan", or "find silent failures".
7setup-process
Generate setup scripts/configs for AI agent worktrees and isolated environments across Cursor, Codex, and Conductor. Use when wiring up a project so AI agents start with the same dependencies, env files, and tool configs as the main repo.
5agents-md
Install or update Robin Ebers's AGENTS.md from github.com/robinebers/agents.md. Use when the user asks to add AGENTS.md to a workspace, refresh it to the latest upstream version, merge upstream changes into a customized local AGENTS.md, or make the repo follow Robin's agent protocol file.
3pr-manager
Manage GitHub pull requests with `gh` and `git`: create or update a pull request, wait for checks, fetch review comments, and optionally fix them automatically. Use when the user says things like "create pr", "open a pr", "update the pr", "pull comments", "check PR comments", "check for new comments", or "fetch review comments".
3conductor-json
Generate conductor.json files for Conductor workspaces. Use when setting up a new project, creating conductor.json, or configuring workspace scripts for Tauri, Next.js, or React projects.
2