agentleFS
nelantonenelantone/cognivia/.agents/skills/safe-refactor/SKILL.md

safe-refactor

Skill1 starsChanged 2 months agoMITView on GitHub

Plan and execute one small behavior-preserving refactor phase with local dependency mapping, compatibility, rollback, validation, and commit boundaries. Use for approved extractions, module splits, dependency untangling, or test migration. Do not use to generate a broad architecture inventory, redesign UX or behavior, add features, update docs only, or create commits.

26 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use verify-and-stop, investigate-first and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • JuliusBrusseeSkill

    verify-and-stop

    Prove existing work meets acceptance conditions without expanding scope. Use for validation-only tasks, completion checks, focused gate runs, and last-mile proof.

    Also in 8 projects that use this

  • JuliusBrusseeSkill

    investigate-first

    Diagnose ambiguous failures before editing. Use for unknown causes, intermittent behavior, performance regressions, or investigations needing evidence-ranked hypotheses.

    Also in 7 projects that use this

  • +10 more from JuliusBrussee

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use after the refactor scope and behavior contract are approved.

    line 15
  2. Very specific:

    Do not use to discover the whole architecture, redesign product behavior, make visual changes, implement unrelated cleanup, or prepare …

    line 21
  3. Distinctive:

    Run the scope-appropriate validation ladder and inspect the complete diff.

    line 45
  4. Distinctive:

    Do not combine architecture movement with UX changes or speculative cleanup.

    line 59
  5. Distinctive:

    Do not let parallel agents edit the same working tree.

    line 60
  6. Distinctive:

    Do not hide failures or alter unrelated code to make validation pass.

    line 61
  7. Distinctive:

    Do not claim browser behavior from unit tests or Streamlit AppTests alone.

    line 62
  8. Distinctive:

    Do not stage, commit, push, reset, discard, or delete compatibility paths without explicit authorization.

    line 63
  9. Distinctive:

    Follow the task-specific ladder in AGENTS.md, starting with focused tests.

    line 68
  10. Distinctive:

    Verify compatibility before removing an old import, path, or test boundary.

    line 69
  11. Distinctive:

    Keep automated, manual, browser, and provider evidence distinct.

    line 70
  12. Distinctive:

    Stop the phase when required validation fails and report the blocker.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 24 edited versions of this file we could read. “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

Safe Refactor

Purpose

Move one coherent responsibility while preserving observable behavior and keeping rollback straightforward.

Trigger

Use after the refactor scope and behavior contract are approved. Use an existing architecture audit when the change crosses boundaries or the dependency map is not already known.

Do not trigger

Do not use to discover the whole architecture, redesign product behavior, make visual changes, implement unrelated cleanup, or prepare commits. Use architecture-audit first when a broad inventory is still required.

Inputs

  • Approved objective, phase, file scope, and non-goals.
  • Current behavior contract and compatibility constraints.
  • Relevant architecture/dependency evidence.
  • Characterization or regression tests and required manual checks.
  • Validation ladder and rollback point.

Workflow

  1. Confirm branch state, approved scope, protected areas, and current behavior.
  2. Map only the dependencies touched by this phase; do not expand into a new architecture audit.
  3. Capture invariants, including Streamlit rerun, callback, widget identity, and session-state semantics when applicable.
  4. Define one extraction boundary and its temporary compatibility mechanism.
  5. Move the smallest coherent responsibility without UX, schema, provider, persistence, or domain changes outside the approved task.
  6. Move or add tests with the behavior they protect; retain characterization coverage until the new boundary is proven.
  7. Run the scope-appropriate validation ladder and inspect the complete diff.
  8. Report rollback instructions and logical commit boundaries. Do not stage or commit without separate authorization.

Outputs

Return the implemented phase, preserved behavior, compatibility path, tests, validation evidence, risks, rollback point, and commit boundary. Use the refactor phase checklist for multi-step work.

Safety

  • Preserve behavior unless the approved task explicitly changes it.
  • Do not combine architecture movement with UX changes or speculative cleanup.
  • Do not let parallel agents edit the same working tree.
  • Do not hide failures or alter unrelated code to make validation pass.
  • Do not claim browser behavior from unit tests or Streamlit AppTests alone.
  • Do not stage, commit, push, reset, discard, or delete compatibility paths without explicit authorization.

Validation

  • Follow the task-specific ladder in AGENTS.md, starting with focused tests.
  • Verify compatibility before removing an old import, path, or test boundary.
  • Keep automated, manual, browser, and provider evidence distinct.
  • Stop the phase when required validation fails and report the blocker.
  • Review staged scope later with commit-review when requested.

References

  • AGENTS.md — behavior, Git, and validation rules.
  • architecture-audit — broad inventory that must precede this skill when dependencies are not known.
  • Refactor phase checklist — phase contract and rollback format.

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.