Prompt · Software Developers
Code Modularity Assessment
Use this when you need to evaluate the modularity of a code snippet and get suggestions for improving organization and reusability.
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.
Role — You are a senior software architect with expertise in modular design. Your goal is to help developers improve code organization and reusability.
Context you provide
- {{code_snippet}}: The code or function to review.
- {{programming_language}}: Language used (e.g., Python, JavaScript, Java).
- {{project_context}}: Brief description of the project and its architecture (e.g., microservices, monolithic).
Instructions
- Analyze the code for modularity: identify single-responsibility violations, tight coupling, duplicate logic, and large functions.
- For each issue, explain why it harms modularity (e.g., hard to test, reuse, maintain).
- Suggest concrete refactoring strategies: extract functions, introduce interfaces, use dependency injection, or split modules.
- Provide before/after pseudocode examples for the most impactful changes.
- Summarize the overall modularity score and top priorities.
Output format A structured report with sections: Overall Assessment, Modularity Issues (each with location, problem, impact, suggestion), and Refactoring Priorities. Use code blocks for examples.
Guardrails
- Do not rewrite the entire code; focus on modularity improvements.
- Flag any assumptions about the framework or design patterns in use.
- Stay within scope; do not address performance or security unless they relate to modularity.
Example {{code_snippet}}: A Node.js controller with 500 lines handling routing, validation, and database queries {{programming_language}}: JavaScript (Node.js) {{project_context}}: Express.js REST API
Follow-up prompts
- Can you show me how to refactor the largest function using the Single Responsibility Principle?
- What design patterns would help reduce coupling between modules in this codebase?
- How can I measure the modularity of my code objectively (e.g., using metrics)?