Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Restructure existing code while preserving externally observable behavior through explicit invariants, characterization evidence, small reversible steps, and continuous verification. Use when the user asks to refactor, simplify, extract, reorganize, modularize, deduplicate, split a component, improve architecture, or pay down technical debt without intentionally changing product behavior. Distinguish refactoring from feature work and stop scope drift from hiding inside structural edits.
.claude/skills/contextosai-refactor-safely/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 20% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 14% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -4% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 4% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 101% | 0% |
Change structure while keeping the behavior contract stable.
change: API, side effects, ordering, errors, timing-sensitive semantics, persistence, telemetry, and extension points.
registration, configuration, serialization, and framework conventions that symbol search may miss.
characterization tests around high-risk invariants before restructuring. Do not encode accidental behavior without evaluating whether callers rely on it.
then semantic cleanup; do not combine both when the diff would obscure behavior changes.
diverging during transition; use adapters or delegation briefly when needed.
broader tests proportional to risk.
error behavior, and performance where relevant.
new path. Search for stale imports, registrations, flags, and documentation.
Split and label intentional behavior changes.
invariant it owns.
sequence over a sweeping rewrite.
For planning-only requests, use references/refactor-ledger.md. For implementation requests, maintain the ledger while editing and report preserved invariants, intentional deviations, checks run, and residual risks.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 24,414 | 32,650 | +34% | 1 | 1 | 0% | 4,119 | 6,097 | +48% | 0 | 0 | — |
case-02 | fail→fail | 5,991 | 27,443 | +358% | 1 | 1 | 0% | 1,079 | 6,631 | +515% | 0 | 0 | — |
case-03 | fail→fail | 16,818 | 2,488 | -85% | 1 | 1 | 0% | 3,572 | 560 | -84% | 0 | 0 | — |
case-04 | pass→pass | 8,711 | 5,165 | -41% | 1 | 1 | 0% | 1,712 | 1,383 | -19% | 0 | 0 | — |
case-05 | pass→pass | 10,956 | 14,620 | +33% | 1 | 1 | 0% | 2,516 | 3,512 | +40% | 0 | 0 | — |
case-06 | fail→pass | 14,411 | 15,992 | +11% | 1 | 1 | 0% | 2,930 | 3,514 | +20% | 0 | 0 | — |
case-07 | pass→fail | 11,501 | 10,958 | -5% | 1 | 1 | 0% | 1,828 | 2,253 | +23% | 0 | 0 | — |
case-08 | fail→pass | 16,828 | 16,999 | +1% | 1 | 1 | 0% | 2,808 | 3,188 | +14% | 0 | 0 | — |
case-09 | pass→pass | 11,984 | 9,378 | -22% | 1 | 1 | 0% | 2,008 | 2,005 | -0% | 0 | 0 | — |
case-10 | pass→pass | 13,399 | 12,053 | -10% | 1 | 1 | 0% | 2,449 | 2,586 | +6% | 0 | 0 | — |
case-11 | pass→pass | 12,736 | 8,537 | -33% | 1 | 1 | 0% | 2,238 | 1,887 | -16% | 0 | 0 | — |
case-12 | pass→pass | 12,313 | 12,320 | +0% | 1 | 1 | 0% | 1,925 | 2,388 | +24% | 0 | 0 | — |
case-13 | fail→fail | 11,042 | 7,824 | -29% | 1 | 1 | 0% | 1,869 | 1,761 | -6% | 0 | 0 | — |
case-14 | fail→pass | 9,044 | 6,230 | -31% | 1 | 1 | 0% | 1,604 | 1,534 | -4% | 0 | 0 | — |
case-15 | fail→pass | 14,688 | 12,463 | -15% | 1 | 1 | 0% | 2,382 | 2,487 | +4% | 0 | 0 | — |
case-16 | fail→pass | 12,009 | 20,370 | +70% | 1 | 1 | 0% | 2,486 | 5,003 | +101% | 0 | 0 | — |
case-17 | pass→pass | 9,803 | 6,302 | -36% | 1 | 1 | 0% | 1,613 | 1,448 | -10% | 0 | 0 | — |
case-18 | fail→fail | 10,081 | 8,892 | -12% | 1 | 1 | 0% | 1,636 | 1,870 | +14% | 0 | 0 | — |
case-19 | fail→pass | 8,478 | 6,112 | -28% | 1 | 1 | 0% | 1,577 | 1,481 | -6% | 0 | 0 | — |
case-20 | fail→pass | 9,903 | 7,366 | -26% | 1 | 1 | 0% | 1,840 | 1,641 | -11% | 0 | 0 | — |
case-21 | pass→pass | 15,849 | 12,171 | -23% | 1 | 1 | 0% | 2,665 | 2,422 | -9% | 0 | 0 | — |
case-22 | pass→pass | 5,715 | 3,915 | -31% | 1 | 1 | 0% | 976 | 1,085 | +11% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +27 percentage points is the difference between those two pass rates over the 21 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.