- Home
- Skills
- Code Quality & Review
- StreamTeem Refactor
Works with the AI Agents you already use
StreamTeem Refactor
Stop shipping fragile code and start making structural improvements with confidence.
$1.99
StreamTeem Refactor
Example session with this skill installed
Refactor the OrderProcessor class in src/services. It's too long and handles both validation and database persistence. I want to keep all behavior the same.
- Read your context and instructions
- Compiled the streamteem refactor
I have analyzed OrderProcessor.ts and categorized this as a
Planned refactor because it involves splitting responsibilities and potentially changing internal interfaces.
Refactor: Decouple OrderProcessor Logic
| Metric | Baseline | Post-Refactor |
|---|---|---|
| Unit Tests | 14 Passed, 0 Failed | 18 Passed (4 new pinning tests) |
| Integration Tests | 5 Passed | 5 Passed |
| Linter Warnings | 2 (Complexity) | 0 |
| Files Changed | src/services/OrderProcessor.ts | OrderProcessor.ts, OrderValidator.ts, OrderRepository.ts |
Changes Made
- Extracted Validation: Moved logic from
OrderProcessor.validate()to a newOrderValidatorclass. - Extracted Persistence: Moved
db.save()calls to a dedicatedOrderRepository.
Pinned Behavior: Added characterization tests for the DiscountError edge case to ensure the specific error message string remained identical.
- Cleaned Up: Removed unused imports for
db-clientwithin the main service.
Found Along the Way
- Found a potential bug in
calculateTax()where rounding occurs twice; recorded in a characterization test but not "fixed" to preserve current behavior. - Identified that
OrderRepositorycould be shared withRefundServicein a future refactor.
Next steps
- Review the new
OrderValidator.tsandOrderRepository.tsfiles for architectural alignment. - Approve the fix for the tax rounding bug identified during the baseline phase.
- Merge the characterization tests into the main branch to prevent future regressions.
Connects securely to your tools. The creator never sees your data.
About this skill
Stop shipping fragile code and start making structural improvements with confidence. This skill provides a systematic approach to refactoring that prioritizes safety and behavior preservation. It addresses the common pain point of "refactor-induced regression" by enforcing a strict workflow: baseline testing, pinning untested behavior, and executing small, reversible steps.
What it does
- Pin behavior using characterization tests to capture current logic (even "odd" behavior) before structural changes.
- Size work by categorizing tasks as Quick, Planned, or Large to prevent scope creep.
- Diagnose smells with evidence-based findings mapped to specific files and line numbers.
- Verify integrity through post-refactor comparisons against baseline test results, linting, and public surface checks.
- Detect side effects by monitoring return values, error types, side-effect ordering, and concurrency.
How it works
- Baseline and Scope: The skill checks
git status, runs the full test suite, and records a baseline of passes, fails, and warnings. - Safety Net: It analyzes coverage and writes characterization tests for untested paths to create a seam for safe editing.
- Planning: For non-trivial work, it generates a step-by-step plan into a decision log for approval.
- Execution: It applies changes one at a time, verifying with tests after every single modification to ensure green status.
Frameworks & tools
Works with any stack using git and local test runners. Integrates with language-specific refactoring tools, coverage reporters, and project linters.
Why this beats prompting it yourself
Generic prompts often lead to "rewrite" behavior that introduces bugs or changes public APIs. This skill enforces a professional engineering workflow that guarantees behavior remains identical while making the code significantly cheaper to maintain.
Use cases
- Decoupling logic from global state to enable unit testing.
- Consolidating duplicate logic before adding new features.
- Breaking down "God classes" or oversized functions into manageable units.
- Cleaning up legacy codebases where the original intent is undocumented.
Known limitations
Does not support codebases without an executable test suite or environments where build tools are inaccessible. Requires user intervention if public interfaces have external callers.
Requires an executable test suite and a clean git state. Cannot safely refactor code without a way to verify behavior. Limited to internal repository scope for public interface changes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 4 days ago
Requires
Permissions
Shell to run git status and the project test suite. Read/write to change code and add characterization tests. Verifies after every step.