audit
無料Run comprehensive code audit for architecture, dead code, and test quality. Use when reviewing overall codebase health, checking for architectural violations, or before marking a feature complete.
日本語の概要は準備中です。原文の説明を表示しています。
Improve code structure without changing behavior. Use when refactoring, restructuring, simplifying, or extracting code. Also for reducing duplication, renaming for clarity, or addressing code smells. Enforces one change → test → commit cycle. NOT for style/formatting (use /lint), features, or bug fixes.
インストール方法を見るインストールする前に、エージェントに与えられる指示の中身を確認できます。
Improve code structure without changing behavior. One small step at a time.
Iron Law: ONE REFACTORING → TEST → COMMIT. Never batch changes.
Answer IN ORDER. Stop at first match:
Code smells (common triggers):
Is this actually refactoring?
| User Intent | Action |
|---|---|
| "Make this cleaner" | ✓ Refactoring |
| "Add validation" | ✗ New behavior → tdd-enforcer |
| "Fix this bug" | ✗ Bug fix → tdd-enforcer or systematic-debugger |
| "Format this code" | ✗ Style → /lint |
If not refactoring: Explain and suggest correct approach.
Does the code have tests?
| Coverage | Action |
|---|---|
| Well-tested | Skip to Phase 3 |
| Partial coverage | Add characterization tests for untested parts |
| No tests | Add characterization tests first |
When writing characterization tests: Characterization tests are still tests — apply behavioral testing principles (assert on what the system does, not how).
Capture current behavior before refactoring:
// Characterization test - captures ACTUAL behavior
it("processOrder returns current behavior", () => {
const result = processOrder({ items: [], user: null });
// Whatever it returns NOW is the expected value
expect(result).toEqual({ status: "empty", total: 0 });
});
Purpose: Safety net, not specification. Test what the code DOES, not what it SHOULD do.
Iron Law: ONE refactoring at a time. Run tests after EVERY change.
Tier 1 - Always Safe (no behavior change possible):
| Smell | Refactoring | Example |
|---|---|---|
| Unclear name | Rename | d → discountAmount |
| Long function | Extract Function | Pull 10 lines into calculateTax() |
| Unnecessary variable | Inline Variable | Remove temp = x; return temp; |
| Misplaced code | Move Function | Move validate() to Validator class |
// ❌ Before: unclear name
const d = price * 0.2;
// ✅ After: Rename
const discountAmount = price * 0.2;
Tier 2 - Safe with Tests (low risk if tests exist):
| Smell | Refactoring | Example |
|---|---|---|
| Repeated expression | Extract Variable | order.items.length > 0 → const hasItems = ... |
| Complex conditional | Decompose Conditional | Extract if branches to named functions |
| Nested conditionals | Guard Clauses | Early returns instead of deep nesting |
| Magic literal | Replace Magic Literal | 0.2 → VIP_DISCOUNT_RATE |
| Unused code | Remove Dead Code | Delete unreachable branches |
// ❌ Before: nested conditionals
function getDiscount(user) {
if (user) {
if (user.isVIP) {
return 0.2;
} else {
return 0.1;
}
}
return 0;
}
// ✅ After: Guard Clauses
function getDiscount(user) {
if (!user) return 0;
if (user.isVIP) return 0.2;
return 0.1;
}
Tier 3 - Requires Care (higher risk, break into smaller steps):
| Smell | Refactoring | Caution |
|---|---|---|
| God class | Extract Class | Do incrementally, move one method at a time |
| Type-checking conditionals | Replace with Polymorphism | Requires class hierarchy |
| Too many parameters | Introduce Parameter Object | Changes function signature |
| Complex loop | Replace Loop with Pipeline | Ensure equivalent behavior |
Tie-breaker: If multiple refactorings apply, choose smallest scope first (Rename < Extract Variable < Extract Function < Extract Class).
After each refactoring:
refactor: [what changed]git checkout -- <changed-files>
After revert:
STOP. Ask user:
"I've attempted this refactoring twice and tests keep failing. This suggests either:
- The refactoring is too large (need smaller steps)
- The code has hidden dependencies
- Tests are brittle
How would you like to proceed?"
More refactoring needed?
├─ Yes → Return to Phase 3 (one more refactoring)
└─ No → Done
├─ Run `/audit` to verify no dead code or new issues
└─ Report: "Refactoring complete. Changes: [summary]"
Audit catches: Dead code left behind, new duplication (should decrease!), architecture violations.
Partial test coverage:
Refactoring reveals a bug:
User requests large refactoring:
| Don't | Do |
|---|---|
| Batch multiple refactorings | One refactoring → test → commit |
| "Fix" a failed refactoring | Revert, then try smaller step |
| Refactor without tests | Add characterization tests first |
| Change behavior during refactor | That's a feature/fix, not refactoring |
| Skip the commit | Commit after every green test |
refactor: [description]/audit to verify no dead code or new issuesまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Run comprehensive code audit for architecture, dead code, and test quality. Use when reviewing overall codebase health, checking for architectural violations, or before marking a feature complete.
日本語の概要は準備中です。原文の説明を表示しています。
Behavior-first feature development — use when building new capabilities, continuing feature work, or when work introduces new state or multiple user flows. Discovers desired behavior through examples and scenarios before implementation. Do NOT use for bug fixes, typos, or small isolated changes.
日本語の概要は準備中です。原文の説明を表示しています。
Use when the user wants to explore options, weigh approaches, or think through uncertainty before committing to a direction. Collaborative brainstorming and rubber ducking — divergence-first thinking partner.
日本語の概要は準備中です。原文の説明を表示しています。
Kill zombie dev servers and test processes. Use when ports are blocked, processes are hanging, or test runners won't start.
日本語の概要は準備中です。原文の説明を表示しています。
Root cause debugging before fixes. Use when investigating bugs, diagnosing test failures, troubleshooting unexpected behavior, or when previous fix attempts failed. Enforces investigate-first discipline.
日本語の概要は準備中です。原文の説明を表示しています。
Extract tacit knowledge through non-obvious microquestions — things only the user knows that can't be found in code, docs, or research. Use when you're about to guess at intent, context, or constraints during SAFEWORD's understanding flow. Also use when user says 'ask me', 'what do you need to know', or when another skill (bdd, brainstorm, debug) needs user context before proceeding. Do NOT use for questions answerable by reading the codebase or searching the web.
日本語の概要は準備中です。原文の説明を表示しています。