skills/refactor/SKILL.md
Use when refactoring, cleaning up code, reducing complexity, fixing code smells, or improving code quality. Audits TS/JS for dead code, nesting, and patterns.
npx skillsauth add tartinerlabs/skills refactorInstall 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.
You are an expert code reviewer focused on refactoring.
Read individual rule files in rules/ for detailed explanations and code examples.
| Section | Prefix | Rules |
|---|---|---|
| General Patterns | general- | dead-code, deep-nesting, long-functions, magic-values, boolean-params, duplication |
| TypeScript/JS Idioms | ts- | type-assertions, optional-chaining, nullish-coalescing, barrel-reexports, enum-union, async-await |
| Design Principles | design- | single-responsibility, interface-segregation, god-objects, tight-coupling |
Scan the target scope (specific files, directory, or full codebase) for violations:
General Patterns:
TypeScript/JS Idioms:
as type assertions (excluding test files)&& for null checks where ?. applies|| used for defaults where ?? is saferindex.ts re-export files (hurt tree-shaking, slow bundlers, risk circular deps).then() chains in async codeDesign Principles:
List all findings grouped by category:
## Refactoring Audit Results
### General Patterns
- `src/services/order.ts:45` - Function `processOrder` is 62 lines → extract validation and submission
- `src/utils/helpers.ts:12-18` - Commented-out code block → remove
### TypeScript/JS Idioms
- `src/api/client.ts:23` - `as UserResponse` → add type guard
- `src/config.ts:8` - `port || 3000` → use `??` (port could be 0)
### Design Principles
- `src/services/user.ts` - 14 named exports → split into focused modules
### Summary
| Category | Violations | Files |
|----------------------|------------|-------|
| General Patterns | X | N |
| TypeScript/JS Idioms | Y | N |
| Design Principles | Z | N |
| **Total** | **X+Y+Z** | **N** |
Apply refactorings. For each fix:
development
Use when setting up a project, adding linting, formatting, git hooks, or TypeScript. Installs Biome, Husky, commitlint, lint-staged, and GitLeaks for JS/TS.
testing
Use when auditing security, checking for vulnerabilities, scanning for secrets, or reviewing dependencies. OWASP Top 10 audit with GitLeaks and dependency checks.
testing
Use when adding CI/CD, creating workflows, auditing GitHub Actions, or fixing action pinning. Creates and audits workflows for SHA pinning and permissions.
testing
Use when hardening npm supply chain, pinning dependency versions, adding .npmrc security flags, or setting up Renovate. Locks down install-time scripts, registries, version ranges, and CI checks.