Audit the codebase for dead code, duplicate code, inefficient code, overloaded code, missing test coverage, non-conforming code, stale documentation, and other best practice violations. Uses parallel subagents for discovery and hands off findings to /architect to create a TDD for fixes.
Audit the codebase for dead code, duplicate code, inefficient code, overloaded code, missing test coverage, non-conforming code, stale documentation, and other best practice violations. Uses parallel subagents for discovery and hands off findings to /architect to create a TDD for fixes.
Systematically audit the codebase for code health issues using parallel subagents for discovery, then hand off findings to /architect to produce a TDD for remediation.
Invocation
# Audit everything
/refactor
# Audit a specific area
/refactor cimplur-core/Memento/Domain/Repositories
# Audit a specific category only
/refactor --category dead-code
/refactor --category duplicates
Arguments:
First argument (optional): path to scope the audit (directory or file)
--category <name>: limit to a single audit category (see categories below)
Process
┌──────────────────────────────────────────────────────┐
│ Phase 1: Scope & Plan │
│ Phase 2: Parallel Discovery (7 subagents) │
│ Phase 3: Consolidate & Deduplicate Findings │
│ Phase 4: User Prioritization │
│ Phase 5: Hand Off to /architect for TDD │
└──────────────────────────────────────────────────────┘
Phase 1: Scope & Plan
Determine audit scope based on arguments:
If a path is provided — audit only that directory/file
If a category is provided — run only that audit category
If no arguments — audit the full codebase (both cimplur-core and fyli-fe-v2)
Before launching subagents, read key project files for context:
Launch up to 7 subagents in parallel using the Task tool (subagent_type: Explore). Each subagent focuses on one audit category. Give each subagent the audit scope (path) and project conventions so it can work independently.
Each subagent must return findings in this format:
## [Category Name] Findings
### Finding 1: [Short title]
- **Severity:** Critical | High | Medium | Low
- **Location:** file_path:line_number
- **Description:** What the issue is
- **Evidence:** Code snippet or explanation proving the issue
- **Suggested fix:** Brief description of how to resolve
### Finding 2: ...
Category 1: Dead Code
Search for code that is never called, never imported, or unreachable.
Backend (C#):
Public methods never referenced outside their class
Unused using statements
Commented-out code blocks (more than 3 lines)
Unreachable code after return/throw
Unused private fields or properties
Empty catch blocks that swallow exceptions
Unused constructor parameters
Frontend (Vue/TypeScript):
Exported functions/types never imported elsewhere
Components never used in templates or router
Dead store actions/getters never called
Unused composable return values
CSS classes defined but never applied
Unused event handlers or watchers
Category 2: Duplicate Code
Search for code that is repeated and should be abstracted.
Methods or functions with near-identical logic (>10 lines of similar structure)
Copy-pasted validation logic across controllers or components
Repeated API call patterns that could be a shared utility
Duplicate type definitions or interfaces
Repeated error handling blocks with identical structure
Similar LINQ/EF query patterns across repositories
Note: 3 similar lines is fine — only flag genuine duplication where abstraction would reduce bugs.
Category 3: Inefficient Code
Search for performance problems and wasteful patterns.
Backend:
N+1 query patterns (loading in loops without Include)
Missing AsNoTracking on read-only queries
Large datasets loaded into memory when paging is needed
Synchronous I/O in async methods
String concatenation in loops (should use StringBuilder)
Unnecessary ToList() before further LINQ operations
Frontend:
Large reactive objects that should use shallowRef
Missing v-once on static content in hot paths
Watchers that could be computed properties
Unnecessary re-renders from improper reactivity
Unbounded list rendering without virtual scroll
API calls in components that should be in stores/composables
Large synchronous imports that should be lazy-loaded
Category 4: Overloaded Code
Search for classes, methods, or components doing too much.
Methods over 100 lines
Classes with more than 10 public methods (God class)
Components with more than 300 lines of <script> (should be split)
Controllers with business logic (should be in services)
Services mixing data access with business rules
Functions with more than 5 parameters
Deeply nested conditionals (>3 levels)
Category 5: Missing Test Coverage
Search for untested code paths.
Backend:
Services without corresponding test files in DomainTest/
Use AskUserQuestion to let the user decide what to address:
Fix all — create a TDD covering all findings
Critical & High only — skip medium/low
Select specific categories — pick which categories to fix
Select specific findings — cherry-pick individual items
Phase 5: Hand Off to /architect
Invoke the /architect skill with the selected findings:
/architect Create a TDD at docs/tdd/refactor-<slug>.md for the following codebase issues found during audit:
[paste consolidated findings here]
Group fixes into logical phases. Each phase should be independently buildable and testable.
The architect skill will:
Create the TDD with phased implementation plan
Run /code-review on the TDD
Return the TDD path for /builder or /builder-r to implement
Severity Definitions
Severity
Definition
Examples
Critical
Active bugs, security vulnerabilities, data corruption risks