AI writes code fast. The code runs and passes the tests. It is still hard to change.
I refactor a lot of AI-generated code. The same problems come back every time:
Functions grow long and deeply nested.
Files collect responsibilities that belong somewhere else.
The next AI session needs more and more context to make a safe edit.
For the GitLab Transcend Hackathon (theme: Life After Code ) I tested how far my own refactoring process can be automated with GitLab pipelines and the GitLab Duo Agent Platform. The result is Liepa refactoring .
Devpost: https://devpost.com/software/liepa-refactoring
Code: https://gitlab.com/gitlab-ai-hackathon/transcend-october-2026/43312097/liepa-refactoring
My manual method
My method has three steps:
Take the most characteristic keywords of each file.
Check whether those keywords belong to the area of the app where the file lives.
If they do not, the file mixes responsibilities. Refactor it with an AI assistant, one file at a time.
It works.…