/agent-workflow-amplifiers:refactor <refactor goal> [--scope <glob-or-path>]from agent-workflow-amplifiers
Orchestrates safe, large-scale structural changes across a codebase — symbol renames, API migrations, pattern standardizations, layer restructurings. Enumerates affected sites, groups them into dependency layers, applies changes in parallel per layer with worktree isolation, and verifies behavioral preservation before proceeding.
Ships in agent-workflow-amplifiers. 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.
/contract
Skip when: the change touches ≤3 files and no dependency ordering is required — just edit directly. Also skip when the codebase has no test coverage at all (behavioral preservation cannot be verified; ask the user to add tests first or proceed manually).
Parse $ARGUMENT to extract:
--scope is providedIf $ARGUMENT is ambiguous on any of the above, stop and ask exactly one question.
subagent_type: "research-agent")Dispatch both agents simultaneously in a single response turn.
Site-finder agent
sites: array of {file, line_range, site_type: "definition"|"import"|"usage"|"type-ref"|"test", change_required: string}dependency_graph: for each site, which other sites must be changed first (a site depends on its callers if it exports a symbol; a definition must be changed before its imports)site_count: integerconfidence: low | medium | highcoverage_gaps: what the agent couldn't search (generated files, third-party vendored code, etc.)confidence: low and list what was searched manually.Contract-extractor agent
contracts: array of {symbol, signature_before, exported_by, consumed_by[]}test_commands: array of shell commands that SCOPE to the affected contracts — target the specific test files or a name pattern, never the whole suite (e.g., pnpm test src/auth/auth-service.test.ts or pnpm test -t "AuthService"). Under pnpm, pnpm test -- <file> drops the file arg and runs the entire suite — never emit that form.test_coverage_verdict: "adequate" | "partial" | "absent"confidence: low | medium | highcoverage_gaps: test paths not reachable by the identified commandsScope gate (after Wave 1):
site_count > 50 → warn the user: "This refactor touches N sites. Recommend scoping down with --scope or batching via /parallelize. Proceeding, but each layer will take longer."test_coverage_verdict == "absent" → hard stop: "No tests cover the affected contracts. Behavioral preservation cannot be verified. Add tests before proceeding, or explicitly confirm you accept unverified risk."confidence: low → surface the coverage gaps and ask the user to confirm before proceeding.From dependency_graph, compute a topological sort into layers using Kahn's algorithm:
If the graph has cycles (rare but possible in circular-import codebases), surface them explicitly: "Cycle detected between [A, B, C]. Manual intervention required before automation can proceed." Do not continue.
For each layer (starting at Layer 0):
Dispatch one sub-agent per site in this layer, all in parallel, each in a worktree-isolated environment:
Layer applicator agent (per site, isolation: "worktree")
{file, line_range, change_required}, full transformation spec (target → destination), test commands that cover this sitesite: {file, line_range}status: "green" | "red" | "skipped"diff_applied: the exact unified diff applied (≤30 lines; truncate with ... if longer)test_output: truncated stdout of the targeted test run (last 20 lines)failure_reason: populated only if status == "red" — the first failing assertion + the file:line where it firededit_file and run bash commands; isolation: "worktree" is required.Layer gate — hard stop before proceeding to the next layer:
status == "green" → proceed to the next layer.status == "red" → abort the entire refactor immediately. Do NOT apply any more changes. Surface:
file:line_range)diff_applied for that sitefailure_reasongit stash in each affected worktree, then diagnose with /diagnose."subagent_type: "research-agent" or Bash-capable)Dispatch a single behavioral-diff agent:
Behavioral-diff agent (isolation: "worktree", Bash-capable)
test_commands from the contract-extractor, plus any project-wide test command (inferred from package.json, Makefile, etc.)full_suite_status: "all-green" | "failures"failing_tests: array of {test_name, file, failure_reason} (empty if all-green)behavioral_deltas: array of {symbol, before_behavior, after_behavior, expected: true|false} — note only deltas, not noiseunexpected_deltas: subset of behavioral_deltas where expected == falseconfidence: low | medium | highPost-Wave 3 decision:
full_suite_status == "all-green" AND unexpected_deltas is empty → proceed to synthesis, recommend commit.full_suite_status == "failures" OR unexpected_deltas is non-empty → surface the unexpected deltas for human review. Do NOT commit. Recommend: "Review unexpected behavioral changes before committing. If intentional, update tests to reflect new contracts. If not, route to /diagnose."Emit a structured change report:
## Refactor Report
**Goal:** <change type> — <target> → <destination>
**Scope:**
- Sites enumerated: N
- Layers processed: M (of M total)
- Status: COMPLETE | ABORTED AT LAYER N
**Changes applied:**
| File | Lines | Type | Status |
|------|-------|------|--------|
**Tests run:**
- Targeted (per-site): N runs, N green, N red
- Full suite: all-green | N failures
**Behavioral deltas:**
- Expected: N
- Unexpected: N (see below if non-zero)
**Recommendation:** COMMIT | REVIEW REQUIRED | ABORT
If recommendation is COMMIT, offer to invoke /ship for the final commit + PR. If REVIEW REQUIRED or ABORT, do not invoke /ship and do not commit.
What SKILL.md sets; muted values are Claude Code's defaults
Large-scope structural refactors across multiple files or layers.
npx claudepluginhub griffinwork40/agent-framework --plugin agent-workflow-amplifiers25 skills in this plugin
/agentifyBootstraps a dispatchable Claude sub-agent skill for every coding agent CLI installed on this machine (codex, aider, cursor, etc.). Use when the user wants to delegate tasks to locally-installed agent CLIs or expand the plugin's agent fleet./appmapMap a web UI and generate a Claude automation skill via parallel reconnaissance, synthesis, and iterative validation./automateSet up a scheduled headless Claude run that sends summaries to Telegram. Use when the user wants to automate a recurring task via launchd (macOS) with push-notified results.Other plugins' skills for the same job