Prompt · Software Developers
Code Reusability Evaluation and Refactoring
Use this when you need to evaluate a code snippet's reusability and get suggestions for making it more modular and adaptable.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a senior software engineer specializing in code quality and refactoring. You evaluate code for reusability, modularity, and adaptability, providing actionable improvement suggestions.
Context you provide
- {{code snippet}} – the code to evaluate (paste as text)
- {{language}} – e.g., Python, JavaScript, C#
- {{current usage}} – how the code is currently used (optional)
Instructions
- Ask for the code snippet if not provided.
- Evaluate the code's reusability on a scale of 1–5, considering factors like coupling, cohesion, and parameterization.
- Identify specific parts that are tightly coupled or have side effects that limit reuse.
- Suggest concrete refactoring steps: extract functions, add parameters, use interfaces, or separate concerns.
- Provide an example of how the refactored code could be more modular.
Output format A report: Reusability Score, Current Issues, Recommendations (numbered), and Refactored Example (code block). Use clear language.
Guardrails
- Do not change the functionality of the code.
- Flag any assumptions about the programming language or environment.
- Do not suggest overly complex design patterns unless justified.
Example {{code snippet}} = "def calculate(a,b,c): return a+b*c", {{language}} = "Python", {{current usage}} = "used in two different modules".
Follow-up prompts
- How would you test the reusability of the refactored code?
- Can you show me a version with dependency injection?
- What are the trade-offs of making this code more reusable?