refactor

Refactor code in isolated git worktrees with test-gated atomic changes.

19|2|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/bjornjee/agent-dashboard --skill refactor-bjornjee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/bjornjee/agent-dashboard/tree/main/adapters/claude-code/skills/refactor
Command: npx skills add https://github.com/bjornjee/agent-dashboard --skill refactor-bjornjee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill restructures code without changing its behavior, reducing the risk of breaking functionality during large or complex refactors.

Core Features & Use Cases

  • Isolated worktree refactoring: Creates an isolated git worktree from the latest main on a dedicated refactor branch to keep experiments contained.
  • Environment-preserving setup: Copies .env* files and optional Claude local settings into the worktree while validating they match the source repo.
  • Test-gated incremental transformation: Runs make test before and after each atomic change, reverting only the failed files to quickly recover.
  • Workflow-safety PR flow: Opens the PR via /agent-dashboard:pr so cleanup, formatting, tests, and push are handled by the dashboard’s gatekeeper.

Quick Start

Ask your agent to run refactor with the goal "separate the business logic from the HTTP handlers and keep behavior identical" so it creates a safe worktree, verifies env files, establishes a passing test baseline, and performs test-checked atomic changes.

Frequently Asked Questions about refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor code safely without breaking existing behavior?

Test-gated refactoring works by running make test before and after each atomic code change. If a test fails, the workflow automatically reverts only the failed files to quickly recover, ensuring the codebase maintains a passing test baseline throughout the incremental transformation.

How do I set up a git worktree for isolated code refactoring?

Setting up a git worktree for isolated refactoring requires branching from the latest main. You must exactly copy and verify .env* files and optional local settings into the worktree, validating they match the source repo to preserve the environment configuration before starting transformations.

Can I delegate large scope refactoring tasks to an agent?

Refactoring at scale is managed through incremental single-change commits and optional Codex delegation for large scopes. The workflow isolates transformations in a dedicated git worktree branch, running per-step regression testing and opening the final PR via /agent-dashboard:pr to handle cleanup, formatting, and push.

What is the best way to structure commits during a complex code refactor?

The best way to structure commits during a complex refactor is using conventional commits for incremental single-change transformations. Each atomic change is committed independently after passing test gating, creating a clear history that isolates failures and simplifies reverting specific files if needed.