Skip to main content
Building with AI (Vibe Coding)

⏱ About 15 min15 XP

Knowing the Code You Shipped

Using AI to write code does not change who is responsible for the code. If an AI writes a function, puts it in your project, and you ship it, that code is yours. You are the one who chose to include it. You are the one who will be asked how it works. And you are the one who will need to fix it when it breaks — because it will break eventually. Owning the code means understanding it, not just possessing it.

The Danger of Black-Box Code

Black-box code is code you are using but cannot explain. You know it works right now, but you do not know how or why. This is dangerous for several reasons. First: you cannot fix it when it breaks. If you do not understand what a function does, you cannot reason about why it is behaving differently. You are stuck waiting for the AI to diagnose code the AI wrote — and the AI might get it wrong again. Second: you cannot extend it safely. If you want to add a feature that touches that function, you are guessing about what your changes will do. Third: it makes collaboration impossible. If a teammate, a teacher, or a future version of you asks 'how does this work?', you cannot answer. That is a problem in any real project. Black-box code in your own project is a debt you will eventually have to pay.

The Rule of Ownership

Before you ship any code — including AI-generated code — you should be able to: say what it does in plain language, say why you included it, and identify where to look if it breaks. If you cannot do all three, you are not ready to ship it.

Here is a practical technique: the explain-it-back process. Every time the AI writes a function you are going to use, ask the AI to explain it line by line. Then close that explanation and try to explain the function to yourself in your own words, as if you were teaching it to a classmate. Where you get stuck is where you do not yet understand. Go back and investigate those parts until you can explain the whole thing. This takes extra time up front. It saves enormous time later — the next time that function breaks, you will know exactly where to look.

Prompt Challenge

Write a prompt asking an AI to explain a piece of code it just wrote so you can understand and own it.

Your prompt should…

  • Ask for a line-by-line explanation of what each part does
  • Ask the AI to flag any parts that could fail or behave unexpectedly
  • End with a request to summarize the function in one plain-English sentence

Understanding Is Cumulative

Every piece of AI-generated code you take the time to understand adds to your knowledge. Over a few projects, patterns emerge: you start recognizing how event listeners work, how data flows through functions, how error handling is typically structured. You stop needing to ask the AI to explain those things because you already know them. The students who grow fastest when building with AI are not the ones who let AI write everything. They are the ones who treat every AI-generated piece of code as a learning opportunity. They read it, question it, understand it, and then ship it. The students who plateau are the ones who ship whatever the AI gives them without looking closely. Their projects work — until they break. And when they break, those students are helpless.

Use AI as a Teacher, Not Just a Tool

When you do not understand a piece of code the AI wrote, ask it to teach you. 'Can you explain what this line does?' and 'Why did you write it this way instead of another way?' are some of the most valuable questions you can ask.

What makes code 'black-box' in the context of AI-generated code?

According to the rule of ownership, what must you be able to do before shipping any code?

Explain It Back

  1. Open a project where you have AI-generated code (or use the sample your teacher provides).
  2. Pick one function — ideally one you are not completely sure you understand.
  3. 1. Read it carefully.
  4. 2. Try to explain it line by line to a partner, in plain English, without looking at any explanation.
  5. 3. Where you get stuck, mark that line.
  6. 4. Go back to the AI (or ask your teacher) to explain the marked lines.
  7. 5. Try to explain the whole function again without notes.
  8. You have earned ownership of that function when you can explain it start to finish without help.
  9. Bonus: write a one-sentence comment at the top of the function summarizing what it does. That comment is now part of your project.