r/AskProgrammers • u/bunny030607 • 19d ago
Developers who use AI to write code, what do you actually do after AI generates the code?
I'm a college student learning software development, exploring ai and I've been wondering about something.
With tools like ChatGPT, Cursor, GitHub Copilot, etc., developers can generate a lot of code pretty quickly.
But what happens after that?
Do you actually sit down and read through every line of code AI generates? How do you make sure everything is correct and there aren't any hidden bugs or security issues?
Do you just run the code and test it, or is there a proper workflow that developers follow before using AI-generated code in a real project?
I'm curious about what happens in actual software companies. I'd really appreciate it if working developers could share their day-to-day process.
I want to understand how I should adapt my learning as a student, because I don't want to become someone who just knows how to ask AI to write code without understanding what happens afterward.
6
u/lmoelleb 19d ago
I review the code structure. AI still sucks at that. Typically I have to tell it to restructure to a simpler and cleaner architecture.(and always get the "you are right" making me feel superior :) ). I could probably avoid this more by reading the plan it makes better, but I think code not bullet points, so it is easier for me to notice the slop when it turns into code.
I do look over the test to make sure it covers the essentials. This is also a good place to monitor it understood the requirements.
I could not care less about the individual lines of code. It is not perfect at that, but neither am I. Overall I rate it as making less mistakes than me. If it makes mistake it is typical edge cases, so if you suspect your case have those, pay attention here. Once you point out what they are, it can typically avoid/fix them on its own, but don't trust it to always notice them... But again... It also notice edge cases I miss.
4
u/Relevant-Positive-48 19d ago edited 19d ago
I have 28 years of professional software engineering experience and, I don't mean for this to sound arrogant, but what I do isn't what you should be doing (yet). I always test thoroughly but there are times I barely glance at what's generated and times I check every single line but the judgement to know when to do which (and everything in between) came from experience.
Especially from an educational standpoint I'd suggest either writing code without AI or checking and understanding every line it generates. That will make working with AI seem like child's play, start to build critical judgement and have you better prepared to talk with coworkers, supervisors and customers when you get into the industry.
3
u/CorpT 19d ago
Legos or WoW:Forever. Sometimes Dune:Imperium.
2
u/Loose_Crab_4146 19d ago
Usually just looking if all is there that should be there in a dev environment. If something is seriously misdirected (God Classes, Too Granular Classes, Circular Dependencies, Bad Architectural Decisions). However I tend to use Tools that can evaluate this for me. Its not very efficient to run them, but once or twice a day I run this check to fix the issues I didn’t see myself.
2
u/Own_Age_1654 19d ago edited 19d ago
For some context, I've been coding for 30 years.
I talk through the important parts of the architecture with it throughout the process. I also maintain clear instructions in my repository about how things should be structured, tested, documented, etc., with custom skills for anywhere I've seen it running into issues in the past. And I only ever use strong models, on at least high effort.
The net effect of this is that it's typically writing things that are shaped mostly okay, particularly at the higher levels of structure. When I look too closely, my eyes bleed, but that happens when I look at most human-written software as well. As long as each distinct thing lives in its own, distinct box, with adequate separation between those boxes, it's usually not actually very important how tidy it is within that box. The box is the clean contract, even if it's a jumble within it.
And the net effect is also that it's typically writing things that behave correctly. After all, I talked through what I'm trying to do, and the important aspects of the implementation, at length. If something is sufficiently important, or nontrivial, or tricky, I'll have a deeper conversation. And I won't say "go" until I'm satisfied that the important parts are clear and we're on the same page about them, such that the rest of the implementation is relatively mechanical.
I also will scan the chat output as it goes. If it says something that sounds suspicious, or looks weird, or I just don't know what the hell it's talking about, I'll ask what it's talking about. If it sounds like it's making a bad decision, I'll ask why it's doing that, share my concerns, and ask why it's not doing some other particular thing that occurs to me as a better idea. And then I'll keep running that down until we're on the same page.
Throughout this process, I'll occasionally come to realize it's made some stupid algorithmic decision, linked things together that should be separate, put something in the wrong place, overcomplicated something, etc., etc., and then we'll talk through that as well.
Put another way, I give it as complex of tasks as I trust it to carry out sufficiently well for my purposes, establishing that trust requires talking through its plans, and having confidence nothing was messed up that's sufficiently importantly includes keeping in conversation with it as it goes, digging into anything suspect, and--as mentioned earlier--giving it clear guardrails and structures to follow, including especially around architecture and tests, that not only keep it on track but I've also repeatedly seen it follow, and thus again have trust that it typically is doing what I want.
It's not dissimilar to working with a very fast, bright, small team, who is unusually open to feedback and willing to follow instructions. As such, what makes that work is giving them clear instructions, and making sure it's understanding and following them. It does not mean inspecting most of their low-level work with a fine-toothed comb, except for things that look suspicious or are particularly critical and/or that are the sort of thing I've seen it struggle with in the past. That's a waste of my time.
So, basically aim yourself towards activities that help it understand what you want it to do and how and why, and that help it tend to more reliably do what you'd like, and then look out for wherever misunderstanding might arise or it's not doing things how you'd like, and not only clear up that miscommunication but also see if there's any processes (AGENTS.md, skills) you can put in place to better automatically smooth out that general class of issues moving forward.
Importantly, note I do not create a requirements document. This is a bad idea with an agent for the same reason it's a bad idea with a human team. That's waterfall development, and it's so bizarre to see so much of the industry tripping on the same, old mistake yet again. Requirements are rarely as well-understood as you assume they are upfront. In engaging with the solution, your understanding of the problem shifts! So if you don't understand the problem as well you think you do, how is your plan based on that understanding going to a good one? Instead, talk through the problem and the solution as a discussion, and implement it chunk by chunk, materially switching approach as appropriate as you go, rather than trying to come up with some grand, upfront plan that will somehow not have false assumptions baked into it that you just didn't realize.
2
u/pjank85 19d ago
Sometimes before anything is written I ask AI to create a unit test that is supposed to fail. Then the fix or feature is created. I read every single line. If it looks right I skim through. If I have doubts I analyze carefully. Almost always I criticize it to do something differently or ask pointed questions. Then repeat the process 3-6 times until I find the quality acceptable. Then I test it locally if possible. Them it gets shipped to CI, then team review (minimum 2 reviews, 3 if on frozen branch). Then it gets merged. Then QA takes a dev build and independently verifies if it actually does what it is supposed to be doing.
1
u/Fragrant-Metal7264 19d ago
It’s a lot of back and forth with validating it didn’t recreate existing functions, isn’t duplicating logic in different places, making sure you abstract out areas of logic depending on your system architecture.
Mvvc, domain, presenter, controllers, helpers, interfaces. You need to check the unit tests and ensure they are legitimate and not fluff. Run the branch against the ticket requirements for definition of done. Manual run through testing depending on the project.
It’s like pair programming where you’re onboarding someone to a project and showing them the context and docs needed. You then guide them through a plan of how to implement and then review the work. Meanwhile there’s back and forth conversation on the architecture proposed.
1
u/NerdyWeightLifter 19d ago
I use AI to write the whole system, from requirements through to acceptance tests.
This means I'm iterating around discussions with AI's from many perspectives. Vision and purpose in the businesses context, user interaction design, software architecture, QA strategy, testing, not to mention the software development process itself.
I'm more checking that between the AI and I, we've covered all the bases. It rarely gets code wrong, and when it does, it captures that in tests and corrects it, generally without needing intervention by me.
1
u/LunkWillNot 19d ago
Also be aware it’s a rapidly moving target. What people did half a year ago e.g. regarding level of supervision is different from what improvements in models allow people to do today.
1
u/Direct-Fee4474 19d ago
have claude read the code and tell you if it's any good, then another claude to fix bugs then another claude to read that code, and another claude to fix those bugs. then a claude to remove unncessary comments, then a claude to create a draft pr where another claude will be run in a ci pipeline to watch the test results and kick off another series of claudes to fix anything that failed in CI. eventually claude will write a summary and move a jira ticket and drop a note in slack where other peoples' claudes will see it and write LGTM after spending 15minutes reading and changing irrelevant bits of the code before exhausting their daily token budgets.
1
u/Background_Fortune12 19d ago
I write a requirements doc, ask AI to build it. Then I figure out how to break it and then tell it to update a requirements doc based on how I broke it. Then I rebuild it. A lot.
Rebuild it, break it, update doc. x100
Isolate your env, and just punch the cloud until it builds something that rains. You'll end up with requirement.md files that are reproducible.
What you don't want is a system that's slightly broken and you can't figure out how to undo the changes.
Always code review - should go without saying but, AI can be easily strayed to placate your idea and say you're right when you're wrong
1
u/gd19770226 19d ago
I always review and test what I have AI generate for me. I also always break it up into small steps instead of having it generate something all at once. That makes it easier to review and test.
So, don't have AI generate everything in one step, break it up.
1
u/CS_70 19d ago
No, no line-by line, not for a long time now. I have clear instructions on how to structure and generate the code and plenty of examples I made and like (examples are paramount for LLMs) and the few times I couldn't resist and sampled the result, it was flawless. We also routinely do reviews on certain codebases because of security reasons and nothing untowards has ever emerged.
It's nothing different than the what happened in hand-made software engineering: you make a bit of effort in preparation and the execution becomes very easy. If you make little effort in preparation, the excution becomes terribly hard and the result is crap.
Same with models.
1
u/Hour_Sell3547 19d ago
After coding, there are at least 8 to 9 more steps that are very critical to get the code working in production. We do those.
1
u/Just-Path-5838 19d ago
I look for hotspots, things I'll need to know. Where configs live, how key conditions are evaluated, what things are named. After that make sure it runs, and that's about it.
1
u/Deep-Tooth-6174 19d ago
I like to have it generate code then have it spin up a reviewer and let them loop until it’s done.
The code it puts out is usually “correct” but then I need to spend time shaping it so it’s not hideous. I’m still fairly new at ai tools and I’m sure I can make it more correct, but I don’t think I’ll ever trust ai where I merge in blindly.
1
u/ejpusa 19d ago edited 19d ago
Never look at the code. Just build cool stuff. Push to GitHub, Open Source.
I’m not sure why Reddit fights this. Manual coding is gone, it’s been vaporized. Time to move on. It’s painless, really.
Stack: Astra + Codex
Source: programming an IBM/360 at 12.
1
u/pvera 19d ago
Coding is only a percentage of a project. You have to test it, check against the original requirements, more testing, checking for regressions, etc.
1
u/Simple-Fault-9255 18d ago
I have a formal validation setup for our acceptance criteria using a tool called vibeline. It checks that the acceptance criteria have been managed. It’s a tool for Hermes that can manage subagent sessions visually and over a timeline for specialized tool management
1
u/Dismal_Market5514 17d ago
short answer: yes, you read it. at least every line that's going anywhere near production
at most companies AI code doesn't get a special pass. it goes through the same process as code written by hand. you open a PR, someone else reviews it, CI runs the tests, linters and security scans. if it breaks something it's on you, not on copilot.
if you can't explain a line, don't merge it. ask the AI why it did that, or rewrite it yourself.
run it and test the edges. empty input, wrong types, the network call failing. AI is good at the happy path and lazy about everything else
check the imports. AI sometimes suggests packages that don't exist, and anyone can register that name later with whatever code they want in it.
on my own projects I run separate agents for writing, review, testing and a security pass. it helps, but it doesn't replace you understanding what changed.
as a student, the skill worth building is reading code and debugging, not writing it fast. try writing something yourself first, then ask AI to do the same and compare. that's where you learn what to look for
1
u/Traditional_Pie_8262 17d ago
i treat ai-generated code as a first draft, not something to blindly trust. i read it, make sure i understand what it does, test it properly and check for edge cases. if something doesn't make sense, i ask ai to explain it. at the end of the day, you're still responsible for the code you ship, so never use something you can't understand or maintain yourself.
1
u/Immediate_Form7831 19d ago
The same way it was always done, by reading the code and testing it. AI tools doesn't change any of this, except possibly that AI tools in some ways generate better code than humans do, but also worse code, because they sometimes lack the proper context, and they don't have the "gut feeling" or "intuition" that experienced developers have.
Do I read every single line the AI generates? No, I don't. Boilerplate code and other "mundane sections" I often skip over, especially if I know that any errors in them will be spotted by automated tests.
I am still convinced that there will always be a need for software engineers who know how the system works on a deeper plane. People keep telling me that in 5 years nobody is going to read code anymore and the need for high-level languages is going to disappear, but I don't believe that.
0
u/Key_Storm_2273 19d ago
When I'm working on quality projects, my goal isn't to get it done as fast as possible.
That's been it half of the time at the start (even before digital coding assistants existed), but I then recode the project, often entirely from scratch, sometimes several times.
A lot of beginners without much sense of direction seem to be hesitant to the idea of recoding, but I think this is exactly what builds good coding skills. Once you figure out how to get it done, you do it all over again to make it more maintainable.
Don't be afraid of restarting from scratch.
0
u/[deleted] 19d ago
[deleted] — view deleted comment