refactor-orchestration
Use when starting a multi-layer top-down refactor that's too large for one session. Produces a validated plan and a copy-paste orchestrator prompt that dispatches small chunks to the refactor-executor agent (Haiku) and escalates contradictions to the refactor-investigator agent (Sonnet) plus the user. Triggers on phrases like 'orchestrate refactor', 'top-down refactor', 'design ideal shape', 'layer-by-layer refactor', 'plan and orchestrate', 'execute big refactor in chunks', 'ideal endpoint design', 'redesign this layer'.
What this skill does
# Refactor Orchestration This skill captures a workflow for **multi-layer top-down refactors**: the kind of work where you design the outermost layer first, push unfit responsibilities downward with an "export manifest," then move layer by layer until the codebase is reshaped. ## When to use - A refactor that touches many files across multiple architectural layers. - A refactor too large to design AND execute in one session. - A refactor where you want to FREEZE the design before executing, then dispatch mechanical work in parallel-ish chunks. If the work fits in one session and one mental model, skip this skill and just do it directly. ## Two outputs of this skill 1. `.claude/plans/<YYYY-MM-DD>-<slug>.md` — the validated design plan 2. `.claude/plans/<YYYY-MM-DD>-<slug>-orchestrator-prompt.md` — the copy-paste orchestrator prompt The first is the WHAT; the second is the HOW. Both are produced in this skill's workflow. ## Stages 1. **Inventory.** Two parallel `Explore` agents: one catalogues the layer's current state (every file, every function, every leaked responsibility), one extracts rules from the relevant ADRs / design docs / framework conventions. If `.claude/refactor-conventions.md` exists, read it and include its **Layer rules** and **Known anti-patterns** sections in the "what should be" report — these are project-tier constraints promoted by prior `refactor-analyzer` runs and must be respected in the plan's §1 (Forbidden). Produces a "what is" and a "what should be" report. 2. **Top-down design.** Draft the IDEAL shape of the layer. For each item that doesn't fit cleanly, push it into the NEXT layer with a placeholder home — even if no clean home exists yet. Capture these in an Export Manifest. The principle: name the responsibility and its target Protocol/method now, defer the destination's implementation shape to the next pass. 3. **Library-claim validation (context7).** For every third-party API the plan names (FastAPI, Pydantic, SDK clients, streaming libraries), confirm the claim via context7 docs. Capture deltas in a validation table. **This step is non-optional** — in past refactors it caught 5/5 library claims, two of which were silent-failure blockers. 4. **Harmonization.** Force the design toward maximal symmetry. Define a canonical template; reduce N templates to 1 or 2; fix parameter order; make every endpoint/function/file look as similar as possible to every other. Asymmetric designs grow asymmetric code. 5. **Persist plan.** Write the plan to `.claude/plans/<YYYY-MM-DD>-<slug>.md` using `plan-template.md` (§0–§13 structure). Keep the section headers stable — anyone reading multiple plans should recognize the shape. When a conventions file was read in Stage 1, its Layer rules and Known anti-patterns must appear verbatim in plan §1 (Forbidden). New projects with no conventions file leave §1 populated only from ADR analysis — that is correct and expected. 6. **Orchestrator design.** Decompose the plan into a chunk queue. Each chunk = one atomic commit. Group chunks into phases (typically: shared primitives → protocols/contracts → per-feature rewrites → structural tests → smoke validation). 7. **Persist orchestrator.** Write the copy-paste orchestrator to `.claude/plans/<YYYY-MM-DD>-<slug>-orchestrator-prompt.md` using `orchestrator-prompt-template.md`. Wrap the executable block with `=== BEGIN ORCHESTRATOR PROMPT ===` and `=== END ORCHESTRATOR PROMPT ===` markers so the reader knows what to copy. 8. **Execute.** Open a fresh `claude` session, paste the orchestrator block between the markers, let it run. The orchestrator dispatches `refactor-executor` (Haiku) per chunk, reviews each itself, and escalates contradictions to `refactor-investigator` (Sonnet) then to the user via `AskUserQuestion`. 9. **Retrospective.** As its final phase (Phase F), the orchestrator dispatches `refactor-analyzer` (Sonnet, read-mostly). The analyzer reads the full session transcript, the git log, and the learnings ledger; writes a retrospective report at `.claude/plans/<plan-slug>-retrospective.md`; appends new observations to `learnings.md`; and proposes template/agent edits via `AskUserQuestion` for any observation that hit `count=3` this run (rule-of-three promotion). NEVER edits the just-finished plan or orchestrator-prompt — those are history. The 5 buckets the analyzer is allowed to propose against: `SKILL.md`, `plan-template.md`, `orchestrator-prompt-template.md`, `refactor-executor.md`, `refactor-investigator.md`. This is what closes the loop and makes the whole system learn over time. ## Templates and subagents - **`plan-template.md`** — fully opinionated §0–§13 structure. Fill in placeholders; keep the section headers stable. - **`orchestrator-prompt-template.md`** — `=== BEGIN/END ===` block with placeholders for plan path, branch, chunk queue, dispatch template instance. Ends with Phase F dispatching the analyzer. - **`retrospective-template.md`** — §1–§7 structure for the retrospective report the analyzer produces. - **`learnings.md`** — ledger that accumulates observations across runs. Rule-of-three promotion controls when an observation becomes a proposed diff. - **`requirements-framework:refactor-executor`** — Haiku subagent. Mechanical chunk execution. Reads only the referenced plan section, edits only the named files, verifies with ruff + import smoke. Does not redesign. - **`requirements-framework:refactor-investigator`** — Sonnet subagent. Read-only. Diagnoses plan-vs-reality contradictions and proposes 2-3 solution paths. - **`requirements-framework:refactor-analyzer`** — Sonnet subagent. Read-mostly. Writes the retrospective report + learnings.md; proposes template/agent diffs via AskUserQuestion. NEVER edits past plans/orchestrator prompts. ## Conventions - **Filenames:** `.claude/plans/YYYY-MM-DD-<slug>.md` for the plan and `<slug>-orchestrator-prompt.md` for the orchestrator companion. Same date prefix; same slug; explicit pairing. - **One chunk = one commit.** The orchestrator commits atomically per chunk with an imperative subject mentioning the plan section (e.g. "Add execute()/stream() transport helpers per plan §4"). - **Pre-commit hooks are mandatory.** Never use `--no-verify` without explicit user approval. If hooks auto-format and leave files in `MM` state, re-stage and retry. - **Two retries on simple issues** before escalating to investigation. If Haiku can't fix it in 3 total tries, the problem is probably a misunderstanding, not a typo. - **Investigation outputs do not change code** — they produce options for the user to pick. The orchestrator updates the plan only after the user picks an option. ## Part of requirements-framework This skill is bundled with the `requirements-framework` plugin. Recommended sequencing: | Step | Command | What it covers | |---|---|---| | 1 | `/requirements-framework:arch-review` | Satisfies the framework's planning gates (commit_plan, adr_reviewed, tdd_planned, solid_reviewed) for the upcoming work. | | 2 | `/requirements-framework:refactor-orchestrate` | Stages 1–7 of this skill: inventory, top-down design, library-claim validation, harmonization, plan write, chunk queue, orchestrator-prompt write. | | 3 | Fresh `claude` session | Paste the orchestrator block. Stages 8–9 (execution + retrospective) run there. | This skill does **not** auto-satisfy any framework requirements. Run `/requirements-framework:arch-review` first if the project enforces them. `req:session-reflect` is complementary to Stage 9 — does general session reflection. The analyzer mentions it in the retrospective's "Further reading" footer but does not invoke it. ## Stop conditions for the orchestrator Stop and bring problems to the user IF: - Baseline tests fail before any chunk runs. - A chunk hits a complex issue after one investigation dispatch. - 2 simple-issue retries fail in a row. - A circular import or layer-guard violation appears that the plan doesn't anticipate. - The plan re
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.