/cc-arsenal:refactor <refactoring_description> [--scope file|module|project] [--interactive]from cc-arsenal
Restructures existing code without changing behavior: maps callers and test coverage, adds characterization tests where coverage is thin, then applies changes in small steps verified against the full test suite after each one.
Ships in cc-arsenal. 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.
Read when SKILL.md points to them.
Refactor code safely: capture current behavior with characterization tests, then restructure it in small steps, running the full test suite after each one before moving to the next.
$ARGUMENTS
Refactoring changes code structure WITHOUT changing behavior. Every step must be verified against existing tests. If tests break, the refactoring introduced a bug: revert and retry.
implement-feature, fix-bug), and Phase 0's scope gate below is where this gets enforced, not just stated.A Stop hook re-runs the Phase 4 Quality Gates Checklist automatically and blocks completion if any item fails, see the hook prompt above for the exact wording.
Whether the ceremony below (formal task chain, subagent fan-out) is worth it depends on blast radius, not on whether the skill fired.
The Phase 0 scope gate below always runs, even on the skip path: it's a five-second scan of the request, not ceremony.
Skip the task chain: grep the callers yourself, run the existing tests, make the change, run tests again; done:
Use the full task chain (Phase 0-6 below) when:
Task structure: a strict sequential chain, each phase blocked on the previous, so characterization tests exist before any structural change begins. TaskCreate returns the real task ID to use in addBlockedBy; don't hardcode literal IDs like 1-6, other tasks may already exist in the session. After finishing each phase, mark its task completed and run TaskList to confirm the next one unblocked: this applies at the end of every phase below. Full TaskCreate/TaskUpdate templates and the Explore-agent prompts for Phase 0 and Phase 1 are in references/task-chain.md, load it when actually running the full chain.
Portability: no Task/TaskCreate tools available? Drop the task chain and subagent fan-out: work through Phase 0-5 yourself, in order. The sequencing (characterization tests before structural change) is what matters, not the tracking mechanism.
Step 0a: Mixed-scope gate (blocking, do this before anything else, no exceptions):
AskUserQuestion to ask before writing any code. Don't guess.implement-feature (or fix-bug). This is checked against the actual final message sent to the user, not against intent recorded earlier in the run: a run that does the refactor correctly but never says what it skipped has not passed this gate.No mixed scope detected → proceed straight to Step 0b.
Step 0b: Project discovery: discover the project's test/lint/type-check commands (CLAUDE.md, Makefile/justfile/package.json/pyproject.toml, an Explore/Haiku agent works well here for wider projects, prompt in references/task-chain.md). Run the full test suite and record the baseline before touching any code. Pre-existing failures aren't yours to fix, just don't let the refactoring add new ones.
Map every caller and dependent of the target: grep for direct calls and imports, plus type references and any dynamic or string-based lookups that might reference it. Then map its existing test coverage: what's tested, what's a gap. For a single-file target with an obvious blast radius, do this yourself; for a wider one, two Explore agents in parallel (callers/dependencies, then test coverage) save tokens, prompts in references/task-chain.md.
If the refactoring spans more than 5 files, or changes a public API that external consumers depend on, confirm scope with AskUserQuestion before proceeding.
Where Phase 1 found coverage gaps, write tests that capture CURRENT behavior (including quirks and edge cases, not desired behavior) before changing anything. Name them so they're identifiable as characterization tests (test_char_* in Python, TestChar_* in Go, a characterization: describe block in JS). Run the full suite; every one must pass against the pre-refactoring code. Skip this phase entirely when the target already has thorough coverage.
def test_char_calculate_total_with_discount():
"""Characterization: captures current discount calculation behavior."""
result = calculate_total(items=[100, 200], discount=0.1)
assert result == 270.0 # current behavior: discount applied to sum
Break the change into the smallest independently-verifiable steps. See references/patterns.md for the step sequence per technique (extract method, extract class, rename, move, simplify conditional, remove duplication, inline, decompose large function). For each step: make the change, run tests immediately.
Tests fail → stop, don't push through. Revert if it's a behavioral change and find a smaller step; only touch the test itself if it was asserting an implementation detail, not behavior; and check whether it's actually a pre-existing baseline failure. Never batch multiple steps before testing: that discipline is what separates refactoring from a rewrite in disguise.
For multi-file changes: update the target first, then update callers one at a time (testing after each), then clean up dead code last. When the change needs temporary duplication, keep old and new structures working side by side until every caller has migrated, then remove the old one.
Run every quality check the project has, against the Phase 0 baseline.
Quality Gates Checklist:
Then read the actual diff (git diff) end to end for anything not on that list: leftover debug statements, unrelated formatting churn, missed import updates, orphaned code. Fix before proceeding, don't leave the task in_progress with a known-broken gate.
Use the git-commit skill if available. Otherwise commit manually with type refactor:. The subject describes what was restructured and the body explains why; the message always ends with "No behavioral changes.":
refactor: extract validation logic from OrderProcessor
Moved order validation into dedicated OrderValidator class to improve
separation of concerns. OrderProcessor now delegates to OrderValidator
for all input validation.
No behavioral changes.
refactor(auth): simplify token refresh conditional logic
Replaced nested if/else chain with guard clauses and extracted
isTokenExpired() helper.
No behavioral changes.
Report:
Only state metrics (line counts, complexity, coverage %) that came from a command actually run this session: never estimate them.
If Phase 0's scope gate deferred any behavior-changing work, name it here explicitly and point to implement-feature/fix-bug, even if it was already mentioned earlier in the run. The final message is what gets checked, not the earlier reasoning.
Tests before and after every change are non-negotiable. Refactoring changes structure only, not behavior: if tests break, revert. Scope stays minimal: refactor only what was requested, and resist "while I'm here" changes to adjacent code. When unsure, clarify scope rather than over-refactor.
TaskCreate/TaskUpdate templates and Explore-agent prompts; load when running the full multi-file task chain (Phase 0-1).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mgiovani/ai-arsenal --plugin cc-arsenal52 skills in this plugin
/agent-browserHeadless browser automation CLI optimized for AI agents: drives a real browser via accessibility-tree snapshots and @e1-style refs for ~93% less context than raw DOM tools. Use whenever a task needs to interact with a live web page: click, fill forms, log in, extract text or data, take screenshots, test a running web app, or scrape a site. Triggers on 'automate the browser', 'fill this form', 'click the button', 'take a screenshot of the page', 'log into', 'scrape this site', 'test my web app', 'headless browser'. Not for Playwright test-suite authoring or CDP/service-worker work needing the full JS API: use Playwright directly. Not for driving the user's own already-open, logged-in Chrome tab: use claude-in-chrome for that./anything-to-skillTurns a docs site, local folder, PDF or book, YouTube video, playlist or channel, or a topic into a source-grounded, token-efficient agent skill (hub SKILL.md, sectioned references, INDEX, evals), and can compact it into a lean expert skill. Use for "make a skill from these docs", "turn this channel into a skill". Not for a skill from your own description (use create-skill), improving one (use improve-skill) or finding third-party skills (use find-skills)./ci-generateGenerate a production-ready CI/CD pipeline config (GitHub Actions, GitLab CI, CircleCI, or Jenkins) by discovering the project's actual stack, test/build commands, and dependencies. Use when setting up CI for a new project, adding a missing workflow file, or asked to create/generate a pipeline, workflow, or `.gitlab-ci.yml`/`Jenkinsfile`. Not for writing a Dockerfile itself (see docker-init), this only wires CI stages around one. Not for running existing CI checks locally (use ci-local), this skill only authors the pipeline file itself./ci-localRun the checks a GitHub Actions workflow would run, locally, when Actions is unavailable or out of quota. Parses .github/workflows/*.yml, extracts the jobs/steps that gate merges (lint, typecheck, test, build), translates them to local commands respecting the workflow's pinned node/python versions and env, executes them sequentially, and reports a parity table of what passed locally vs. what can't be replicated (service containers, secrets, matrix dimensions) and why. Activates on "CI quota", "Actions is down/unavailable", "run CI locally", "verify like CI would", "run the pipeline on my machine", or a pre-push request to check a branch the way CI checks it. Not for generating a new workflow file (use ci-generate), not for debugging why a specific CI run failed on GitHub (use fix-bug or review-code), and not for the release/hotfix gating process itself (use gitflow), this skill only produces the local stand-in when the real thing isn't reachable./clotho-researchFind what a change will actually touch before planning it — the existing code that must change, the prior art worth copying, and the risks that will bite. Trigger on "what would this change touch", "research this before we plan it", or an automated pre-planning step. Reports files, sources, and risks; it never proposes an implementation and never edits anything. Not for auditing dependencies (use review-deps), not for writing the plan itself (use project-planner), and not for reviewing code that already exists (use review-code)./codex-imagegenGenerates images and polished raster art (logos, mascots, hero images, icons, characters, sprite sheets, illustrations, product mockups) by driving Codex CLI's $imagegen skill. This is the default image generator, use it for any request to generate or create an image or visual asset, including "generate an image", "create a hero image", "make a mascot", "design a logo", "draw an icon", "generate a sprite sheet", or "make an illustration". Requires the `codex` CLI installed and authenticated (ChatGPT auth). Not for architecture, flow, or sequence diagrams (use docs-diagram).