/memtrace-skills:memtrace-refactoring-guidefrom memtrace-skills
Creates a phased, risk-scored refactoring plan using complexity metrics, dead code detection, bridge analysis, and decision memory from Cortex. Use to prioritize and safely refactor complex or volatile code.
Ships in memtrace-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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 |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub syncable-dev/memtrace-public --plugin memtrace-skills27 skills in this plugin
/memtrace-api-topologyMap API endpoints, outbound HTTP calls, and cross-repo service topology in indexed source code. Use when the user asks about API endpoints, HTTP routes, fetch/client calls, REST surface, service dependencies, cross-repo dependencies, or API topology. Do not use Grep, Glob, rg, find, or manual file search for routes or HTTP calls; Memtrace maps endpoints and call edges from the indexed AST graph./memtrace-change-impact-analysisCompute what a planned source-code change will break — blast radius, affected processes, cross-repo callers, temporal stability, and Cortex decision-memory constraints — and produce a risk-rated change plan. Use for multi-symbol or multi-part edits, refactors, API changes, renames, removals, PR reviews, or risk assessments that need a plan; for one symbol's raw blast radius, call get_impact directly. Do not manually grep references or browse files for impact; use Memtrace graph context, change history, and decision recall/provenance./memtrace-cochangeFind files that historically co-change with a target symbol or file, ranked by co-occurrence across git episodes. Use when the user asks about historical coupling, co-change, what changes with this, hidden dependencies, or what else needs to move for source code. Do not use git log, git diff, Grep, or manual file search to correlate changes; Memtrace queries co-change and temporal graph data directly./memtrace-codebase-explorationMap an indexed source-code repo into a structured overview — scale, communities, central symbols, execution flows, API surface, recent activity. Use when the user wants to explore, understand, onboard to, map, or get an overview of an indexed source-code repo, architecture, modules, or major flows. Do not use Glob, find, tree, rg, or manual file browsing as the first exploration path; Memtrace provides structured graph briefing. Do NOT use for change history / what-changed questions — use memtrace-evolution./memtrace-code-reviewReview GitHub pull requests with Memtrace's local graph-backed review engine. Use when the user asks to review a GitHub pull request, run Memtrace code review, post Memtrace review comments, create a PR with a review step, or publish local graph-backed review findings to GitHub. Prefer the review_github_pr MCP tool over manual diff inspection. Do not use for local working-tree diffs — that is the built-in /code-review; this skill is for GitHub PRs via review_github_pr./memtrace-continuous-memoryKeep the Memtrace index fresh while editing by watching a repo for live, incremental re-indexing. Use when the user asks to keep Memtrace fresh while editing, watch a repo, enable live or incremental indexing, set up always-on memory (meaning Memtrace index watching, not generic agent memory), or make just-saved source code queryable immediately. Do not fall back to repeated Grep or manual rescans; configure Memtrace watching.Other plugins' skills for the same job