Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tomevault-io/skills-registry --skill refactor-audit명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | refactor-audit |
| description | > Use when this capability is needed. |
Systematic codebase audit and refactoring plan generator. Run periodically to identify and reduce tech debt.
Before doing any analysis, ask the user for these inputs. Present them as questions, don't assume defaults silently.
Ask: "What should I audit?"
Accept any of:
packages/server/modules/auth)@speckle/viewer)src/components/**)If the user gives a vague answer like "the auth stuff", use grep/find to locate the relevant directories and confirm with them before proceeding.
Ask: "How detailed should the refactoring plan be?"
Two modes:
| Mode | When to use | What you produce |
|---|---|---|
| Subtask | Plan will be split into subtasks for a ralph loop or multiple agent sessions | High-level task descriptions with context, goals, and acceptance criteria. Subtask agents will do their own file-level research. |
| Execution | You or the user will implement changes immediately in this session | Precise file paths, function names, line ranges, exact changes to make, and execution order. Like plan mode output. |
Ask: "Run all checks or focus on specific areas?"
Default is all. If the user wants to focus, let them pick from:
Gather context about the target scope before analyzing anything.
# File inventory
find <scope> -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.vue" -o -name "*.js" -o -name "*.jsx" -o -name "*.py" \) | head -200
# Size distribution — find the big files first
find <scope> -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.vue" \) -exec wc -l {} \; | sort -rn | head -30
# Directory structure (2 levels)
find <scope> -type d -maxdepth 3 | head -50
Detect what's available in the project. Check for:
pnpm-lock.yaml, yarn.lock, package-lock.json, poetry.lock.eslintrc*, eslint.config.*, .prettierrc*, biome.json, ruff.tomlvitest.config.*, jest.config.*, playwright.config.*, pytest.ini, pyproject.tomltsconfig.json, pyrightconfig.json, mypy.inivite.config.*, nuxt.config.*, webpack.config.*, rollup.config.*pnpm-workspace.yaml, lerna.json, nx.json, turbo.jsonRecord what's present — you'll use these tools in Phase 2.
Check for: <% if (target === 'claude') { -%>
CLAUDE.md / .claude/rules/ — project-level AI instructions.claude/skills/ — reusable AI workflows and slash commands
<% } else if (target === 'copilot') { -%>.github/copilot-instructions.md / .github/instructions/ — project-level AI instructions.github/skills/ — reusable AI workflows and slash commands
<% } else if (target === 'cursor') { -%>.cursor/rules/ — project-level AI instructions.cursor/skills/ — reusable AI workflows and slash commands
<% } else { -%>CONTRIBUTING.md — team conventions.editorconfigNote any project-specific patterns or conventions so your recommendations don't fight the existing codebase style.
If git is available:
# Most frequently changed files (last 3 months) — high churn = high debt risk
git log --since="3 months ago" --name-only --pretty=format: -- <scope> | sort | uniq -c | sort -rn | head -20
# Files with the most authors — coordination cost indicator
git log --since="6 months ago" --pretty=format:%an -- <scope> | sort | uniq -c | sort -rn | head -10
Run each enabled audit category. For each finding, record:
Goal: Find code that can be deleted with zero behavior change.
Techniques:
eslint --rule 'no-unused-vars: error', ruff check --select F811,F401)# For each export, grep for imports of that symbol across the scope
grep -rn "export " <scope> --include="*.ts" | while read line; do
symbol=$(echo "$line" | grep -oP '(?<=export (const|function|class|type|interface|enum) )\w+')
if [ -n "$symbol" ]; then
count=$(grep -rn "import.*${symbol}" <scope> --include="*.ts" --include="*.vue" | wc -l)
if [ "$count" -eq 0 ]; then echo "UNUSED EXPORT: $symbol in $line"; fi
fi
done
Severity guide:
Goal: Find functions and components that are too complex to maintain safely.
Techniques:
ref()/reactive() declarations (extract composable)Prioritization formula:
(lines / 100) + (branch_count × 0.5) + (nesting_depth × 2)
Score >5 = HIGH priority for refactoring.
Goal: Find duplicated logic that should be consolidated.
Techniques:
# Find suspiciously similar functions
grep -rn "function\|const.*=.*=>" <scope> --include="*.ts" | \
awk -F: '{print $1}' | sort | uniq -c | sort -rn | head -20
Important distinction: Structural similarity is NOT always a DRY violation. Two functions that look alike but serve different domains should stay separate. Only flag duplication where the logic is genuinely shared knowledge.
Severity guide:
Goal: Find outdated, vulnerable, or unnecessary dependencies.
Techniques:
pnpm outdated or check package.json for pinned ancient versionsaxios and fetch wrappers)Severity guide:
npm audit / pnpm audit available, run it)Goal: Find places where TypeScript's type system is being bypassed.
Techniques:
# Count type safety escapes
grep -rn "as any\|: any\|<any>" <scope> --include="*.ts" --include="*.tsx" --include="*.vue" | wc -l
# Find specific occurrences
grep -rn "as any" <scope> --include="*.ts" --include="*.vue"
grep -rn ": any" <scope> --include="*.ts" --include="*.vue"
grep -rn "@ts-ignore\|@ts-expect-error\|@ts-nocheck" <scope> --include="*.ts" --include="*.vue"
grep -rn "eslint-disable.*@typescript" <scope> --include="*.ts" --include="*.vue"
# Non-null assertions (risky)
grep -rn "!\." <scope> --include="*.ts" --include="*.vue" | grep -v "!=\|!=="
Object or {} as types, excessive use of type assertionstsconfig.json for permissive settings (strict: false, noImplicitAny: false)Severity guide:
any in function signatures (spreads through the call chain), @ts-nocheck on entire filesas any type assertions, non-null assertions in complex logic@ts-expect-error with explanation comments (at least they're documented)Goal: Find critical code paths that lack test coverage.
Techniques:
vitest --coverage, jest --coverage, pytest --cov# Find source files with no corresponding test file
find <scope> -name "*.ts" -not -name "*.test.*" -not -name "*.spec.*" -not -path "*/node_modules/*" | while read src; do
base=$(basename "$src" .ts)
test_count=$(find <scope> -name "${base}.test.*" -o -name "${base}.spec.*" | wc -l)
if [ "$test_count" -eq 0 ]; then echo "NO TESTS: $src"; fi
done
Severity guide:
Goal: Find structural problems that make the codebase hard to change.
Techniques:
# Quick circular dependency check
# For each file, check if any of its imports also import it back
grep -rn "^import" <scope> --include="*.ts" | grep -v node_modules
(Or use madge --circular if available)# Most-imported files
grep -rn "from.*['\"]" <scope> --include="*.ts" --include="*.vue" | \
grep -oP "from ['\"]([^'\"]+)['\"]" | sort | uniq -c | sort -rn | head -20
index.ts files that re-export everything, causing import cycle risks and bundle bloatSeverity guide:
Goal: Find patterns that could lead to security issues.
Techniques:
# Hardcoded secrets
grep -rn "password\|secret\|api_key\|apikey\|token\|private_key" <scope> --include="*.ts" --include="*.vue" | grep -v "test\|spec\|mock\|\.d\.ts\|type\|interface"
# SQL/NoSQL injection risks
grep -rn "query.*\`\|execute.*\`\|raw.*\`" <scope> --include="*.ts"
# XSS risks
grep -rn "innerHTML\|dangerouslySetInnerHTML\|v-html" <scope> --include="*.ts" --include="*.vue" --include="*.tsx"
# Eval and friends
grep -rn "eval(\|new Function(\|setTimeout.*['\"]" <scope> --include="*.ts" --include="*.js"
# Unvalidated user input going into file paths, commands, URLs
grep -rn "exec(\|execSync(\|spawn(" <scope> --include="*.ts"
Access-Control-Allow-Origin: *)Severity guide:
v-html with sanitized content (still worth noting)Goal: Find names that mislead or confuse.
Techniques:
is/has/can/should/willgetX that has side effects, or isX that returns non-booleanmgr, proc, val, tmp, cb)data, info, result, item, stuff, thing, handler, manager, service, utils, helpersSeverity guide:
After all checks complete, sort all findings into a prioritized list.
For each finding, compute:
priority_score = severity_weight + effort_bonus + churn_bonus + coupling_bonus
severity_weight:
CRITICAL = 10
HIGH = 7
MEDIUM = 4
LOW = 1
effort_bonus (favor quick wins):
S (< 30 min) = +3
M (30 min–2 hr) = +1
L (2+ hr) = +0
churn_bonus (if git data available):
File changed >10 times in 3 months = +3
File changed 5–10 times = +1
File changed <5 times = +0
coupling_bonus (more importers = higher risk):
>15 importers = +3
5–15 importers = +1
<5 importers = +0
Sort descending by priority_score. Group into tiers:
Generate the refactoring plan in the requested detail level.
For each tier (starting from Tier 1), generate task descriptions like:
## Task: [short descriptive title]
**Category:** [which audit category]
**Tier:** [1-4]
**Estimated effort:** [S/M/L]
**Findings addressed:** [count]
### Context
[2-3 sentences explaining what the problem is and why it matters.
Include enough info for a fresh agent session to understand the situation.]
### Goal
[1-2 sentences on what "done" looks like]
### Scope
[List the files/directories involved — just names, the executing agent will read them]
### Acceptance criteria
- [ ] [Specific, verifiable criterion]
- [ ] [Another criterion]
- [ ] All existing tests still pass
- [ ] No new lint errors introduced
Group related findings into single tasks where they touch the same files. Aim for tasks that take 15-60 minutes each. Split anything larger.
For each tier, generate precise instructions:
## Refactoring: [short title]
**Priority score:** [X] | **Severity:** [X] | **Effort:** [S/M/L]
### Changes
1. **`path/to/file.ts` (lines 45-78):**
- Extract the nested if/else block in `processPayment()` into a separate
`validatePaymentMethod(method: PaymentMethod): ValidationResult` function
- Move it to `path/to/payment-validation.ts`
- Update imports in `path/to/file.ts` and `path/to/other-consumer.ts`
2. **`path/to/another-file.ts` (lines 12-15):**
- Replace `as any` with proper generic: `Record<string, PaymentConfig>`
- The type definition exists in `path/to/types.ts` line 34
### Verification
- Run: `pnpm test --filter @scope/package`
- Run: `pnpm typecheck`
- Confirm no new lint errors: `pnpm lint`
After the plan is generated, present a brief summary:
## Audit Summary
**Scope:** [what was analyzed]
**Files scanned:** [count]
**Total findings:** [count]
**Breakdown:**
- Tier 1 (critical): [count] findings → [count] tasks
- Tier 2 (high): [count] findings → [count] tasks
- Tier 3 (medium): [count] findings → [count] tasks
- Tier 4 (low): [count] findings → [count] tasks
**Top 3 systemic issues:**
1. [Pattern that appears across multiple findings]
2. [Another pattern]
3. [Another pattern]
**Quick wins (< 30 min, high impact):**
- [Task name] — [one-line description]
- [Task name] — [one-line description]
**Estimated total effort:** [rough range in hours]
These principles guide the analysis. When in conflict, earlier items take precedence:
Converted and distributed by TomeVault — claim your Tome and manage your conversions.