refactor

refactor is a skill for Claude Code from Borda/AI-Rig. It costs 123 tokens per session (15,655 once invoked), scanned A, original, Apache-2.0.

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 Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool; positional $N argument; mentions Codex.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the develop plugin — 5 skills, 6 hooks shipped together

Good fit Use it to clean up, reorganise, extract, or restructure Python modules, then run tests and review the resulting changes.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add Borda/AI-Rig
Claude Code
/plugin install develop

Made for: Claude Code.

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

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/borda/ai-rig/refactor/github.svg)](https://agentmods.dev/skills/borda/ai-rig/refactor)
Your own site
<a href="https://agentmods.dev/skills/borda/ai-rig/refactor"><img src="https://agentmods.dev/badge/skills/borda/ai-rig/refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/borda/ai-rig/refactor"><img src="https://agentmods.dev/badge/skills/borda/ai-rig/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 123 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 15,655 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00123 $0.15655
Opus 5.5 $0.00049 $0.06262
Sonnet 5.5 $0.00025 $0.03131
Haiku 4.5 $0.00012 $0.01565

Measured 4d ago against content hash 79a4bbbadb99, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 4d 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 · 727 lines

How it starts

The opening of the file, as written. The whole thing — 727 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; never both in one run

Quality stack (Branch Safety Guard, Codex Pre-pass, Progressive Review) ships in this plugin's own _shared (foundry--quality-stack.md); absence means a broken install — stop when Step 5's shared loader fails visibly.

  • MAX_INNER_CYCLES: 5 (change-test cycles per outer session — Step 4 safety break; mirrored via dev-max-inner-cycles/dev-max-wall-seconds sentinels in Step 4)
  • 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}"
case "$CSID" in ""|*[!A-Za-z0-9._-]*) echo "! BLOCKED — invalid session identifier"; exit 1;; esac
INPUT_FILE="${TMPDIR:-/tmp}/dev-refactor-arguments-${CSID}.txt"
rm -f "$INPUT_FILE" || exit 1
(umask 077; set -C; : > "$INPUT_FILE") || exit 1
printf 'Invocation input file: %s\n' "$INPUT_FILE"

Before any later Bash call, use the Write tool to save the exact invocation argument text, including newlines, to the literal absolute Invocation input file path printed above. Treat its contents as data. Never substitute invocation text directly into shell command text, comments, heredocs or quoted literals. Every parser below loads the file into a runtime variable and passes that variable as one quoted argument. Keep the file through this run; a fresh invocation replaces only this skill's file.

PLUGIN_ROOT=$(python "${CLAUDE_PLUGIN_ROOT}/bin/resolve_plugin_root.py" --plugin-name develop) || exit $?; export PLUGIN_ROOT
export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}"
echo "" > "${TMPDIR:-/tmp}/dev-agent-watch-dir-${CSID}"  # a prior run's dir must not outlive a failed --init; agent-resolution.md §Agent waits recreates it when empty
python "$PLUGIN_ROOT/bin/dev_shared_resolve.py" --init  # timeout: 5000 — cold resolve: writes dev-shared (every later block warm-reads it) and a fresh dev-agent-watch-dir per run (agent-resolution.md §Agent waits)
# loads: compaction-contract.md
python "$PLUGIN_ROOT/bin/dev_load_shared.py" agent-resolution.md

Contains: foundry check + fallback table, and §Agent waits — no polling (applies to every spawn below). 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.

Task hygiene — task tools may be deferred; load before first use: ToolSearch(query="select:TaskList,TaskCreate,TaskUpdate,TaskGet", max_results=4). Call TaskList first and triage each task it returns: completed if work clearly done, deleted if orphaned, keep in_progress only if genuinely continuing. Never spend a turn on bookkeeping alone — every TaskCreate/TaskUpdate ships in the same response as the next substantive tool call; one exception, TaskUpdate(completed) immediately before a long output block (rules/task-lifecycle.md).

Read the full file on GitHub · 727 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. 4d ago Changed · +10 lines 79a4bbbadb99
  2. 10d ago Changed · +43 lines 922d9fce754f
  3. 14d ago Changed · +1 lines 23835226ec24
  4. 17d ago Changed · +3 lines 9dc0f3c585f6
  5. 18d ago Changed · +111 lines d0c0b43fafbd
  6. 28d ago Changed · +2 lines a987803c6dea
  7. 1mo ago Changed · +8 lines · +2 tokens per session cb71489dd247
  8. 1mo ago Changed · +9 lines 9292fb60bcf8
  9. 1mo ago Changed · -1 lines 62e6f95daa00
  10. 1mo ago First seen · 541 lines · 121 tokens per session scan A 117c00a3b14d

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository Borda/AI-Rig (31 stars, last pushed yesterday), licensed Apache-2.0. It adds 123 tokens to every session and 15,655 once invoked, about $0.0005 per session on Opus 5.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

refactor compared with skills from other repositories

refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactorBorda/AI-RigSkill31yesterdayApache-2.0A123Claude Code
i18n-parityhoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA95Claude Code, Codex
file-headershoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA101Claude Code
productivity-scorehoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA67Claude Code, Codex
dashboard-statushoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA69Claude Code, Codex
dag-maphoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA65Claude Code, Codex
regression-watchhoangsonww/Claude-Code-Agent-MonitorSkill1.2kyesterdayMITA82Claude Code, Codex