By the end of this lesson you will know what happens inside an AI coding agent, and why short, focused chats give you better code for less money.
You need: nothing to install, only curiosity · Time: 6 minutes
An LLM (large language model) is the "brain" behind tools like Claude Code, Codex, OpenCode and Cursor. Models such as DeepSeek, GLM, Kimi, Qwen and MiniMax are LLMs. An LLM does one thing: it reads text and predicts the most likely next piece of text. It is very, very good at it.
A coding agent is an LLM plus "hands" (tools). The agent can:
- read the files in your project folder
- write and edit files
- run commands in the terminal (the text window where you type commands)
- read the result and decide what to do next
It works in a loop: read → think → act → check → repeat, until it believes the task is finished.
Put in order Put one round of the agent's loop in the right order
Tap the steps in the order you would do them. Tap a placed step to remove it.
- 1
Why?The agent does not "know" your app. It only knows what it reads and what you tell it. You are the manager: you give clear instructions and check the results.
Imagine a desk. Everything the agent can see right now is on that desk:
- your messages and its replies in this chat
- every file it opened
- every command it ran and the output it got
- your rules file (you will write one in lesson 6)
This desk is called the context window. The AI can only work with what is on the desk. When you start a new chat, the desk is empty again. It does not remember yesterday's chat unless something was saved in a file.
Today most models have a big desk (the models on AllModelAPI hold up to about 1 million tokens). But a big desk covered in old papers is still hard to work on.
Everything on the desk is what the AI sees. A new chat clears the desk; files stay. Why?If an important decision lives only in an old chat, the AI will not see it next time. Important things belong in files (like
SPEC.mdandAGENTS.md), not in chat history.The AI does not read words. It reads tokens: small pieces of words. For English text, one token is roughly three-quarters of a word, so 100 tokens is about 75 words. Hindi, Hinglish and code often need more tokens for the same meaning.
You are billed in tokens:
- input tokens: everything sent to the AI (your message plus the whole desk)
- output tokens: everything the AI writes back (answers and code)
A small example: a 200-line file is roughly 2,000 tokens. If the agent opens ten such files, that is about 20,000 tokens sitting on the desk.
Why?Once you think in tokens, you understand your bill. Big pasted files, long error logs and long chats all add tokens.
After an hour of back and forth, the desk is full of:
- old ideas you already rejected
- failed fixes that did not work
- three different tasks mixed together
The AI reads all of it every time. It may copy an old, wrong idea or forget a requirement from the start. Most tools also compact a very long chat (squash it into a short summary) when the desk gets full, and small details get lost in that summary.
The Claude Code team puts it plainly: a focused context gets you better answers and costs less.
Why?A long, messy chat is the number one reason beginners see "I fixed one thing and two others broke". A clean desk gives the AI a clear view of your project.
Match them Match each word with its meaning
Tap an item on the left, then its meaning on the right.
Here is the part most people miss: each new message sends the whole conversation again. Message 1 might send 5,000 tokens. By message 40 the same short question can send 150,000 tokens, because all the history goes along with it.
Tools use tricks such as caching to make repeated history cheaper, but a long chat still costs more per message than a fresh one.
ExampleYou paste a 500-line error log into the chat to ask one question. That is roughly 5,000 tokens, and it is sent again with every message after it. Twenty messages later, that log has been sent twenty times. Pasting only the error itself (the red lines, not the whole log) gives the AI what it needs for a fraction of the tokens.
You can watch this happen on your Usage page. If you want a safety net, give each key a spend limit on the API keys page.
- One task, one chat. Finish "add the login screen", then start a fresh chat for "fix the date format". In Claude Code you type
/clear; in other tools, start a new chat or session. - Save decisions in files, not in chat. Ask the AI to write the plan to
SPEC.mdor a rule toAGENTS.md. The next chat can read those files. - Point, don't paste. Instead of pasting a whole file, name it: "look at
src/routine.js". The agent can open it itself.
Prompt · copy it into your AI agentWe are done with this task. Before I start a new chat, add the decisions we made today to SPEC.md under a heading "Decisions", in 5 short bullet points.
Why?These habits keep the desk clean, so every chat starts sharp and cheap.
- One task, one chat. Finish "add the login screen", then start a fresh chat for "fix the date format". In Claude Code you type
- An LLM predicts text; a coding agent is an LLM with tools that reads, edits and runs things in a loop.
- The context window is the AI's desk: it only sees what is on it right now.
- Tokens are pieces of words; you pay for what goes in and what comes out.
- Long chats get worse and cost more, because the whole history is re-read every message.
- Next: the Prompt Card, a five-part way to write prompts the AI understands the first time.
Create a free account to save your progress and open every lesson. Create free account