GitLab Well Architected
Cookbook navigation
Prompts / Modernize Legacy Code

Modernize Legacy Code

Code QualityDeveloperLegacyRefactoringCreateBeginner

Update legacy code to use current language features and best practices. Modernize without breaking functionality.

For GitLab Duo

prompt

Modernize this legacy code:

[PASTE CODE]

Update to use:
1. Current language features
2. Modern libraries
3. Best practices
4. Improved error handling

Use the prompt

Include the language version and behavior you need to preserve. A smaller change is easier to review when it has a clear benefit beyond making the code look newer.