safe-incremental-coding
Build characterization tests before a risky change to untested legacy code. Apply it to preserve existing behavior while making the affected code testable, then hand behavior changes to tdd.
How do I install this agent skill?
npx skills add https://github.com/robsonrung/rar-skills --skill safe-incremental-codingIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides safe, high-level process instructions for refactoring legacy code and contains no malicious code, network requests, or data access patterns.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Safe Incremental Coding
Farley's legacy-change method, aimed at ease of change: protect the behavior a requested change touches, then make that code testable. Stay inside the area the change needs.
Build the net
A characterization test net pins current behavior before any refactoring.
- Find the affected behavior and an observable boundary that exercises it. Prefer an acceptance or integration boundary when unit tests would bind to the current internals.
- Capture current outputs and side effects for representative inputs, including boundary and failure cases. Pin a known defect too; changing it is a separate, intentional step.
- Normalize timestamps, identifiers, and seeds without hiding behavior the change depends on.
- When no boundary exposes the behavior, the first production edit is the minimum observation seam, with business logic untouched. Capture the baseline before any other production change.
- Confirm the net passes on the baseline and would catch a relevant change.
The net protects only the cases it exercises. Add any case the requested change depends on.
Remove a testability obstacle
Use only the structural move that removes what still blocks testing the change:
| Obstacle | Move |
|---|---|
| Proven dead code or comments obscure the path | Remove them. Coverage alone does not prove code unused. |
| One block makes several decisions the change must isolate | Extract a cohesive, well-named operation. |
| Control flow hides the behavior under test | Simplify the affected conditions or flow. |
| A dependency blocks controlling input or observing output | Add a narrow seam, or split the decision from its side effect. |
| Unrelated responsibilities block a focused test | Separate them within the affected boundary. |
Each move is behavior-preserving. Run the net after each coherent move, and stop to investigate any failure before the next.
Done
Preparation is done when:
- The relevant existing behavior has a passing characterization test.
- The requested change can be exercised through a usable test boundary.
- Every structural change preserved the captured behavior.
Say it like this: "The characterization test protects the current output, and the dependency seam lets tdd test the requested change."
Hand the intentional behavior change to tdd. Keep the net until finer tests demonstrably cover the same behavior. Report the protected behavior, the testability changes, the checks run, and the remaining evidence gaps. Behavior that surprises you and needs explaining before you can pin it goes to diagnose.
Do not quote or reconstruct source text from the book.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/robsonrung/rar-skills/safe-incremental-coding">View safe-incremental-coding on skillZs</a>