How to learn to code with AI switched on
Keep the AI, but use it for questions, not for code. Write your plan in plain comments first, ask the AI why and how something works, then type the code yourself. Predict what it will do before you run it, and explain every piece in one line. In the one trial that looked, learners who asked conceptual questions kept learning. Learners who handed over the task did not.
What the trial found
In a randomised trial with 52 mostly junior developers learning a new Python library (Shen and Tamkin, Anthropic, 2026, a preprint, not peer reviewed), the group with an AI assistant scored about 50% on a skills quiz afterwards. The group without AI scored about 67%. The biggest gap was on debugging questions. The AI group saved about two minutes, which was not a significant difference.
The useful part is what happened inside the AI group. People who asked the assistant conceptual questions, or who asked for code and then made sure they understood it, scored well. People who delegated the task scored worst. These subgroups were very small (2 to 7 people each), and the authors say the pattern does not prove cause. It is still the best evidence we have on how to learn with an assistant open.
One more thing to know: your sense of progress is a poor guide. In a 2025 trial (METR, a preprint), 16 experienced open-source developers were 19% slower with the AI tools of early 2025, and believed they had been 20% faster. Feeling fast and learning are different things.
The routine
Write the plan in comments
Before any code, write the steps in plain words as comments: read the file, split each line, count the words, print the top five. If you cannot write the plan, that is your first question for the AI, not "write this for me".
Ask why and how, not "write it"
Good asks: "What does a dictionary do that a list does not?" "Why would this loop never end?" "Explain the approach and what could go wrong. No code yet."
Type the code yourself
Switch off inline suggestions while you are learning a topic, if your editor lets you. When the AI shows an example, read it, close it, and write your own version. Typing is slow, and slow is where it sticks.
Predict, then run
Say out loud or write down what the program will print. Then run it. When you are wrong, stop and find out why before you change anything. That gap is the lesson.
Read the error before you paste it
Read the last line of the error message and guess the cause. Then, if you ask the AI, send your guess with it: "I think the list is empty here. Am I right? Give me the next thing to check, not the fix."
Explain each piece in one line
For every function you keep, write one line on what it does and why it works. If you cannot, you are borrowing that code, not learning it.
Wording to copy
This is the coding line from our coach instruction. Paste it at the start of a chat, or save it in your AI's settings so it applies every time.
I write code. Before you give code, ask what I have tried and what I think the cause is. Prefer explaining the idea, pointing me to the docs, or a small hint over a full solution. If you do give code, ask me to explain it back in one line.
The coach setup page builds the full instruction (choose Coding) and shows where to paste it. It is free. Several coding assistants also have their own learning or explain mode. If yours has one, turn it on for anything new to you.
When to let the AI write
- Things you have already learned. Once you can write a loop in your sleep, having it typed for you costs little.
- Setup that is not the lesson. If today is about sorting, do not lose an hour to a config file.
- After a real try. Twenty minutes stuck, with a guess written down, is a fair point to ask for more. Then explain the answer back.
A weekly test of where you are
Once a week, build something small with no assistant: a number guessing game, a to-do list, a script that renames files. Docs and search are allowed. If it feels much harder than last month, move more of your asks from "write" to "explain".
Questions
Should beginners avoid AI when learning to code?
You do not have to. In the trial above, how people used the assistant mattered more than whether they had one. Ask it to explain. Do not ask it to do the exercise.
How do I know I am learning and not just finishing tasks?
Try the same kind of task a week later with no assistant. If you can do it, you learned it. Finished exercises with the AI open do not tell you.
Which AI should I use to learn?
The routine works in any of them, because it is about what you ask. If you are under 18, note that Claude is for adults only. ChatGPT is for ages 13 and up with a parent's permission.