How to learn to code with AI
Write and understand your first small program with AI as a patient tutor. You will pick a tiny project, build it a line at a time, and learn what each part does rather than copying code you cannot follow.
By the end of this, you will have written and understood your first small program, with AI acting as a patient tutor that explains each part rather than handing you code you cannot follow.
What you will need
- Any AI chat tool: Claude, ChatGPT, or Gemini all work well.
- No prior coding experience at all.
- About 30 to 40 minutes and a willingness to experiment.
Step 1: Pick a tiny first project
The best way to start is with something small and concrete. Ask the AI to suggest a beginner project you can build and run without installing anything complicated.
I've never written any code before and I'd like to learn by building something
tiny. Suggest three very simple first projects I could build, tell me what each
one does, and recommend the easiest programming language to start with. Keep it
beginner-friendly.
What to expect: a few small ideas, such as a tip calculator or a number- guessing game, and a suggested language (often Python for beginners). Pick the one that sounds most fun to you.
If it does not work: if the ideas sound too advanced, reply with “Simpler, please, something I could build in under 20 lines.”
Step 2: Build it one small step at a time
Rather than asking for the whole program at once, ask the AI to walk you through it in small pieces and explain each one. This is how you actually learn, instead of ending up with code you cannot read.
Let's build [the project you chose] in [language], step by step. Give me the
first small piece of code, then explain in plain English what each line does.
Wait for me to say I understand before moving to the next piece.
What to expect: a short chunk of code followed by a clear explanation, one step at a time. Type each piece out yourself rather than copying it, since typing helps it stick.
If it does not work: if a chunk is too big to follow, reply with “That’s too much at once. Give me a smaller piece and explain it more slowly.”
Step 3: Run your program and understand any errors
Getting an error is a normal part of coding, not a sign you have failed. When something goes wrong, paste the exact error message and let the AI help you make sense of it.
I ran the code and got this error. Please explain in plain English what it
means, why it happened, and how to fix it, so I understand it rather than only
copying a fix.
[paste the full error message]
What to expect: a plain explanation of the error and a fix, with the reason behind it. Errors will happen often when you are learning, and reading them is a skill you are building here.
If it does not work: if the fix does not help, paste the updated code and the new error, and say “It still isn’t working, here’s where I am now.”
Step 4: Check that you really understand it
It is easy to feel like you understand code when you are reading it and then find you cannot explain it. Ask the AI to test you so you know what has truly landed.
Now quiz me on the program we built. Ask me what three different parts of the
code do, one question at a time, and tell me whether I've understood correctly.
What to expect: a few questions that check your understanding, with gentle feedback. Anything you cannot answer shows you exactly what to revisit.
Wrapping up
You have now written, run, and understood a small program, which is a real milestone. AI tools are powerful learning partners: because they are trained on huge amounts of text, a kind of program called a large language model, they can explain code at whatever level you need and answer the “but why?” questions a textbook cannot.
One honest caution: AI can occasionally produce code that looks right but does not work, or state something with confidence that is not quite true, a slip called a hallucination. Running the code and asking “why does this work?” is your best protection, and it happens to be how good programmers learn too.
A tip for your next step: once your program works, ask the AI “what’s one small feature I could add to make this more useful?” Adding to something you already understand is one of the fastest ways to improve.
Prompts you’ll need
Code Explainer
Paste a snippet of code and get a plain-English explanation of what it does, line by line, with no assumed programming background.
Use this prompt →
Debug Helper
Paste code that is not working, along with the error message, and get help finding the likely cause and a suggested fix you can understand.
Use this prompt →
Concept Explainer
Get any idea explained at exactly the level you want, from "like I'm 12" to a deeper dive, using examples and analogies that make it stick.
Use this prompt →
Learn more
AI can act as a patient tutor: explaining things at your level, building a study plan, setting practice questions, and giving you someone to practise a language with. In this guide you will learn how to use it to learn faster, while keeping a healthy check on what it tells you.
Context is the background you hand the AI so it can answer for your situation, not a generic one. This guide explains why context matters so much, what kinds are worth giving, audience, purpose, examples, and limits, and how it helps keep the AI honest.