Live data from Hacker News

Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

news.ycombinator.com

41–50 of 59 posts

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#41
Actually, only today I noticed that Cursor's Agent Composer now can properly respond to linting errors.

In my typescript codebase case, it solves a lot of problems, it probably helps that I use tRPC type rather aggressively (i.e. using UUID types, separate dates and datetimes etc).

A few weeks ago it wasn't working nearly as well in my experience.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#42
I use aider to work on the aider code base, which is approaching 30k lines of python. Aider writes about 70% of the new code in each release [0]. So it's doing some fairly heavy lifting in a non-trivial code base.

Some pragmatic tips:

- Work with AI like a junior developer, except with unlimited energy and no problem being corrected repeatedly.

- Provide the AI with guidance about conventions you expect in your code base, overall architecture, etc [1]. You can often use AI tools to help write the first draft of such "conventions" documents.

- Break the work down into self-contained bite sized steps. Don't ask AI to boil the ocean in one iteration. Ask it to make a sequence of changes that each move the code towards the goal.

- Be willing to explore for a few steps with the AI. If it's going sideways, undo/revert. Hopefully your AI tool has good checkpoint/undo/git support [2].

- Lint and test the code after each AI change. Hopefully your AI tool can automatically do that, and fix problems [3].

- If the AI is stuck, just code yourself until you get past the tricky part. Then resume AI coding when the going is easier.

- Build intuition for what AI tools are good at, use them when they're helpful. Code yourself when not.

Some things AI coding is very helpful for:

- Rough first draft of a change or feature. AI can often speed through a bunch of boilerplate. Then you can polish the final touches.

- Writing tests.

- Fixing fairly simple bugs.

- Efficiently solving problems with packages/libraries you may not have known about.

[0] https://aider.chat/HISTORY.html

[1] https://aider.chat/docs/usage/conventions.html

[2] https://aider.chat/docs/git.html

[3] https://aider.chat/docs/usage/lint-test.html

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#43
post #29

> How often do you catch AI trying to make breaking changes? I think this is the wrong way to think about the problem. The AI isn't breaking your code, the engineers are. AI is just a tool, and you should always keep this in mind when talking about this sort of thing. But I understand some of the problems you describe while using AI. And the way I work around is to never let the AI write more than a few lines at a ti…

That’s what I used to do but now I think it is a major handicap. I haven’t perfected it yet, but I’ve had good luck letting AI write entire (smallish) programs and do major updates to those.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#44

It sounds like you're not training it with your existing code base, and that you're running it with relatively small contexts. Have you done any custom LLM training on your code base, and what model are you using?

Reminds me of Go being released without a package manager because at Google they didn't need it lol What codebase size do you have?

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#45
I'm surprised that there aren't already greater integrations between Copilot and Github pull reviews - pulling into the prompt context for completions, for instance, the data set of pull review comments that address any prior attempt to break patterns and modify architecture. Any mature codebase will have had many a senior engineer swatting away these attempts, in writing. Either way, this seems to me to be a context engineering challenge (and privacy-at-scale challenge) more than anything else, and that means that this will all improve over time!

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#46
Same way you prevent humans from breaking your codebase: tests, code reviews, static analysis, etc. I agree with others that say treat AI like an intern or junior dev. They can speed you up if managed well, but need oversight. Over time the AI will get better, and will learn to learn as senior developers do.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#47
post #40
post #38

Do you not have code reviews? These are all problems with regular humans, too. You prevent it via code reviews.

Or even better, before the code review. If your engineers commit substandard code that was generated by an AI, they’re not doing their job. It’s ok to miss some things, but "breaking the codebase" should absolutely not happen.

> If your engineers commit substandard code that was generated by an AI, they’re not doing their job.

Whether it is generated by AI or not is irrelevant. I've seen junior engineers submit better code than normal because it is AI generated.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#48
post #22

Small functions, small modules, small codebases. Keep state as contained as possible. Tightly control interfaces and interactions. Know your paradigms. Example: in Rust multi threading it loves putting things in an Arc. You have to tell it to use MPSC queues instead. I love coding with AI. It has made me 100x more productive. I am able to work on my distributed event processing backend in Rust, then switch to my mobi…

Just curious have you been working in those disciplines for years though regarding: rust -> swift -> uart driver gps esp32

Not really, since I was in management for five or so years with not much code writing. Embedded programming -- never in my life. Swift -- briefly, when it just came out years ago, but modern Swift is extremely different. Rust -- sure, I guess that's what I'd been doing before moving to management.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#49
post #22

Earlier quoted context omitted.

Just curious have you been working in those disciplines for years though regarding: rust -> swift -> uart driver gps esp32

Not really, since I was in management for five or so years with not much code writing. Embedded programming -- never in my life. Swift -- briefly, when it just came out years ago, but modern Swift is extremely different. Rust -- sure, I guess that's what I'd been doing before moving to management.

Dang that's impressive then. I've been a programmer of different languages for a while and I tried to learn/use rust ehh... but that's cool to hear.

Re: Ask HN: Teams using AI – how do you prevent it from breaking your codebase?

#50
post #49

Earlier quoted context omitted.

Not really, since I was in management for five or so years with not much code writing. Embedded programming -- never in my life. Swift -- briefly, when it just came out years ago, but modern Swift is extremely different. Rust -- sure, I guess that's what I'd been doing before moving to management.

Dang that's impressive then. I've been a programmer of different languages for a while and I tried to learn/use rust ehh... but that's cool to hear.

It's not the easiest language to learn, and in some respects it's one of the hardest.

Luckily, tooling is good.

It's one of those things where "trying" to learn it doesn't work. You should commit yourself to it and do it. Don't try too hard to understand all the abstractions and concepts. Just write an incredible amount of code. Your brain, over time, will pick up the patterns and make sense of the abstractions. It will do that while you're resting, not while you're actively trying to internalize. Just put in the "saddle time", and the brain will work its miracle.

Post reply on HN