Ask HN: How do you improve code for future AI?

1 tmaly 3 5/31/2025, 1:03:44 PM
I am sitting on tons of legacy code at my day job. I keep looking at how fast AI is improving over the last few years.

I am thinking what can I do to improve the massive amount of legacy code I have to maintain so that eventually I can let a better AI in the near future help me more?

What are your best tips that are working now?

Comments (3)

apothegm · 5h ago
AI has limited context windows and little ability to reason about what complex code does.

If you can refactor it to small modules with simple interfaces and properly document the interfaces and what the modules do, AI can work with your code more easily. Think of the ideal AI codebase as being assembled from libraries (even if private internally developed ones) with a small amount of glue code in between.

lucfranken · 14h ago
Did you try running some ai over it to see if it is capable of being useful?

Legacy code is a statement but in the end it only matters if it works and is maintainable.

It might surprise you.

tmaly · 5h ago
I got mixed results. A good portion of the code was written by former employees. There is little documentation.