refactor

refactor is a skill for Claude Code from bjornjee/agent-dashboard. It costs 20 tokens per session (1,473 once invoked), scanned A, original, MIT.

A workflow for restructuring code in an isolated Git worktree while preserving existing tests and behaviour.

In plain words
What is it for?
Use it for incremental code refactors, including projects that involve browser interfaces, Playwright tests, or development servers.
Why use it?
It breaks refactoring into setup, scope, change, and verification stages with checks before moving on.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions Claude Code; mentions Codex.

Part of the agent-dashboard plugin — 8 skills, 5 agents, 10 hooks shipped together

Good fit Use it for incremental code refactors, including projects that involve browser interfaces, Playwright tests, or development servers.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/bjornjee/agent-dashboard/refactor
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.

Any agent
npx skills add bjornjee/agent-dashboard --skill refactor
Clone the repo
git clone --depth 1 https://github.com/bjornjee/agent-dashboard

Made for: Claude Code.

Or install agent-dashboard, the plugin that ships this one along with the rest of its 8 skills, 5 agents, 10 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/bjornjee/agent-dashboard/refactor/github.svg)](https://agentmods.dev/skills/bjornjee/agent-dashboard/refactor)
Your own site
<a href="https://agentmods.dev/skills/bjornjee/agent-dashboard/refactor"><img src="https://agentmods.dev/badge/skills/bjornjee/agent-dashboard/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/bjornjee/agent-dashboard/refactor"><img src="https://agentmods.dev/badge/skills/bjornjee/agent-dashboard/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,473 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.00020 $0.01473
Opus 5.5 $0.00008 $0.00589
Sonnet 5.5 $0.00004 $0.00295
Haiku 4.5 $0.00002 $0.00147

Measured 1mo ago against content hash 7cc46f37d95f, 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 1mo 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.

adapters/claude-code/skills/refactor/SKILL.md · 114 lines

How it starts

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

Safely refactor code while preserving all existing behavior.

Refactoring goal: $ARGUMENTS

Instructions

Follow these phases in order. Each phase has a gate — do not proceed until the gate is satisfied. Apply all project rules and conventions that are in your context.

If the refactor touches browser UI, Playwright, dev-server ports, screenshots, or interactive Browser/Chrome inspection, apply ../_shared/ui-automation.md at scoping, environment setup, baseline, verification, delegation, and cleanup points.


Phase 1: Setup

Follow ../_shared/worktree-setup.md with branch prefix refactor.

Gate: Working directory is the new worktree on the correct branch, based on latest main. If .env* files existed in the source repo, they are all present in the worktree.


Phase 2: Scope

Start two tracks in parallel:

Background — Environment setup: First check for a reusable environment: if .env-setup-done exists in the worktree root AND every dependency manifest/lockfile present (package-lock.json, pnpm-lock.yaml, yarn.lock, requirements.txt, pyproject.toml, uv.lock, go.mod, go.sum) is older than the sentinel ([ "$f" -ot .env-setup-done ]), skip the launch and note the reuse — the setup from a prior run in this worktree is current. Otherwise, launch a background agent (run_in_background: true) to set up the dev environment per ../_shared/env-setup.md.

Foreground — Scoping:

  1. Parse the refactoring goal — what is being restructured and why?
  2. Identify all affected files by searching the codebase for the code to be changed and its dependents.
  3. Check test coverage for the affected code — what tests exist? What is untested?
  4. If test coverage is insufficient for safe refactoring, tell the user and suggest writing tests first before refactoring.

Gate: The scope is clear. Affected files and their test coverage are identified.


Phase 3: Baseline

Pre-gate: Check for .env-setup-done in the worktree root.

  • If present: verify dependencies are installed (e.g. node_modules/ exists, pip list succeeds, go env GOPATH works) and data symlinks resolve correctly.
  • If .env-setup-failed exists: surface the error and halt.
  • If neither file exists: the background agent is still running — wait for it to finish before proceeding.

Read the full file on GitHub · 114 lines

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. 1mo ago First seen · 114 lines · 20 tokens per session scan A 7cc46f37d95f

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository bjornjee/agent-dashboard (26 stars, last pushed 3mo ago), licensed MIT. It adds 20 tokens to every session and 1,473 once invoked, about $0.0001 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.