refactor

A test-first workflow for restructuring existing Python code while keeping its current behaviour unchanged.

In plain words
What is it for?
Use it to clean up, reorganise, extract, or restructure Python modules, then run tests and review the resulting changes.
Why use it?
It checks test coverage and adds characterization tests—tests that capture how the code currently behaves—before making changes, reducing the risk of accidental breakage.

Skill for Claude CodeCodex

Part of the develop plugin — 5 skills, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/borda/ai-rig/refactor
Any agent
npx skills add Borda/AI-Rig --skill refactor
Clone the repo
git clone --depth 1 https://github.com/Borda/AI-Rig

Made for: Claude Code, Codex.

Or install develop, the plugin that ships this one along with the rest of its 5 skills, 1 hook.

Per session 121 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 8,120 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00121 $0.08120
Opus 5 $0.00060 $0.04060
Sonnet 5 $0.00024 $0.01624
Haiku 4.5 $0.00012 $0.00812

Measured 3d ago against content hash 4d726b4c1193, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cc_develop/skills/refactor/SKILL.md · 572 lines

How it starts

The opening of the file, as written. The whole thing — 572 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test-first refactoring. Audit coverage, add characterization tests if missing, apply changes with safety net.

NOT for:

  • bug fixes (use /develop:fix)
  • new features (use /develop:feature)
  • .claude/ config changes (use /foundry:manage (requires foundry plugin))
  • non-Python projects (JS/TS/Go/Rust) — toolchain assumes pytest; use language-native toolchain instead
  • mixed refactor+feature tasks — run /develop:refactor first, then /develop:feature; do not attempt both in single skill run

Quality stack (Branch Safety Guard, Codex Pre-pass, Progressive Review) requires foundry plugin; when absent, Step 5 quality stack skipped with a visible warning — output lower quality but workflow still completes.

  • MAX_INNER_CYCLES: 5 (change-test cycles per outer session — Step 4 safety break)
  • Key boundary: end of Step 2 — coverage audit complete, before characterization test writing in Step 3.
  • Second boundary: end of Step 4 — refactor edits applied, before review stack in Step 5.
  • Preserve at boundary 1: dev-dir, target path, coverage audit summary, plan-file, --keep items.
  • Preserve at boundary 2: dev-dir, changed files list, test outcomes.

Agent Resolution

export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
_DEV_SHARED=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/cc_develop}/bin/dev_shared_resolve.py" 2>/dev/null)  # timeout: 5000
[ -z "$_DEV_SHARED" ] && _DEV_SHARED="plugins/cc_develop/skills/_shared"
echo "$_DEV_SHARED" > "${TMPDIR:-/tmp}/dev-shared-${CSID}"  # cold resolve — every later block warm-reads this
# loads: compaction-contract.md
cat "$_DEV_SHARED/agent-resolution.md"

Contains: foundry check + fallback table. If foundry not installed: substitute each foundry:X with general-purpose per table. Agents skill uses: foundry:sw-engineer, foundry:qa-specialist, foundry:linting-expert, foundry:challenger.

export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
IFS= read -r _DEV_SHARED < "${TMPDIR:-/tmp}/dev-shared-${CSID}" 2>/dev/null || _DEV_SHARED=""  # timeout: 5000
[ -z "$_DEV_SHARED" ] && _DEV_SHARED="plugins/cc_develop/skills/_shared"
cat "$_DEV_SHARED/task-hygiene.md"

Read the full file on GitHub · 572 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 572 lines · 121 tokens per session scan A 4d726b4c1193

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository Borda/AI-Rig (25 stars, last pushed 9d ago), licensed Apache-2.0. It adds 121 tokens to every session and 8,120 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

apm-usage

Activate when the user asks about APM (Agent Package Manager): installing, configuring, authoring, or troubleshooting AI-agent packages, dependencies, compilation, MCP servers, policy, or any apm CLI command.

microsoft/apm · 49 tokens

clean-user-facing-text

Audit and finalize authorized natural-language text meant for readers: strip suspicious invisible Unicode, then rewrite prose while keeping facts, meaning, and the writer's voice. Use when the user asks to clean, humanize, polish, or finalize articles, manuscripts, reports, documentation, emails, product copy, UI…

ShadowAqueduct/watermark-remover · 121 tokens

sessions

Search and ask questions about coding agent session history across Claude Code, Codex, and Cursor. Use when asking what was worked on, what was tried before, how a problem was investigated across sessions, what happened recently, or any question about past agent sessions. Also use when the user references prior…

slopus/happy · 78 tokens

codex-autoresearch

Run autonomous, measurable experiments in a Git repository: change one hypothesis, verify a numeric metric, keep improvements, and revert failures. Use when the user wants Codex to keep iterating toward a numeric target in the foreground or as a detached background run. Do not use for ordinary one-shot coding…

leo-lilinxiao/codex-autoresearch · 80 tokens

daily-budget-check

Run a daily spend check-in against a daily budget on the Agent Monitor dashboard — today's spend vs the daily target, pace through the day, and the projected overage if the current pace holds. Uses /api/pricing/cost and /api/sessions (grouped by startedat = today). Use for a quick daily spend check-in or a…

hoangsonww/Claude-Code-Agent-Monitor · 81 tokens

ship-feature

Implement a feature safely end-to-end in this repository. Use when adding or changing functionality across backend, frontend, or MCP with required verification and documentation updates.

hoangsonww/Claude-Code-Agent-Monitor · 34 tokens