agentleFS
ImNotTheWolfOfficialImNotTheWolfOfficial/auto-master-skills/skills/master-refactor/SKILL.md

master-refactor

Skill15 starsChanged 4 months agoMITView on GitHub

Plan and execute safe behavior-preserving refactors for authorized local projects. Use for Master-Refactor, repo or feature cleanup, code simplification, periodic maintenance sweeps, optimization candidates, or refactor planning. Starts with measured analysis and a ranked candidate report, requires approval before code, then uses isolated slices, characterization tests, execution receipts, and regression deltas.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 6 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start analysis-only. Stop after the ranked candidate report and wait for the user to select scope.

    line 12
  2. Distinctive:

    Read the refactor log first.

    line 14
  3. Distinctive:

    Add characterization tests before moving weakly covered behavior.

    line 16
  4. Distinctive:

    If implementation changes behavior, eject it into a separate Auto proposal with RED -> GREEN acceptance proof.

    line 17
  5. Very specific:

    Run auto-qa per slice and at the end.

    line 20
  6. Very specific:

    Research: - use auto-research or a lean inline map.

    line 28
  7. Very specific:

    Plan: - use auto-plan on the approved set.

    line 31
  8. Distinctive:

    Isolate: - create the approved dedicated branch/worktree.

    line 32
  9. Very specific:

    Execute: - use auto-pilot, one bounded slice at a time.

    line 33
  10. Very specific:

    Verify: - use auto-qa per slice and a full integrated pass.

    line 34
  11. Distinctive:

    Merge: - only after completion, clean QA, and explicit user approval.

    line 35
  12. Very specific:

    Read references/workflow.md before starting.

    line 42
  13. Very specific:

    Read references/candidate-report.md before presenting options.

    line 43
  14. Very specific:

    Read references/baselines-and-metrics.md before measurement.

    line 44
  15. Very specific:

    Read references/isolation-and-qa.md before implementation.

    line 45
  16. Very specific:

    Read references/refactor-log.md before log access.

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Master-Refactor

Find, approve, implement, and verify refactors that make code leaner without changing observable behavior.

Core Rules

  • Start analysis-only. Stop after the ranked candidate report and wait for the user to select scope; no planning or code skips this gate.
  • In maintenance mode, rank a bounded top set by value/risk and record the rest in the log. Never automatically delete, rewrite, or "clean everything."
  • Read the refactor log first. Do not re-propose rejected work without new evidence.
  • Capture the baseline commit, dirty state, relevant metrics, existing gates, and UI screenshots before implementation.
  • Add characterization tests before moving weakly covered behavior. They must pass before and after a behavior-preserving refactor; do not manufacture RED for structural-only work.
  • If implementation changes behavior, eject it into a separate Auto proposal with RED -> GREEN acceptance proof.
  • Implement only in an isolated owned branch/worktree; never on main/master.
  • Require execution receipts and a regression delta for each slice and the final set.
  • Run auto-qa per slice and at the end; every UI-visible slice requires the Frontend Gate.
  • Merge only after the entire approved set is complete, QA-clean, and explicitly approved.
  • Store reports under ~/.auto-master/artifacts/<project-slug>/refactor/.
  • Preserve unrelated work; do not destructively clean or print secrets.

Pipeline

  1. Startup - confirm repo/branch/worktree; read the log; define scope and expected audit outputs.
  2. Research - use auto-research or a lean inline map; trace dependents, coverage, hot paths, and existing conventions.
  3. Baseline - capture git, metrics, gates, and UI state.
  4. Candidate report + STOP - rank recommended/optional/not-recommended candidates and wait for selection.
  5. Plan - use auto-plan on the approved set; classify slices Micro/Small/Full.
  6. Isolate - create the approved dedicated branch/worktree.
  7. Execute - use auto-pilot, one bounded slice at a time. Keep characterization tests green before/after and receipts current.
  8. Verify - use auto-qa per slice and a full integrated pass; compare every after-signal with baseline.
  9. Merge - only after completion, clean QA, and explicit user approval.
  10. Log - append outcomes, regression deltas, confirmed failures, rejected ideas, and do-not-retry evidence.

For multi-phase refactors, auto-manage owns the queue. Honor its five-attempt circuit breaker: after the same failure twice, diagnose or shrink the slice; never continue blind retries.

References

  • Read references/workflow.md before starting.
  • Read references/candidate-report.md before presenting options.
  • Read references/baselines-and-metrics.md before measurement.
  • Read references/isolation-and-qa.md before implementation.
  • Read references/refactor-log.md before log access.

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.