/everything-copilot-cli:refactor-cleanfrom everything-copilot-cli
Guides incremental code cleanup: extract functions, remove duplication, rename, and reduce nesting while preserving behavior. Use when code is correct but messy.
Ships in everything-copilot-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
# Find long files (likely doing too much)
Get-ChildItem -Recurse -Include *.ts,*.js,*.py,*.go | Where-Object { (Get-Content $_.FullName | Measure-Object -Line).Lines -gt 300 } | Select-Object FullName, @{N='Lines';E={(Get-Content $_.FullName | Measure-Object -Line).Lines}}
# Find duplicated string patterns
grep -rn "pattern-you-suspect-is-duplicated" src/ --include="*.ts"
# Find functions with too many parameters (>4 is a smell)
grep -n "function.*,.*,.*,.*," src/**/*.ts
Common smells to look for:
# Run existing tests and record baseline
npm test 2>&1 | Tee-Object -Variable baseline
echo $baseline | Select-Object -Last 5
# If coverage is low, write characterization tests first
npm test -- --coverage --collectCoverageFrom="src/module-to-refactor.ts"
Before touching code, decide on the transformation:
Each change should be:
# After each refactoring step
npm test 2>&1 | Select-Object -Last 10
# If tests break, revert and try a smaller step
git checkout -- src/module-to-refactor.ts
# Full test suite must still pass
npm test
# Compare coverage — it should not decrease
npm test -- --coverage
When the code to clean is the current PR or working-tree change rather than old code, cut it down
to the smallest correct diff (concept adapted from antfu/skills antfu-simplify):
git diff --stat before and after.Cut speculative options, pass-through wrappers, one-use helpers, and guards against impossible input. Keep handling for real edge cases and the general fix over a special case.
// BEFORE: duplicated validation in multiple handlers
function createUser(data) {
if (!data.email || !data.email.includes('@')) throw new Error('Invalid email');
// ... create logic
}
function updateUser(data) {
if (!data.email || !data.email.includes('@')) throw new Error('Invalid email');
// ... update logic
}
// AFTER: extracted to a shared validator
function validateEmail(email: string): void {
if (!email || !email.includes('@')) throw new Error('Invalid email');
}
function createUser(data) { validateEmail(data.email); /* ... */ }
function updateUser(data) { validateEmail(data.email); /* ... */ }
// BEFORE
function process(input) {
if (input) {
if (input.isValid) {
if (input.data.length > 0) {
return transform(input.data);
}
}
}
return null;
}
// AFTER
function process(input) {
if (!input || !input.isValid || input.data.length === 0) return null;
return transform(input.data);
}
| Rationalization | Reality |
|---|---|
| "I'm not sure what this code does, but it looks unused" | If you're not sure, don't remove it. Use git blame to understand the context first. (Chesterton's Fence) |
| "I'll add a feature while refactoring" | Separate refactoring from feature work. Mixing the two makes debugging impossible. |
| "Tests still pass, so the refactor is correct" | Tests must exist before refactoring to have any meaning. If not, write them first. |
| "TypeScript isn't warning, so it's safe to delete" | Dynamic imports, reflection, and external references are invisible to the type system. |
// @ts-ignore or any typesnpm test passes identically before and after the refactorgrep -rn or IDE reference search)refactor:)explore agent to understand call graphs before renaming or moving functionsgrep to find all callers before changing a function signaturegrep and remove itWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub drvoss/everything-copilot-cli --plugin everything-copilot-cli115 skills in this plugin
/actions-debuggingUse when a GitHub Actions workflow fails — diagnose the run log, identify the root cause, and apply a targeted fix/add-to-changelogUse when you've shipped a feature, fix, or breaking change and need to update CHANGELOG.md — follows Keep a Changelog format and syncs version numbers across package manifests./agent-governanceUse when designing or reviewing an AI agent system that needs policy-based access controls, intent classification, tool-level rate limiting, trust scoring for multi-agent workflows, or append-only audit trails.
Other plugins' skills for the same job