config/codex/skills/refactor-audit/SKILL.md
Audit a codebase for refactoring opportunities across all packages/sections. Spawns parallel refactor subagents per section, collects suggestions without executing, then presents a ranked plan for approval. Use when the user asks to "audit for refactors", "refactoring suggestions", "code quality review", "refactor plan", "find refactoring opportunities", or "what should we clean up".
npx skillsauth add cryptofish7/dotfiles refactor-auditInstall 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 a codebase for refactoring opportunities across all packages. Designed to be non-destructive — collects and ranks suggestions without executing any changes.
Scan the repository to identify distinct sections of the codebase. Each section should be a coherent unit (package, service, module) with its own domain.
package.json, workspace configs (pnpm-workspace.yaml, lerna.json), Cargo.toml workspaces, monorepo packages/ or apps/ directories, top-level folders with their own build configs.| Section | Root path | Language | Focus areas |
|---------|-----------|----------|-------------|
| ... | ... | ... | ... |
If the user provided an explicit section breakdown in their prompt, use that instead of auto-discovering.
Spawn one refactor subagent per section in parallel. Each subagent receives:
Subagent instructions (include verbatim in each subagent prompt):
Analyze the code in
{root_path}for refactoring opportunities. Do NOT make any changes — analysis only.For each suggestion, provide:
- What: File(s) and specific code to change (include line numbers)
- Why: How this improves the code (readability, performance, maintainability, correctness)
- Size:
quick-win(< 30 min),moderate(1-2 hrs), orsignificant(half-day+)- Risk:
low(safe rename/extract),medium(logic restructure, needs tests),high(behavioral change, cross-cutting)- Category: One of:
dead-code,duplication,extraction,simplification,naming,type-safety,performance,error-handling,organizationFocus areas for this section: {focus_areas}
Prioritize suggestions that:
- Remove dead code or unused imports
- Eliminate duplication (especially copy-pasted logic)
- Extract reusable functions from repeated patterns
- Simplify overly complex conditionals or nested logic
- Improve type safety (remove
any, add missing types)Flag any cross-package opportunities — shared logic that could move to a common package, inconsistent patterns across packages, or duplicated utilities.
Output your suggestions as a structured list grouped by category.
After all subagents complete:
Present the consolidated suggestions to the user:
## Refactor Audit Report
### Quick Wins
- [ ] **[category]** `path/to/file.ts:L42` — [what to change]. *Why:* [reason]. Risk: [low/medium].
### Moderate
- [ ] **[category]** `path/to/file.ts:L100-150` — [what to change]. *Why:* [reason]. Risk: [low/medium/high].
### Significant
- [ ] **[category]** `path/to/file.ts` + `other/file.ts` — [what to change]. *Why:* [reason]. Risk: [medium/high].
### Cross-Package Opportunities
- [ ] [description of shared pattern or utility that spans packages]
### Skipped
- [suggestion]: [why it was dropped]
Wait for user approval. The user may:
Do not execute any refactors until the user explicitly approves.
After approval, for each approved suggestion:
refactor agent when available. For cross-package changes, use the best available Codex implementation path and keep the change grouped as one logical refactor.Commit approved changes in logical groups (one commit per category or per section, not one per suggestion).
significant size minimum.testing
Generate and maintain a local deploy script (scripts/deploy.sh). Discovers project services, deploys them locally, and health-checks each one. Use when the user asks to "smoke test", "deploy locally", "test local deploy", "update deploy script", "run deploy", or "run smoke test".
testing
Audit installed skills and agents for bloat, overlap, and improvement opportunities. Use when the user wants to review, audit, list, or improve their skills and agents. Triggers on "review skills", "audit skills", "list skills", "skill review", "improve skills".
development
Set up the autonomous post-task workflow for a project. Injects the standard development pipeline into AGENTS.md and installs all required skills and agents (docs-consolidator, ci-cd-pipeline, smoke-test, bug-bash-update, code-reviewer, debugger). Use at the start of a new project. Triggers on "setup workflow", "init workflow", "add workflow", or "set up project workflow".
tools
Analyze the current conversation for learnings and persist approved insights. Triggers on "reflect", "retrospective", "session review", "what did we learn", "conversation review".