/tea-rags:refactoring-planning [scope — pathPattern, domain, or 'whole project']from tea-rags
Transforms architecture diagnosis into an ordered refactoring plan with simulated candidates, tiered steps, and execution tasks. Use when asked to plan a refactoring or fix architecture violations.
Ships in tea-rags. 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.
Diagnosis → simulated candidates → server-ordered steps → plan Tasks w/ expected delta. Server orders; agent builds candidates + plan. Execute YOURSELF, tea-rags tools only.
Lag / drift ≠ licence to leave tea-rags (core). Own checkout, changedFiles > 0
→ incremental index_codebase; subagent / linked worktree → never reindex. →
tea-rags://guide/freshness.
get_architecture_reportplannedEdgesrestructurePlan (report candidates per cost rule)tea-rags:refactoring-scan, notes onlydinopowers:writing-plans, one step = one TaskrestructurePlan simulation behind it.UNJUDGED newFile treated as reject (it is not).includeReportCandidates default on large repo → call runs ~1 h (bd
tea-rags-mcp-vytjl).Codegraph on = graph tools (get_callers, trace_path, …) in tool list; absent
= off. Off → "refactoring planning needs codegraph", stop. Any plan-mode answer
unavailable: "noCodegraph" → stop, same line.
get_architecture_report(path: "<working dir>", pathPattern?|domain?, limit?) —
reading per tea-rags:architecture-diagnostics Phase 1 (do not restate). Keep:
tier critical / active (SDP, leakingAbstraction, layering
backEdge, hubLikeDependency). Structural-only → listed, no candidate unless
user asks. summary.impactTiers built: false → untiered: take by
maintenanceCost, say "untiered".N = summary.propagationCost.fileCount (judged production files — drives
per-judge cost).R = summary.splitMerge split + merge candidates (report candidates
restructurePlan adds). Block not built → R = 0.truncated present → page the held report
(reportId, per architecture-diagnostics Phase 1) BEFORE Phase 2 caps
candidates — a critical finding on page 2 is still a candidate.User already ran architecture-diagnostics this session → reuse that report, no re-call.
Per kept finding: load ../../repair/<family>.md ## Ops recipe — that family
only, never preload dir.
| Finding | Recipe file |
|---|---|
stableDependencies | stableDependencies.md |
hubLikeDependency | hubLike.md |
leakingAbstraction | leakingAbstraction.md |
layering backEdge | layeringBackEdge.md |
| layer-map move / A5 verdict | architecture-diagnostics Phase 3i op table |
removeEdge{from,to},
addFile{file,component, abstract: true} for extracted interface,
addEdge{from,to}, move{…}. Paths repo-relative base paths; new-file path
per recipe's path rule (never hard-coded dir). SDP inversion: A = finding's
sourceRelPath, B = its toRelPath — FILES, never the component dirs of the
finding key; spelled: removeEdge{A,B},
addFile{<foundation>/…/<Iface>.ts, abstract: true}, addEdge{A,iface},
addEdge{B,iface} — rationale = finding key.get_naming_lexicon call over all drafted new-file / type names.
MISFIT / COLLISION → rename to suggestion; NEW_TERM → keep + one-line
why.get_architecture_report(path, plannedEdges: [...]) over every
addEdge between EXISTING files. MISFIT → drop candidate, line
DROPPED <id> — MISFIT <src> -> <dst> (established <roleSrc> -> <roleDst>, support <n>).
UNJUDGED newFile / NEW_PATTERN / CONFORMS → keep.{id, rationale: <finding key>, ops} — one per remedy, ≤ 20 ops.
rationale = the finding key string verbatim (e.g.
stableDependencies:<A dir>-><B dir>), not prose. Write each candidate out in
the answer: every op with its concrete paths, the new file under the
foundation component — never "form candidate from recipe". id kebab
<family>-<short subject>, never report: prefix (server owns it).maintenanceCost. Rest → Deferred (re-plan after first Tasks land).get_architecture_report(path, restructurePlan: {candidates, includeReportCandidates})
— only limit may ride along.
Cost: rounds = steps + 1, each round judges every remaining candidate (full
detector run) → judges ≈ (S + 2)·(K + R). Per-judge ms grows w/ N. Known per
judge = (timing.totalMs − timing.factsMs) / timing.judgeCount of an earlier
plan / restructure call this session.
includeReportCandidates: false (always safe), ≤ 15 own candidates (critical
first; rest Deferred — never all of them). It yields S + per-judge.includeReportCandidates omitted (true); that plan
supersedes. Over → large repo: keep the false plan, say verbatim (bd id
included) "report split/merge candidates not ordered — quadratic judging,
call can run ~1 h (bd tea-rags-mcp-vytjl)", list them under Not ordered (each
simulable alone via architecture-diagnostics Phase 3i). Never drop them
silently.Large repo = estimate over budget; N ≥ ~10k judged files with dozens of R → skip
the estimate, go false directly — still ≤ 15 candidates, and say why citing bd
tea-rags-mcp-vytjl.
Read response: steps[] (order = plan order; delta vs prefix, byTier,
touchedFiles, blastRadius), tradeOffs[] (introduce critical/active — never
selected), unselected[] (noImprovement | conflictsWithPrefix + detail),
total (base vs final prefix). Unknown file / edge → typed error
(INPUT_UNKNOWN_RESTRUCTURE_*) → fix name, re-call; never drop candidate.
tea-rags:refactoring-scan over union of steps' touchedFiles. Tier 1/2 hit on
file F in step k → note on step k: "F — decompose too ()". Order
unchanged; no Task added; no step removed.
dinopowers:writing-plans. One step = one Task, step order. Per Task:
candidateId, rationale (finding key), ops as implementation intent (remove
import A→B, extract interface I at path, A + B import I).delta: resolved subjects, introduced subjects
(none or listed), byTier, net; blastRadius; scan note if any.tea-rags:data-driven-generation; Task ends w/ DDG Step 7
gate line, quoted literally in the Task:
GATE review_changes: introduced=<n>, partial=<true|false>.Separate sections, NEVER Tasks: Trade-offs (candidate, introduced vs resolved by tier), Unselected (candidate, reason, detail), Not ordered (report candidates on large repo), Deferred (over cap), Escalated (no recipe), Dropped (MISFIT).
Write this block into every generated plan, verbatim:
Execution contract (refactoring-planning):
1. After each Task: review_changes(changes: {base: <commit before this Task>},
sections: ["architecture"]) — compare change.resolved and introduced
(findings + change.nonLocal) with the Task's expected delta.
2. Match → DDG Step 7 gate line, commit, next Task.
3. Diverged (expected resolved missing, or unexpected introduced) → DDG Step 7
fix-at-write loop (≤ 2 rounds).
4. Not converging → get_architecture_report(path: <working dir>,
restructurePlan: {candidates: <remaining Tasks' candidates>}) on the real
tree; replace remaining Tasks with the new steps + expected deltas.
Never continue on the stale plan.
Show, never summarize: candidate ops with paths, Task expected delta, the gate line and the Phase 6 contract block appear in the answer as text — "Task includes expected delta and execution contract" is not the plan.
## Plan — <scope>: <S> steps, total net <n> (critical <r>/<i>, active <r>/<i>, structural <r>/<i>)
| # | Candidate | Rationale | Expected resolved | Introduced | byTier | Blast | Note |
## Trade-offs / Unselected / Not ordered / Deferred / Escalated / Dropped
Plan file: <path from writing-plans>
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub artk0de/tearags-mcp --plugin tea-rags17 skills in this plugin
/analytics-rerankPick tea-rags rerank preset, build `{custom: {...}}` weight set, or compose analytics-driven search (ownership, tech-debt, hotspots, code-review, security-audit, fragile-silo). Invoke on intent like "rank by ownership", "find tech debt", "hotspot scan", "code review of recent changes", "security audit of auth code", "code that looks stable but breaks a lot", "custom weights for impact analysis". NOT for project health scan needing cross-preset overlap — use `tea-rags:risk-assessment`. NOT for debug root-cause — use `tea-rags:bug-hunt`. NOT for filter shape — use `tea-rags:filter-building`./architecture-diagnosticsDiagnose structural violations for an explicit architecture audit, an explicit invocation of this skill, or structural refactoring. Assess dependency/layer violations, coupling and move candidates. Not for context gathering, code overviews, behavior or contract questions, or routine feature work. Risk/health uses risk-assessment; failures use bug-hunt; plain cycles use find_cycles./bug-huntFind source of concrete failure — rank historically buggy code (high bugFixRate + churn) AND freshly changed never-fixed code (committed or still uncommitted) against symptom. Triggers on "debug X", "why does Y fail", "test fails", "stack trace says Z", "find bugs in X", "found a bug in X — show / compare Y", "suspects in X and Y — search both", a search hit with bugFixRate / ageDays labels ("proceed?", "проверь там"), "where is error 'X' in code", "где в коде строка / упоминается 'X'", "when did error 'X' appear in git history", "когда появилась ошибка 'X'", "read the whole file" / "прочитай весь файл" of a search hit, "падает". NOT for code history without an error string or failure ("when did X change", "посмотри через git" alone) — core routing answers it. NOT for code health scanning without bug intent — use risk-assessment for that./data-driven-generationDecide HOW to write or change code by inspecting git signals on neighbors — classifies task mode (CREATE / EXTEND / MODIFY), pulls strategy and templates from proven low-churn implementations, reuses existing shared helpers. Triggers on "implement function X", "add method to class Y", "write a helper for Z", "modify function X", "change behavior of Y", "напиши функцию", "добавь метод", "поправь метод", "измени поведение", "overlay labels → strategy?", a hotfix with location + fix named (cause known → not bug-hunt). NOT for discovery — use tea-rags:explore. NOT for pure rename/extract; a file MOVE still routes here./exploreUse for questions about existing code behavior, usages, structure, examples, or explicit pre-change context that need investigation. Not bug symptoms, implementation-plan authoring, or broad code-health audits./extract-project-patternsAgentic-only — runs on any behaviorQuery / positiveIds handoff: proven code as code-gen templates, not test patterns. Returns templates + locality (target subdomain → infra prefix → project). Read body before planning. Called by data-driven-generation Step 2, dinopowers writing-plans / executing-plans. No input → returns { templates: [], locality: "none", diagnostics: ["no input"] }, zero calls.Other plugins' skills for the same job