From praxis
Refactoring process with test safety. Invoke immediately when user or document mentions refactoring, or proactively when code gets too complex or messy.
How this skill is triggered — by the user, by Claude, or both
Slash command
/praxis:refactorThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Work autonomously as much as possible. Start with the simplest thing or file and proceed to the more complex ones.
Work autonomously as much as possible. Start with the simplest thing or file and proceed to the more complex ones.
Do not change test code during refactoring, except:
Never change test assertions, test data, or test logic.
.light/REFACTORING_SUMMARY.md in the project root with the following initial content:
# Refactoring Summary
## Baseline
- Files in scope: {list of files}
- Test result: {PASS/FAIL with test count}
## Steps
Prefer self-explanatory, readable code over comments.
Example — extract method and rename variable:
Before:
// apply discount
const x = order.items.reduce((sum, i) => sum + i.price, 0);
return x * (1 - order.dc);
After:
const subtotal = sumItemPrices(order.items);
return subtotal * (1 - order.discountRate);
function sumItemPrices(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
Example — remove dead code and use domain language:
Before:
function process(u, t) {
// TODO: remove legacy path
if (false) { return legacyProcess(u, t); }
return chargeCard(u.card, t.amount);
}
After:
function processPayment(user, transaction) {
return chargeCard(user.card, transaction.amount);
}
For each refactor:
.light/REFACTORING_SUMMARY.md:
### Step {N}: {refactoring description}
- Commit: `- r {message}`
- Test result: {PASS with test count}
- Files changed: {list}
When you see no more obvious refactoring opportunities, say "Entering final evaluation."
Shift focus: you've been implementing. Now become a critic. Your job is to find problems, not produce code.
Re-read Code Style guidelines. Look at each file in scope. Consider blind spots - what improvements haven't we even considered that would make the code better, easier, more maintainable?
For each file, find ONE thing that could be better. If you find something:
Repeat until you find nothing more to improve.
Provide a high-level summary of the refactoring:
Append a final section to .light/REFACTORING_SUMMARY.md:
## Final
- Total steps: {N}
- Files touched: {list of all files changed}
- All commits: {list of commit messages}
- Final test result: {PASS with test count}
This skill was originally adapted from Lada Kessler's AI augmented patterns, which was built upon Llewellyn Falco's refactoring process. See credits.md for attribution.
npx claudepluginhub 8thlight/lightfactory --plugin praxisSafely refactors code with test coverage: writes tests first if absent, plans changes, applies small testable steps, verifies tests/lint/typecheck pass without behavior changes.
Safe, test-gated refactoring methodology: behavior-preserving transformations (extract, inline, rename, move, simplify, delete) enforced with full test runs before, during, and after each change.
Enforces rigid pre-refactor checklist: read existing code, verify covering tests pass, state goal clearly, validate non-ego motivation, plan smallest first step. Use before restructures, renames, or cleanups.