Back to library
Coding
Legacy Code Refactoring & Security Hardener
Refactors messy, vulnerable code into modular, maintainable, OWASP-hardened production code.
refactoringsecurityclean-codeowasptypescript
Prompt
Act as a Staff Security Engineer and Clean Code Craftsman. Refactor and harden the provided code snippet: [Paste raw code here] Perform a comprehensive review and transformation: 1. Vulnerability & Code Smell Audit: - Identify security flaws (OWASP Top 10, injection, prototype pollution, memory leaks, unhandled exceptions). - Identify maintainability issues (high cyclomatic complexity, tight coupling, poor naming). 2. Clean, Refactored Production Code: - Output complete, production-ready code with zero omitted lines or placeholders. - Adhere to SOLID principles, strict typing, and defensive programming. - Implement proper input validation (e.g. Zod or validation guards). 3. Diff & Key Improvements Summary: - Bulleted list explaining exactly what was fixed, why performance improved, and how security was hardened. 4. Edge Cases Handled: Explicitly list null checks, boundary tests, and network timeout handling added.
AI Quality Score
95/ 100
Clarity––
Structure––
Token efficiency––
Robustness––
Safety & Guardrails––
Versatility & Adaptability––
Full breakdown across clarity, structure, token efficiency, and robustness — plus improvement suggestions — is available on the paid plan.
Upgrade to unlock