💻 Codingadvanced4 variables

Refactor Code

Get suggestions for refactoring and improving code structure.

refactoringclean-codearchitecture

Template

Refactor this {{language}} code to improve: {{improvement_goals}} Current code: ```{{language}} {{code}} ``` Constraints: - Maintain the same external behavior - {{constraints}} Please provide the refactored code with explanations for each change.

Variables to Fill In

1
{{language}}

Programming language

Example: JavaScript

2
{{improvement_goals}}

What to improve

Example: - Readability - Performance - Maintainability

3
{{code}}

Code to refactor

Example: function processData(data) { ... }

4
{{constraints}}

Any constraints

Example: Keep backward compatibility

Example Usage

Variables Used:

language = Python
improvement_goals = - Remove duplication - Add type hints
code = def process(x): ...
constraints = Python 3.8+ compatible

Result:

Refactor this Python code to remove duplication and add type hints while maintaining Python 3.8+ compatibility.

Tips for Best Results

  • 1Be specific with your variables - the more detail you provide, the better the AI response.
  • 2Start with the example values if you're unsure, then customize based on your needs.
  • 3Iterate on the results - if the first response isn't perfect, refine your variables and try again.
  • 4Combine multiple templates for complex tasks that require different perspectives.