refactorx technical debt optimizer
A systematic technical debt analyzer and refactoring planner that ensures behavioral parity for Python codebases.
$7
Works with the AI Agents you already use
refactorx technical debt optimizer
Example session with this skill installed
Run a debt assessment on the auth module. Identify the highest priority smells and suggest a plan to reduce complexity in the login flow without breaking the public interface.
- Read your context and instructions
- Compiled the refactorx technical debt
I have completed the technical debt assessment for the auth module using code_metrics.py and debt_model.py. The login flow shows high cyclomatic complexity (C=14) and lacks proper characterization tests.
Technical Debt Audit: Auth Module
| Signal | Value | Metric ID | Findings |
|---|---|---|---|
| Complexity | 14 | DEBT-001 | LoginManager.authenticate exceeds recommended limit. |
| Duplication | 12% | DUP-001 | Token validation logic repeated in OAuthProvider and BasicAuthProvider. |
| Test Coverage | Low | DEBT-004 | No characterization tests found for edge cases in LDAP integration. |
| API Surface | Stable | API-001 | Public methods identified; no breaking changes allowed. |
Proposed Refactor Plan (RFX-001)
Characterization Phase: Create TestLoginBehavior to capture current outputs for valid, expired, and malformed tokens. Values must be frozen as-is.
2.
Decomposition Phase: Extract LDAP connectivity logic from authenticate into a private _verify_ldap_credentials method.
3.
Unification Phase: Centralize token verification.
Note: Verify if OAuth and Basic tokens follow the same business rule before merging.
4. Verification: Run api_surface_diff.py to ensure LoginManager.authenticate signature remains unchanged.
Next steps
- Approve the creation of characterization tests for the
authmodule. - Confirm if the duplication in
OAuthProviderrepresents a shared security policy or coincidental similarity. - Run
refactor_plan_check.pyon the draft JSON plan once characterization is green.
Connects securely to your tools. The creator never sees your data.
About this skill
Technical debt accumulates silently until it paralyzes your release cycle. This skill provides a systematic framework to measure, prioritize, and plan refactors for legacy codebases without breaking existing behaviors.
What it does
- Measure technical debt using objective signals like cyclomatic complexity, class size, and duplication density.
- Analyze code smells to identify high-interest debt that impacts maintenance costs.
- Detect clones with type-2 duplication analysis that accounts for renamed variables and literals.
- Plan safe refactors by enforcing a "characterization before modification" workflow to freeze current behavior.
- Protect public APIs by identifying potential breaking changes in method signatures and interfaces.
- Identify coupling issues to resolve circular dependencies and improve modularity.
How it works
- Scope the audit by defining target modules, performance constraints, and public API requirements.
- Execute measurement tools like
debt_model.pyandcode_metrics.pyto generate a prioritized debt index. - Formulate hypotheses for specific structural improvements and expected gains.
- Draft refactor plans in JSON format that separate structural changes from behavioral changes.
- Verify safety using API diff tools and plan checkers to ensure zero regression before any code is touched.
Frameworks & tools
This skill is optimized for Python codebases. It utilizes deterministic scripts for complexity analysis, duplication detection, and API surface auditing.
Why this beats prompting it yourself
Generic LLMs often suggest "cleaner" code that subtly changes logic or breaks undocumented edge cases. This skill enforces strict engineering constraints: no modification without characterization tests and no mixing of structural and behavioral commits.
Use cases
- Legacy code stabilization before adding new features to an untested module.
- Migration planning for framework upgrades or library swaps.
- Pull Request reviews specifically focused on refactoring safety and clean code standards.
- Audit reports to justify maintenance sprints to non-technical stakeholders.
Known limitations
Structural measurements and exact metrics are currently restricted to Python. Text-based clone detection requires manual verification to distinguish between shared logic and coincidental similarity.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.
Structural metrics are accurate for Python only. Duplication detection requires human review to confirm if identical code blocks represent the same business rule.
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 buying a skill.
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 2 days ago