agentleFS
aloiloraloilor/lean-coding-agent/skills/workflow-refactor/SKILL.md

workflow-refactor

Skill7 starsChanged 47 days agoMITView on GitHub

Workflow for behavior-preserving restructuring, from local cleanup through complex refactors.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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:

    Use this workflow for clear, small, localized refactors and complex behavior-preserving restructuring.

    line 9

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

Use this workflow for clear, small, localized refactors and complex behavior-preserving restructuring. The approved plan records the behavior and contracts to preserve, scope, risks, documentation impact, and verification needed for the work. Every run produces the standard durable plan, implementation report, and review pass artifacts.

The main agent orchestrates this workflow and owns user communication and closeout. Follow the shared scaffolding in AGENTS.md — Workflow Delegation, Standard Artifacts, and Shared Stop Conditions.

Steps

  1. Plan and approve. Spawn planner with the request and this workflow's planning requirements. The plan records current behavior and contracts to preserve, boundaries, baseline and post-refactor verification, behavior-drift and rollback risks, and documentation impact. The main agent obtains explicit user approval before implementation. If the work reveals behavior change, stop and request user direction; do not switch workflows automatically.
  2. Establish the baseline and refactor in green steps. After plan approval, spawn implementer with the approved plan. Apply $refactor and the test-strategy guidance from $tdd. Run focused tests before restructuring; add characterization tests when behavior to preserve is uncovered. Make one small behavior-preserving change at a time and rerun focused tests after each meaningful step. The implementer records its TDD, baseline, documentation, and verification evidence in .agents/implementation-reports/implementation_YYYYMMDD_<name>.md.
  3. Review independently. Spawn code-reviewer with the approved plan, implementation report, touched files, tests, and verification evidence. The reviewer checks behavior drift, scope creep, missed tests, unnecessary abstraction, code smells, and documentation staleness. Missing or stale required documentation is a BLOCK. Each review pass is recorded under .agents/code-reviews/review_YYYYMMDD_<name>_pass_N.md.
  4. Resolve and verify. On BLOCK, send only the concrete findings back to implementer, preserve the approved plan, rerun focused checks, and repeat review until APPROVE or a Shared Stop Condition triggers. Treat WARNING as actionable when tied to the plan, behavior drift, or a meaningful test gap. Run broader final verification whenever shared behavior, API contracts, persistence, auth, security, or user-facing workflows are touched.

In the final response, identify the artifact paths, independent reviewer verdict, and main-agent closeout review. Report the preserved behavior, structural improvement, exact verification results, residual risks, and omissions.

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.