πŸ€– HarDojo
Log in Sign up

How AI Coding Works

Tokens, context windows, and why an LLM can write code at all.

AI coding tools are powered by large language models (LLMs). They don't "think" like a programmer β€” they predict the most likely next token (a word or code fragment) given everything before it.

Tokens and context

  • A token is roughly a word or a few characters of code. function might be one token; getUserProfile might be three.
  • The context window is how many tokens the model can "see" at once. Modern models handle 100k–1M+ tokens β€” that's why an agent can read a whole codebase.
  • Everything you send β€” files, conversation history, tool output β€” lives inside this window. Context is the most precious resource an agent has.

Why it can write code

Models are trained on enormous amounts of code, so they learn syntax, idioms and patterns. Give one a clear task plus the relevant files, and it can produce surprisingly good code. Give it too little context and it hallucinates β€” invents APIs that don't exist.

From chat to agent

A chat tool answers one message at a time. An agent adds a loop:

1. Understand the goal
2. Choose an action (edit a file, run a command, search)
3. Observe the result
4. Repeat until done

That loop β€” plus the ability to run tools β€” is what separates Claude Code from a plain chatbot. We'll build the loop ourselves in the Agentic Coding section.

Key takeaway

The model's ability is constant. Context and instructions are what make it good or bad at your job.