Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Build a phased, risk-scored refactoring plan from Memtrace complexity, dead-code, bridge, impact analysis, and Cortex decision-memory constraints. Use when the user wants to refactor source code, reduce complexity, clean technical debt, delete dead code, split large functions, extract modules, reorganize code, or choose refactoring priorities. Do not plan refactors from grep/manual reference search alone; check graph impact and decision rationale/bans/contracts before changing existing code.
.claude/skills/syncable-dev-memtrace-refactoring-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 106% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -30% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 43% | 0% |
| case-11 | ✗→✓ | ▲ Improved | -6% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 27% | 0% |
Guided refactoring workflow — identifies refactoring candidates using structural analysis, scores them by risk and priority, checks Cortex decision memory for rationale/bans/contracts, and produces a phased refactoring plan. Combines complexity metrics, dead code detection, bridge analysis, temporal evolution, and decision memory to prioritize what to refactor first and how to do it safely.
Run these three tools in parallel to build a candidate list:
a) Complexity hotspots: Call find_most_complex_functions with top_n: 20
b) Dead code: Call find_dead_code to find unused symbols
c) Architectural bottlenecks: Call find_bridge_symbols to find chokepoints with too much responsibility
Call get_evolution with from: "90d ago" and mode: "compound".
Review top_touched_symbols and top_changed_files:
Priority matrix:
| | Low Complexity | High Complexity | |---|---|---| | Stable (low change freq) | Leave alone | Monitor; refactor if touched | | Volatile (high change freq) | Normal; leave alone | TOP PRIORITY — refactor first |
For each top-priority candidate, call get_impact with direction: both:
Also call get_symbol_context to check:
For each top candidate, call recall_decision("<symbol/subsystem/refactor intent>"). If you have a numeric symbol_id, call why_is_this_here(symbol_id) and governing_contracts(symbol_id).
For each refactoring target, call analyze_relationships:
find_callees — what does it depend on? These become candidates for extractionfind_callers — what depends on it? These need updating after refactoringclass_hierarchy — is it part of an inheritance chain? Liskov concernsFull parameter spec for every Memtrace tool: references/mcp-parameters.md (bundled at the memtrace-skills plugin root).
Call list_communities and check: does the refactoring target sit at a community boundary?
Synthesize into a phased plan:
Phase 1 — Quick Wins:
Phase 2 — High-Impact Refactors:
Phase 3 — Structural Improvements:
For each item, include:
| Condition | Action | |-----------|--------| | Complex + volatile + high blast radius | Highest priority — but plan carefully; incremental approach | | Complex + stable + low blast radius | Can wait; refactor when you're already touching nearby code | | Dead code with zero callers | Run Cortex provenance/recall first; zero callers is not proof that no decision/contract keeps it | | Bridge symbol with many dependents | Extract interface first, then refactor implementation behind it | | Symbol in cross-repo API | Coordinate with consumers; backward-compatible changes only | | Cortex returns a held ban/contract | Preserve it or ask before overriding it |
A phased plan (Phases 1–3). One worked entry:
| Field | Example | |---|---| | Target | process_payment — src/billing/processor.py, complexity 38 | | Why | Complex + volatile (14 changes/90d in top_touched_symbols) + 23-symbol blast radius | | First move | Extract validation branch to validate_payment_request; keep callers untouched | | Risk | High — upstream spans 3 processes incl. checkout_flow; incremental migration |
Acceptance criteria:
| Mistake | Reality | |---------|---------| | Refactoring the most complex function first | Complexity alone isn't enough — prioritize by complexity × volatility | | Deleting all dead code at once | Some "dead" code is called dynamically; verify before batch deletion | | Refactoring without checking blast radius | A "simple" refactor on a bridge symbol can cascade across the codebase | | Not checking temporal evolution | A complex function that hasn't changed in a year is lower priority than a simpler one that changes weekly |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 38,862 | 4,690 | -88% | 1 | 1 | 0% | 6,242 | 1,905 | -69% | 0 | 0 | — |
case-02 | fail→fail | 31,203 | 7,085 | -77% | 1 | 1 | 0% | 5,766 | 1,505 | -74% | 0 | 0 | — |
case-03 | fail→fail | 27,576 | 5,165 | -81% | 1 | 1 | 0% | 4,504 | 1,509 | -66% | 0 | 0 | — |
case-04 | pass→pass | 8,803 | 4,589 | -48% | 1 | 1 | 0% | 1,410 | 2,116 | +50% | 0 | 0 | — |
case-05 | fail→pass | 6,396 | 3,459 | -46% | 1 | 1 | 0% | 966 | 1,989 | +106% | 0 | 0 | — |
case-06 | pass→pass | 9,943 | 3,592 | -64% | 1 | 1 | 0% | 1,589 | 1,959 | +23% | 0 | 0 | — |
case-07 | fail→pass | 15,573 | 2,360 | -85% | 1 | 1 | 0% | 2,415 | 1,688 | -30% | 0 | 0 | — |
case-08 | pass→pass | 14,225 | 9,613 | -32% | 1 | 1 | 0% | 2,059 | 2,876 | +40% | 0 | 0 | — |
case-09 | pass→pass | 10,078 | 4,392 | -56% | 1 | 1 | 0% | 1,555 | 2,033 | +31% | 0 | 0 | — |
case-10 | fail→pass | 9,320 | 4,075 | -56% | 1 | 1 | 0% | 1,309 | 1,872 | +43% | 0 | 0 | — |
case-11 | fail→pass | 10,911 | 1,754 | -84% | 1 | 1 | 0% | 1,676 | 1,575 | -6% | 0 | 0 | — |
case-12 | fail→fail | 13,406 | 4,622 | -66% | 1 | 1 | 0% | 2,048 | 2,120 | +4% | 0 | 0 | — |
case-13 | fail→pass | 10,139 | 4,237 | -58% | 1 | 1 | 0% | 1,616 | 2,055 | +27% | 0 | 0 | — |
case-14 | pass→pass | 46,036 | 4,100 | -91% | 1 | 1 | 0% | 1,006 | 1,879 | +87% | 0 | 0 | — |
case-15 | fail→pass | 7,058 | 5,678 | -20% | 1 | 1 | 0% | 1,074 | 2,427 | +126% | 0 | 0 | — |
case-16 | fail→pass | 11,067 | 2,746 | -75% | 1 | 1 | 0% | 1,895 | 1,728 | -9% | 0 | 0 | — |
case-17 | fail→pass | 12,187 | 5,055 | -59% | 1 | 1 | 0% | 1,742 | 2,166 | +24% | 0 | 0 | — |
case-18 | fail→pass | 16,902 | 2,812 | -83% | 1 | 1 | 0% | 1,165 | 1,801 | +55% | 0 | 0 | — |
case-19 | fail→pass | 9,993 | 3,552 | -64% | 1 | 1 | 0% | 1,560 | 1,890 | +21% | 0 | 0 | — |
case-20 | pass→fail | 22,841 | 8,078 | -65% | 1 | 1 | 0% | 4,810 | 1,691 | -65% | 0 | 0 | — |
case-21 | fail→fail | 7,397 | 10,535 | +42% | 1 | 1 | 0% | 1,011 | 2,666 | +164% | 0 | 0 | — |
case-22 | fail→fail | 11,925 | 26,115 | +119% | 1 | 1 | 0% | 1,125 | 4,833 | +330% | 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 17 counted toward the lift figure. The other 5 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 +41 percentage points is the difference between those two pass rates over the 17 comparable cases. 3 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.