agentleFS
roborracleroborracle/agent-workflow-kit/skills/code-cleanup-guardian/SKILL.md

code-cleanup-guardian

Skill0 starsChanged 3 months agoMITView on GitHub

Safely refactor and clean up code without breaking existing functionality. Use when doing any code cleanup, refactoring, formatting, removing dead code, or restructuring files. Prevents regression by enforcing incremental changes and mandatory testing.

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before starting, classify the cleanup scope:

    line 13
  2. Distinctive:

    Test after each caller redirect

    line 29
  3. Distinctive:

    Remove original only after all callers migrated and tests pass

    line 30
  4. Distinctive:

    Check string literals, config files, and dynamic references

    line 36
  5. Distinctive:

    Check for reflection, dynamic dispatch, or string-based references

    line 41
  6. Distinctive:

    Check test files — remove test coverage for dead code too

    line 42
  7. Distinctive:

    Remove in a dedicated commit with clear message

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Cleanup Guardian

Core safety protocol is in ~/.claude/rules/code-cleanup-safety.md. This skill adds tactical guidance.

Refactoring Assessment

Before starting, classify the cleanup scope:

ScopeRiskApproach
Formatting onlyLowAutoformat, single commit, verify no logic diff
Rename/moveMediumUpdate all references, verify with grep, test
Extract function/moduleMediumEnsure identical behavior, compare outputs
Change data flowHighWrite characterization tests first, then refactor
Remove feature/code pathHighProve zero references, check feature flags, test

Refactoring Workflows

Extract & Split

  1. Identify the boundary (function, class, module)
  2. Copy to new location — do NOT cut yet
  3. Redirect callers to new location one at a time
  4. Test after each caller redirect
  5. Remove original only after all callers migrated and tests pass

Safe Rename

  1. grep -r "oldName" src/ — count all references
  2. Rename with IDE refactor tool or find-and-replace
  3. grep -r "oldName" src/ — confirm zero references remain
  4. Check string literals, config files, and dynamic references
  5. Test

Dead Code Removal

  1. grep -rn "targetName" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" --include="*.py" --include="*.php" . (grep does not expand {a,b} braces inside --include)
  2. Check for reflection, dynamic dispatch, or string-based references
  3. Check test files — remove test coverage for dead code too
  4. Remove in a dedicated commit with clear message

Recovery Protocol

SituationAction
Tests fail after one commitgit revert HEAD
Tests fail after multiple commitsgit log --oneline, find last green, git revert HEAD~N..HEAD
Uncertain what brokegit bisect start, git bisect bad, git bisect good <known-good>
Everything is brokenLast resort, and only after the user confirms: it discards all local commits and uncommitted work. Show git status and git log origin/main..HEAD first, then git reset --hard origin/main

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.