refactor

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 CodeCodex

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/bjornjee/agent-dashboard/refactor
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, Codex.

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. 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.00020 $0.01473
Opus 5 $0.00010 $0.00737
Sonnet 5 $0.00004 $0.00295
Haiku 4.5 $0.00002 $0.00147

Measured 2d ago against content hash 7cc46f37d95f, 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 2d 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. 2d 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 (21 stars, last pushed 1mo ago), licensed MIT. It adds 20 tokens to every session and 1,473 once invoked, about $0.0001 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

webapp-testing

Start/reuse a local app, wait for readiness, inspect rendered state/console/network, act from observed selectors, and verify with evidence.

Hmbown/CodeWhale · 32 tokens

tutti-workspace-app-factory

Create, convert, or repair one Tutti workspace app as either a self-contained publishable package under package/ or a Chrome-style local debug app under .tutti/dev-app/. Use for mention://workspace-app-factory/create handoffs, mention://workspace-app-factory handoffs, standalone app generation, adapting existing…

tutti-os/tutti · 138 tokens

tutti-record-agent-session-replay

From a Tutti checkout, run, audit, freshly replay, publish, or diagnose Session Replay cassettes that are driven by case-repository scenario scripts (CDP), not by interactive UI recording. Use for real-Provider capture while a scenario.mjs executes, cassette transport or semantic-state mismatches, fresh replay…

tutti-os/tutti · 127 tokens

qa

Browser-based QA verification. Launches a real browser, navigates the app, clicks buttons, fills forms, and tests user flows. Works as a standalone skill or as a phase end condition in campaigns. Requires Playwright (optional dependency, graceful skip if not installed).

SethGammon/Citadel · 56 tokens

browser

Browser automation via the agent-browser CLI. Use when the user needs to drive websites or Electron desktop apps — navigating, filling forms, clicking, screenshots, extracting data, testing web apps, visual UI checks, the Pi Dashboard's Electron shell, or the user's own logged-in browser (SSO/2FA sites). Triggers…

BlackBeltTechnology/pi-agent-dashboard · 92 tokens

canvas-webapp

Render a React/Vite (or any bundled) web app on the pi-dashboard canvas, which loads loopback URLs in a sandboxed opaque-origin iframe. Use when a canvas(target:{kind:"url"|"server"}) target shows up blank white, an empty surface, or a /live/ 500 ECONNREFUSED. Covers why Vite dev servers and non-CORS static servers…

BlackBeltTechnology/pi-agent-dashboard · 99 tokens