Skip to main content
Prompts Code Improvement and Refactoring Suggester

developer coding template risk: low

Code Improvement and Refactoring Suggester

Improves provided code by suggesting enhancements for readability and maintainability, performance optimization, best practices and patterns, and error handling with edge cases. De…

PROMPT

Improve the following code

```
${selectedText}
```

Please suggest improvements for:
1. Code readability and maintainability
2. Performance optimization
3. Best practices and patterns
4. Error handling and edge cases

Provide the improved code along with explanations for each enhancement.

INPUTS

selectedText REQUIRED

The code snippet to improve

REQUIRED CONTEXT

  • code snippet

EXPECTED OUTPUT

Format
markdown
Constraints
  • provide improved code
  • explanations for each enhancement
  • address readability and maintainability
  • performance optimization
  • best practices and patterns
  • error handling and edge cases

SUCCESS CRITERIA

  • Improve code readability and maintainability
  • Optimize performance
  • Apply best practices and patterns
  • Handle errors and edge cases
  • Provide improved code
  • Explain each enhancement

FAILURE MODES

  • Might overlook improvements in one of the specified areas
  • Could fail to provide explanations for changes
  • Risk of breaking existing functionality
  • May not consider language-specific best practices

CAVEATS

Dependencies
  • Requires the selectedText code snippet
Missing context
  • Programming language of the code
  • Detailed output format (e.g., use markdown sections for explanations)

QUALITY

OVERALL
0.92
CLARITY
0.95
SPECIFICITY
0.90
REUSABILITY
1.00
COMPLETENESS
0.85

IMPROVEMENT SUGGESTIONS

  • Add a placeholder for the programming language, e.g., 'Language: ${language}'
  • Specify output structure: 'Use markdown with sections for each improvement category, followed by the full improved code.'
  • Include constraints like 'Keep changes minimal unless performance gains justify otherwise.'

USAGE

Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.

MORE FOR DEVELOPER