refactor-a-bead

Coordinate a refactor-shaped bead through the M1–M4 stage workflow.

Updated May 3, 2026
One-click install
npx skills add https://github.com/fkberthold/loom --skill refactor-a-bead
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-a-bead
Source: https://github.com/fkberthold/loom/tree/main/skills/refactor-a-bead
Command: npx skills add https://github.com/fkberthold/loom --skill refactor-a-bead

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Coordinates a refactor-shaped bead to preserve behavior while restructuring code.

Core Features & Use Cases

  • Coordinates a dedicated refactor middle that runs between scope identification and verification, deferring lifecycle operations to the bead-lifecycle-shell.
  • Enforces a tripwire-based process: scope, characterization tests, careful restructuring, and behavior verification.
  • Use case: when refactoring a module to consolidate duplicated logic while preserving public behavior.

Quick Start

Brief the worker with the exact scope and expected preserved behavior, then initiate M1 to identify scope.

Frequently Asked Questions about refactor-a-bead

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

FAQPage Schema
How do I refactor code without changing its behavior?

Restructuring code without changing behavior requires a stage-based workflow: identify scope, write tripwire characterization tests, restructure carefully, then verify no observable behavior changes occurred.

What are characterization tests and how do they protect a code refactor?

Characterization tests act as tripwires during a code refactor by pinning down current module behavior, ensuring your restructuring preserves the exact public outputs and prevents regressions throughout the process.

What is the best way to consolidate duplicated logic while preserving public behavior?

Consolidating duplicated logic safely requires a structured M1–M4 stage workflow that scopes the duplication, establishes characterization tests, restructures the code, and verifies behavior preservation.

How do I start a workflow to restructure code safely?

To start restructuring code safely, you first identify the exact scope and expected preserved behavior during the M1 stage, briefing the worker before initiating characterization and restructuring phases.

When should I not use a stage-based workflow for refactoring?

A stage-based refactoring workflow is unnecessary when modifying observable behavior rather than restructuring internal structure, as it is designed specifically to enforce behavior preservation through characterization tests.