GitLab Well Architected
Cookbook navigation
Prompts / Refactor for Better Readability

Refactor for Better Readability

Code QualityClean-CodeDeveloperRefactoringCreateBeginner

Improve code readability with better names, simplified logic, and clearer structure. Make code self-documenting.

For GitLab Duo

prompt

Refactor this code for better readability:

[PASTE CODE]

Focus on:
1. Clear variable names
2. Simplified logic
3. Better function decomposition
4. Appropriate comments

Use the prompt

Include the code and explain which parts readers struggle to understand. Reviewing the result alongside its tests helps keep a readability change from becoming an unintended behavior change.