- Home
- Skills
- Code Quality & Review
- Refactor boundary and invariant plan
Refactor boundary and invariant plan
For software architects: an incremental extraction plan tied to preserved invariants.
$12
Works with the AI Agents you already use
Refactor boundary and invariant plan
Example session with this skill installed
Analyze the attached PaymentProcessor class (S1). I need to split the refund logic into a separate RefundService while preserving the transaction logging invariant.
- Read your context and instructions
- Compiled the refactor boundary
The requested split of the refund logic from PaymentProcessor (S1) is feasible. The primary constraint is the audit_log side effect which must be synchronized across the new boundary.
Incremental Extraction Plan
| Item | Input evidence | Status | Proposed action | Verification |
|---|---|---|---|---|
| Refund Logic | S1: lines 45-89 | Supported | Extract process_refund to RefundService | Unit test RefundService.process() matches S1 output |
| Logging Invariant | S1: line 12, 55 | Supported | Inject ILogger into RefundService | Verify audit_log entries persist after extraction |
| State Dependency | S1: self._db_session | Unknown | Define database transaction boundary | Confirm if RefundService shares the session object |
Step-by-Step Execution
- Define Interface: Create
IRefundServicewith aprocessmethod matching the signature in S1. - Isolate Side Effects: Wrap the
audit_logcall in S1:55 into a sharable logging component.
Draft Extraction: Move lines 45-89 to the new service. Keep the original method as a deprecated wrapper calling the new service.
4. Verification: Run existing PaymentProcessor tests. If audit_log fails, rollback to the wrapper state.
Missing Inputs
- The definition of
self._db_session(S1:20) is not fully visible; need to know if it supports nested transactions.
Next steps
- Provide the
db_sessioninitialization logic to resolve the transaction boundary. - Review the proposed
IRefundServiceinterface for compatibility with your DI container. - Execute Step 1 and verify the seam with a mock logger.
Connects securely to your tools. The creator never sees your data.
About this skill
Use this skill when you have a small module excerpt and desired responsibility split and need an incremental extraction plan tied to preserved invariants.
The workflow:
- Map inputs, outputs and side effects to the current module.
- Identify one responsibility boundary and the invariants it must preserve.
- Order small extractions with a test at each seam and a rollback point.
- Keep public behavior unchanged unless the request explicitly changes its contract.
You receive the work product with input-linked findings, visible unknowns and concrete verification checks. Work from pasted or redacted text. This skill does not execute changes, send messages or access service accounts.
Original AI-assisted content. A synthetic worked example is included. Use through your Agensi-connected agent. No extra paid API or runtime is required for this workflow. Delivery is through the Agensi agent connection. No sales, ranking or compliance outcome is promised.
Limited to small module excerpts. Requires manual input of code and context. Cannot execute commands or modify files directly.
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 5 days ago