surgeon

Refactor a single module with tests after every edit.

1|Updated May 18, 2026
One-click install
npx skills add https://github.com/linenoize/topia --skill surgeon-linenoize
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: surgeon
Source: https://github.com/linenoize/topia/tree/main/skills/surgeon
Command: npx skills add https://github.com/linenoize/topia --skill surgeon-linenoize

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Surgeon enables disciplined, low-risk refactoring when a codebase needs improvement but cannot afford broad or speculative changes. It keeps the work constrained to one module per session, so changes stay understandable, testable, and reversible.

Core Features & Use Cases

  • Single-module refactoring: Focuses on one target module and refuses to exceed a five-file blast radius.
  • Safety-first workflow: Requires preexisting safeguard coverage, runs tests after every edit, and stops immediately if tests fail.
  • Pattern-guided changes: Supports Strangler Fig, Branch by Abstraction, Expand-Migrate-Contract, and Extract & Simplify depending on the refactor shape.
  • Production-ready follow-through: Ends with review, commit, and journal updates so the session leaves a clear audit trail.
  • Use case: A team can use this Skill to break apart a fragile legacy module incrementally while preserving behavior and keeping each step shippable.

Quick Start

Use surgeon to safely refactor the target module in a single, test-validated session without exceeding the five-file blast radius.

Frequently Asked Questions about surgeon

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

FAQPage Schema
How do I safely refactor tightly coupled legacy code without breaking working features?

Legacy code refactoring is safest when constrained to one module per session. This workflow enforces a strict five-file blast radius, verifies safeguards, and runs tests after every edit to incrementally rewrite tightly coupled modules without breaking existing behavior.

What is the best way to incrementally rewrite a fragile module while preserving behavior?

Incremental module rewriting uses pattern-guided changes like Strangler Fig or Branch by Abstraction. This approach isolates legacy behavior and applies per-edit testing, ensuring each refactor step remains understandable, testable, and reversible without broad speculative changes.

Do I need existing test coverage before starting a single-module refactoring session?

Yes, test coverage is a prerequisite for safe refactoring. This safety-first workflow requires preexisting safeguard coverage to validate behavior, stopping immediately if tests fail after an edit to prevent regressions in the target module.

How does a blast-radius check work when refactoring code architecture?

A blast-radius check limits architectural refactoring impact by refusing changes that exceed a five-file scope. This constraint keeps the work focused on a single module, making changes understandable and reversible while preventing unintended damage to the broader codebase.

Can I use Strangler Fig and Branch by Abstraction patterns for module refactoring?

Yes, pattern-guided refactoring supports Strangler Fig, Branch by Abstraction, Expand-Migrate-Contract, and Extract & Simplify. These patterns guide the refactor shape depending on the module's architecture, ensuring disciplined and low-risk structural changes.

What happens after a safe code refactoring session is completed?

After safe code refactoring, the session ends with a production-ready follow-through. This process includes a final code review, a commit of the isolated changes, and a journal update to leave a clear audit trail of the incremental structural improvements.