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

Test Preserving Refactor

skill-yeaight7-agent-powerups-test-preserving-refactor · by yeaight7

Use when code needs restructuring and observable behavior must stay unchanged, with existing tests kept green at every step.

— No reviews yet
0 installs
34 views
0.0% view→install

Install

$ agentstack add skill-yeaight7-agent-powerups-test-preserving-refactor

✓ 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-yeaight7-agent-powerups-test-preserving-refactor)

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 Test Preserving Refactor? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Purpose

Refactoring is only safe if it is backed by tests. Work in a strict loop — green baseline, one structural change, immediate re-run, revert on red — so you are never trapped in an uncompilable state.

When to Use

  • Code needs restructuring (extract/inline/move) without behavior change
  • A previous refactor spiraled into a broken, hard-to-recover state
  • Tests covering the target area exist or can be run

Inputs

  • The target area and the command that runs just its tests

Workflow

  1. Run tests first. Before touching any code, run the tests covering the target area. They MUST be green. If they are red, stop and fix the tests (or the code) first:

``bash npx jest path/to/target # or: pytest tests/test_target.py -q ``

  1. Small steps. Make one structural change at a time (e.g., extract a method).
  1. Run tests immediately after the single structural change. The per-change loop:

``bash # repeat per structural change: edit -> test -> commit (green) | revert (red) npx jest path/to/target && git commit -am "refactor: extract X" || git checkout -- . ``

  1. Revert on red. If the tests fail, you made a mistake. Revert the change (git checkout -- . or git restore .) and try a different approach. Do not attempt to "fix" the refactor while tests are failing.
  1. Commit on green. Once the small change is green, consider it a safe checkpoint.

This strict loop prevents you from getting trapped in an uncompilable state.

Output

  • A chain of small, individually green commits
  • The final test run output proving unchanged behavior

Verification

  • [ ] Baseline test run was green before the first edit
  • [ ] Exactly one structural change per test cycle
  • [ ] Every red result handled by revert, not forward-fixing
  • [ ] Each green step committed as a checkpoint
  • [ ] No test was modified to make the refactor pass

Failure Modes

  • Refactoring on red — starting from failing tests means you cannot tell what you broke.
  • Step batching — three changes per test run; when it fails, you don't know which one did it.
  • Forward-fixing a broken refactor — "fixing" while red digs the hole deeper; revert is cheaper.
  • Bending the tests — editing assertions to match new behavior is a behavior change, not a refactor.

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.