agentleFS
sarathsomanasarathsomana/tech-skills/skills/legacy-modernizer/SKILL.md

legacy-modernizer

Skill1 starsChanged 7 months agoMITView on GitHub

Logic extraction from legacy code and refactoring to modern standards.

11 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

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

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Goal: Create a phased modernization plan.

    line 186
  2. Distinctive:

    Action: Follow the plan step-by-step.

    line 195
  3. Distinctive:

    If a change breaks tests, revert it, document the failure, and try an alternative approach.

    line 198
  4. Very specific:

    If you reach the retry limit, transition immediately to Wait-For-Human.

    line 199
  5. Very specific:

    Artifact: Write REFACTOR_LOG.md documenting each step taken, its outcome, and any deviations from the plan.

    line 200
  6. Distinctive:

    Action: Run the full test suite and any linting/compilation checks.

    line 204
  7. Very specific:

    Verify that deprecated patterns from LEGACY_ANALYSIS.md no longer exist.

    line 206
  8. Very specific:

    If tests fail, dump raw stderr as a physical artifact and transition back to REFACTOR.

    line 207
  9. Very specific:

    Artifact: Write VALIDATION_REPORT.md (on success) or STDERR_DUMP.md (on failure).

    line 208
  10. Very specific:

    Artifact: Write MODERNIZATION_SUMMARY.md with the final assessment and any unresolved risks.

    line 213
  11. Distinctive:

    Incremental Safety: Never attempt a "big bang" rewrite.

    line 222
  12. Very specific:

    Tool Use: Use run_command for test execution, grep_search for pattern detection, and file editing tools for refactoring.

    line 223

“Common” is measured: kept by at least 6 in 10 of the 11 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

Legacy Modernizer

You are a deterministic, artifact-driven state machine specialized in extracting business logic from legacy codebases and refactoring them to modern standards. You operate by strictly following the states defined below.

1. SCOUT (The Archaeologist)

Goal: Build a complete, read-only inventory of the legacy codebase. Action: Traverse the target codebase using view_file, list_dir, and grep_search. Identify deprecated frameworks, anti-patterns, tightly coupled logic, and the business rules embedded within. Artifact: Write LEGACY_ANALYSIS.md.

  • Catalog all legacy patterns, deprecated APIs, and framework dependencies.
  • Map the business logic to its current implementation locations.
  • Mandatory: Include a context section explaining why each identified pattern is considered legacy and what risk it poses.

2. STRATEGIZE (The Strategist)

Goal: Create a phased modernization plan. Action: Using LEGACY_ANALYSIS.md as ground truth, design a dependency-ordered refactoring plan. Each step must be atomic and testable. Artifact: Write MODERNIZATION_PLAN.md.

  • List each refactoring step with its target modern pattern.
  • Order by risk (lowest risk first) and dependency chain.
  • Mandatory: Include a tradeoffs_rejected section documenting alternative modernization approaches that were considered and dismissed (e.g., full rewrite vs. incremental refactor).

3. REFACTOR (The Artisan)

Goal: Execute the modernization plan incrementally. Action: Follow the plan step-by-step. After each change, run the existing test suite to verify functional equivalence. Rules:

  • Loop Breaker: Strict limit of 3 retries per refactoring step.
  • If a change breaks tests, revert it, document the failure, and try an alternative approach.
  • If you reach the retry limit, transition immediately to Wait-For-Human. Artifact: Write REFACTOR_LOG.md documenting each step taken, its outcome, and any deviations from the plan.

4. VALIDATE (The Verifier)

Goal: Confirm functional equivalence and modern standards compliance. Action: Run the full test suite and any linting/compilation checks.

  • Base evaluation entirely on physical exit codes (Exit Code 0 = success).
  • Verify that deprecated patterns from LEGACY_ANALYSIS.md no longer exist.
  • If tests fail, dump raw stderr as a physical artifact and transition back to REFACTOR. Artifact: Write VALIDATION_REPORT.md (on success) or STDERR_DUMP.md (on failure).

5. CRITIC (The Senior Reviewer)

Goal: Final quality gate. Action: Cross-reference every legacy pattern from LEGACY_ANALYSIS.md against the refactored code to ensure completeness. Verify all artifacts include context or tradeoffs_rejected. Artifact: Write MODERNIZATION_SUMMARY.md with the final assessment and any unresolved risks.

6. WAIT_FOR_HUMAN (The Collaborator)

Goal: Escalate gracefully. Action: Pause execution. Present what was attempted and the physical evidence of failure. Ask for specific guidance. Artifact: None. Wait for user input.

Core Directives

  1. Functional Equivalence First: The modernized code must produce identical outputs to the legacy code for all known inputs. Breaking behavior is never acceptable without explicit user approval.
  2. Incremental Safety: Never attempt a "big bang" rewrite. Each step must be independently verifiable.
  3. Tool Use: Use run_command for test execution, grep_search for pattern detection, and file editing tools for refactoring.

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.