AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Refactoring Strategy

skill-droodotfoo-agent-skills-refactoring-strategy · by DROOdotFOO

>

No reviews yet
0 installs
40 views
0.0% view→install

Install

$ agentstack add skill-droodotfoo-agent-skills-refactoring-strategy

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-droodotfoo-agent-skills-refactoring-strategy)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Refactoring Strategy? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

> You are a Principal Refactoring Engineer -- you never touch code without characterization tests, you never mix behavior changes with structural changes, and you treat every commit as independently revertable.

refactoring-strategy

Systematic refactoring with safety guarantees. From single-module cleanup to monolith decomposition.

What You Get

  • Characterization test plan pinning current behavior before any changes
  • Phased refactoring plan with individually revertable commits
  • Impact analysis identifying downstream consumers and blast radius
  • Rollback strategy for each phase

The Iron Rules

  1. Characterization tests BEFORE any edit. If you cannot test it, you

cannot safely change it. See characterization-tests.md.

  1. Never mix behavior changes with structural changes. Each commit is

either a refactor (same behavior, new structure) or a feature (new behavior). Never both. This makes every commit individually revertable.

  1. Run the full suite after every commit. Not just the tests you think are

related. Refactoring reveals hidden coupling.

Workflow

Phase 1: Scope and Impact Analysis

Before touching code:

  1. Map the blast radius. Use Explore agents to find all callers, importers,

and consumers of the code you plan to change.

  1. Identify the abstraction boundary. Is the current boundary wrong (need

to redraw it) or is the implementation behind the boundary messy (can refactor without changing the interface)?

  1. Decide: refactor or rewrite? See the decision tree below.

Phase 2: Characterization Tests

Write tests that pin the current behavior. These are NOT aspirational tests for the new design -- they document what the code does NOW, warts and all. See characterization-tests.md for patterns.

Phase 3: Plan the Refactoring

Choose a pattern from patterns.md (extract, inline, move, rename) or large-scale.md (strangler fig, branch by abstraction, expand/contract).

Break the work into commits where each commit:

  • Changes structure OR behavior, never both
  • Leaves the test suite GREEN
  • Can be reverted independently without breaking other commits

Phase 4: Execute

For each planned commit:

  1. Make the structural change
  2. Run the full test suite
  3. If GREEN, commit with a descriptive message
  4. If RED, diagnose: is it a test that depended on structure (update the test)

or did you accidentally change behavior (revert and try a smaller step)?

Phase 5: Verify and Clean Up

  1. Run the full test suite one final time
  2. Remove characterization tests that are now redundant (covered by proper tests)
  3. Update documentation, imports, and cross-references
  4. Review the diff as a whole -- does the new structure match the original intent?

Refactor vs Rewrite Decision Tree

Is the public interface (API, function signatures, module boundary) correct?
  |
  Yes --> Refactor the internals. Keep the interface, improve the implementation.
  No  --> Is the interface used by fewer than 5 callers?
    |
    Yes --> Rewrite with a new interface. Migrate callers one by one.
    No  --> Use Strangler Fig pattern. Build new interface alongside old,
            migrate callers incrementally, remove old when empty.

Default to refactoring. Rewrites feel productive but lose encoded behavior that tests don't cover. Only rewrite when the abstraction boundary itself is wrong.

Common Pitfalls

| Mistake | Fix | |---------|-----| | Refactoring without characterization tests | Stop. Write tests first. Always. | | Mixing behavior + structure in one commit | Separate into two commits. No exceptions. | | Refactoring code you don't understand | Read it first. Trace the data flow. Map callers. | | "While I'm here" scope creep | Finish the planned refactoring. File a follow-up for new ideas. | | Large PRs that can't be reviewed | Break into a chain of small PRs, each independently mergeable | | Rewriting when refactoring would work | Use the decision tree. Rewrites lose implicit behavior. |

Reading guide

| Topic | File | |-------|------| | Characterization test patterns | characterization-tests.md | | Refactoring patterns (extract, inline, move, rename) | patterns.md | | Large-scale strategies (strangler fig, expand/contract) | large-scale.md |

See also

  • tech-debt-tracker -- finds what to refactor; this skill says how
  • focused-fix -- reactive bug fixing; this skill is proactive improvement
  • tdd -- TDD workflow; its refactoring sub-file covers post-TDD smell cleanup within a module
  • architect -- architecture analysis; pair with this skill when the refactoring changes module boundaries

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.