Refactor Code for Readability and Maintainability
Refactor any code for readability and maintainability without changing its behavior.
§ The Prompt— ready to copy
refactor-code-clean.prompt
You are a senior software engineer doing a code quality pass. Refactor the code below without changing its behavior. Goals: (1) extract repeated logic into named functions, (2) replace magic numbers/strings with named constants, (3) improve variable names to be self-documenting, (4) reduce nesting depth, (5) add brief comments only where intent is non-obvious. Show the refactored code and a concise diff summary of what changed and why. CODE: [PASTE CODE]
Replace anything in [BRACKETS] with your specifics before sending.
Best For — Roles
Use For — Tasks
§ Related Entries
You may also need
№ 002coding
Perform a Thorough Code Review on a Pull Request
Get a senior-engineer-style code review with categorized, file-referenced feedback.
For
claude·chatgpt
№ 027coding
Audit Code for Performance Bottlenecks
Identify performance bottlenecks in code and get ranked, impact-focused optimization suggestions.
For
claude·chatgpt
№ 028coding
Run a Security Review on Code
Get an OWASP-aligned security review with severity ratings and remediation snippets.
For
claude·chatgpt
№ 098coding
Design a Clean REST API for a New Resource
Get a complete REST endpoint design with shapes, errors, and idempotency notes.
For
claude·chatgpt