r/CodingForBeginners • • Oct 16 '26

How do you verify AI-generated code when you're not an expert?

A green-looking result isn't proof that everything works. What simple checks would you recommend to someone building their first app with AI?

0 Upvotes

48 comments sorted by

13

u/Beregolas Oct 16 '26

That's the neat part... you don't ^^

This is why learning programming is still important, especially in the "Age of AI". There are no simple checks that just work, you actually need to be able to understand what the AI is doing to control it.

-4

u/waveoui Oct 16 '26

Fair point. You definitely need some understanding, but I think beginners can still catch a lot by testing edge cases, checking error messages, and asking AI to explain what each part does. Not foolproof, but better than blindly trusting a green checkmark 😅

7

u/johlae Oct 16 '26

-3

u/waveoui Oct 16 '26

Haha fair 😅 But isn’t that exactly why beginners should learn to question AI output instead of trusting it blindly? You don’t need to be an expert to start testing things.

4

u/cheetah1cj Oct 16 '26

We're not suggesting that they should trust it blindly. We're suggesting that if someone does not understand coding enough to validate the code, they should not be using AI to build the application.

AI is a tool to help a coding expert to build or troubleshoot an application, but it does not replace the need for having someone who can build code.

2

u/Dashing_McHandsome Oct 16 '26

No, that's why a beginner should get a textbook and start there

2

u/Amazing_Boss2686 Oct 17 '26

You won’t know what to ask

2

u/dafugiswrongwithyou Oct 16 '26

OK, so; when the beginner asks a chatbot to explain what part of the code does, how do they understand whether to trust that the description the chatbot gave is accurate and complete? Do they ask another chatbot to double-check it? Is it chatbots all the way down?

At some point, the person reading it either has to know enough to tell for themselves, or trust the LLM... and they should never trust the LLM.

0

u/Slight-Living-8098 Oct 17 '26

You ask the bot for verifiable reference for their answers, then you cross reference and check those references. Same as you would do any other source of information.

2

u/dafugiswrongwithyou Oct 17 '26

And how do you understand the answers those references provide, if you're a beginner who doesn't yet get the concept of the code you're typing in? (Or alternatively; if you do already understand, what was the purpose of checking with an LLM?)

-1

u/Slight-Living-8098 Oct 17 '26

The exact same way you do it when in school.

"Hey, I don't understand this part, I better look it up"

You just keep drilling down, man.

2

u/dafugiswrongwithyou Oct 17 '26 edited Oct 17 '26

So.

If you're learning how the code works.

By looking up sources elsewhere.

As we did in school.

As we have always done.

As I think we should do anyway.

Why. Ask. An. Llm?

Remember; the original advice, the thing we're discussing, was to have an LLM explain the code. They didn't say "ask an LLM to explain the code, with references to the info it stole from, at sites that you should've been reading in the first place and already know the info from". They made it sound like an LLM was the shortcut, when the way you're describing it now, the LLM is just one extra step between the beginner and the info they needed and were always going to get; a waste of time.

Remember how I ended my reply to that; you either learn enough to know for yourself, or you trust the LLM, and you shouldn't trust the LLM. Sounds like you actually completely agree with that.

-1

u/Slight-Living-8098 Oct 17 '26

I think you need to check yourself, and review the entire thread and reply to the correct person.

2

u/dafugiswrongwithyou Oct 17 '26

Ahh, you've just spent all this time defending someone elses original advice with your "ask for references" suggestion! Fair, didn't notice that: I've edited to adjust the pronouns to account for that. My point still stands, and my question, which is indeed to you, remains.

0

u/Slight-Living-8098 Oct 17 '26

Your reading comprehension is deplorable.

Have a good day

→ More replies

1

u/Void-Creator Oct 16 '26

Keep making new projects and try to make the suceeding project be better at performance and take less time. It takes a lot of practice and experience.

4

u/marmotta1955 Oct 16 '26

Short answer: you cannot.

3

u/ConcreteExist Oct 16 '26

OP, you're so close to realizing the problem with vibecoders, so close.

2

u/HugeCannoli Oct 16 '26

you become an expert. But you can't because you keep programming with AI.

2

u/Cevvity Oct 16 '26

If it looks like shit, waffles on, outputs shit, yeah it’s probably my code

2

u/questron64 Oct 16 '26

You don't. If you can't tell the good code from the bad then you're vibe coding. There is no simple "is this code good" check you can do.​

1

u/Distdistdist Oct 22 '26

How do you verify your mechanic's work if you don't know anything about cars? By hiring somebody who knows about cars.

1

u/Ornery_Platypus9863 Oct 22 '26

You can’t, that’s why you have to actually know what you’re doing.

1

u/LrdJester Oct 16 '26

This is a good way to learn debugging.

But never trust the generated code.

I use AI to create personal stand alone apps as my disability honest my ability for long coding sessions. But this is for my use shortly at this point. If I ever share it I'll refactor the entire project, even though it'll take me a long time, to ensure it's not being inefficient and ensure security.

I will have it working and then update the small things, via AI, and the app will totally collapse and I find that when it made changes it introduced timing bugs.

1

u/DirtAndGrass Oct 16 '26

At the minimum be able to write/execute full coverage whitebox and black box tests 

1

u/Shtucer Oct 16 '26

By hiring expert... Obviously.

1

u/net_ramblings Oct 16 '26

This is free advertisement.

1

u/buzzon Oct 16 '26

You hire an expert

1

u/Ormek_II Oct 16 '26

No simple Checks!

I suggest TDD.

  1. First define your requirements.
  2. Then built test which fail.
  3. Then built the program and let it test.

If it works immediately you have too few test.

1

u/LongjumpingFee2042 Oct 16 '26

I don't approve unless I am reasonably sure of the code. If the ai can write it. It can explain it. In depth and respond to your questions about why it chose to do x. 

1

u/mxldevs Oct 17 '26

You spend thousands of dollars to get an expert to look at it.

1

u/Oliver_clothsoff1983 Oct 17 '26

The same way you build a house if you have only ever built a shed,.... hire a contractor thats built 100 houses already.

1

u/Longjumping_Put_7212 Oct 18 '26

I would say you verify it by reading through the code and seeing if the logic works. Or just add a few debug print lines that tell you what it is actually doing to help you understand how different inputs affect it

1

u/_manpat Oct 18 '26

you don't. the simple check I would recommend is "check that you're not using ai"

1

u/NoDepartment772 Oct 19 '26

A lot of the answers are "you can't," which is honest but not much use if you're going to ship the thing anyway. Practical version: you can't verify quality, but you can verify behaviour, and that catches more than people expect.

Test it on inputs you choose, not the ones in the demo. Empty, zero, a negative, a huge number, text where a number goes, an emoji. The demo always uses the happy path.

Re-read the prompt you gave it and check the code does what you actually asked, not what looks impressive.

For anything touching money, login, or files, if you can't explain what a line does, don't ship it yet. Ask it to explain that line, then check whether the explanation matches the code. Those often disagree.

Keep the last known-good version before each AI change so you can get back.

The skill you're really building here is testing, and that's worth learning on its own.

0

u/Sure-Passion2224 Oct 16 '26

It's a learning opportunity. AI is a tool and it is appropriate to use tools to get any job done. In those cases when you don't understand what the tool did the best response is to walk through it line by line to learn from it.

-1

u/VoiceOfSoftware Oct 16 '26

For starters, ask a second AI model (from a different company) to check the code. Ask both AI models to write tests, and explicitly look for edge cases, monitor errors, etc. Inject as much of your human understanding as possible, meaning add your own creative requirements that an AI may not be thinking of on its own.

3

u/HouseMysterious8172 Oct 16 '26 edited Oct 16 '26

It's still AI's code in the end. Questioner ask 'how do YOU verify'.

It like someone else translate a language for you, you got the result and it convincing, but you not sure if there can have some mistake.

Now you don't know that language, how YOU verify it yourself?

1

u/VoiceOfSoftware Oct 16 '26

Understood. OP also has no skills to do this on their own. They could ask an experienced coder to review, or they could get a little closer to verification by using another AI to assist. This is how agent swarms do it today. It’s not perfect, but it’s faster than asking OP to get a CS degree.

1

u/External-Scratch-502 Oct 16 '26

probably wont need a degree, but a couple youtube videos and maybe some practice with whatever language you are working with. if he is serious and not lazy it would be like maybe 8 hours of learning and you should be able to create a basic app.

1

u/VoiceOfSoftware Oct 17 '26 edited Oct 19 '26

Anyone can create a functioning basic app with zero hours of learning these days. Look at Lovable, for instance. But OP is asking how to VERIFY that the app code isn’t broken in some cases, and that’s a whole different ballgame. 8 hours is not enough to learn how to troubleshoot or look for edge cases. The code would look like gibberish to the untrained eye.

Asking Ai to walk you through the code, and teach you as it goes, would be a valid use case, but still a steep learning curve to understand what the AI is reporting.

1

u/VigilanceOne Oct 18 '26

Then why build something so outside your own depth if you're not going to learn along the way and build an understanding through trial and error? AI isn't magic and doesn't enable you to build a house when you don't even know how to setup a basic tent.

1

u/VoiceOfSoftware Oct 18 '26

Agreed: using AI as a tutor is a great way to learn along the way. After it builds the thing, ask it to walk you through the code.

I'm just here to answer OP's original question "What simple checks would you recommend to someone building their first app with AI?"

1

u/HouseMysterious8172 Oct 19 '26

VERIFY that the app code isn't broken in some cases

-> Hey AI, check all the edge cases before build 😄