legacy-code

Guide incremental legacy codebase improvement with characterization tests and refactoring strategies.

Updated Jun 19, 2023
One-click install
npx skills add https://github.com/JeroenJochems/modelwise --skill legacy-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: legacy-code
Source: https://github.com/JeroenJochems/modelwise/tree/main/.claude/skills/legacy-code
Command: npx skills add https://github.com/JeroenJochems/modelwise --skill legacy-code

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a structured approach to incrementally improve and maintain legacy codebases, reducing the risk of introducing bugs and ensuring stability.

Core Features & Use Cases

  • Incremental Improvement: Apply techniques like the Boy Scout Rule for continuous small enhancements.
  • Risk Mitigation: Use characterization tests and seams to safely refactor or add features to untested code.
  • Use Case: You need to fix a bug in a critical, but poorly tested, legacy system. This Skill guides you through writing characterization tests to understand its current behavior before you make the fix, ensuring you don't break anything else.

Quick Start

Use the legacy-code skill to write characterization tests for the function process_legacy_data in the file src/legacy/processor.php.

Frequently Asked Questions about legacy-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely refactor legacy code without breaking existing functionality?

To safely refactor legacy code, you should first write characterization tests to document the system's current behavior, then introduce seams to isolate dependencies, allowing you to modify the code without unintended side effects.

What is the Boy Scout Rule for code maintenance?

The Boy Scout Rule in code maintenance involves leaving the codebase cleaner than you found it by making small, incremental improvements continuously, which incrementally reduces technical debt without requiring large rewrite efforts.

How do I fix a bug in poorly tested legacy systems?

To fix a bug in poorly tested legacy systems, apply characterization tests to capture the exact current outputs before making changes, ensuring your bug fix does not inadvertently break other undocumented behaviors.

What is the best way to add features to a legacy codebase?

The best way to add features to a legacy codebase is to use strangulation patterns and clean module extraction, which allows new functionality to be built separately and gradually replace the old untested components safely.

When should I use a strangulation pattern for code maintenance?

You should use a strangulation pattern for code maintenance when you need to incrementally replace large, critical legacy modules by routing new functionality to modern components while slowly deprecating the old system.

What are characterization tests and when do I need them?

Characterization tests are tests written to document and lock in the actual current behavior of legacy code, and you need them before refactoring or modifying untested systems to prevent regressions.