1Claude Code 101

How Claude Code works

5 min read811 words

You know Claude Code can edit files and run commands. But when you type a prompt and watch it spin up ten tool calls, read six files, and land a patch — what is actually happening between your Enter key and the final diff? The mechanics matter. Once you see the loop, you write better prompts.

The agentic loop

Claude Code is best understood as a five-step loop that runs until your request is satisfied.

  1. Prompt. You enter a request.
  2. Gather context. Claude Code calls the model, which responds with either text or a tool call. Tool calls are Claude Code's way of asking for information it does not already have — read this file, list this directory, run this command.
  3. Take action. Claude Code executes the tool call — edits a file, runs a shell command, searches the web.
  4. Verify. The results come back, and Claude decides whether they actually achieve what the prompt set out to do.
  5. Loop or finish. If the goal is met, Claude stops and waits for your next prompt. If not, it loops — gathering more context, taking more action — until the work is complete and verifiable.

You are not locked out during this cycle. At any point you can add context, interrupt, or steer the model toward the outcome you want. That ability to intervene mid-loop is a feature — use it.

Context window — the working memory

Claude has a context window: a bounded buffer that holds your conversation, file contents, command outputs, and tool results. It is generous, but it is not infinite.

When you hit the limit, Claude Code compacts the conversation automatically — summarising what it can, removing what it no longer needs. Compaction keeps you moving, but it is not free: detail gets lost in the summary. Managing context deliberately (which you will learn in a later lesson) produces better results than relying on auto-compact to rescue you.

Tools — why agents are not chatbots

Most AI assistants are text-in, text-out. Nothing happens between the input and the output except model inference.

Tools are the backbone of what makes Claude Code an agent. They let the model decide, on its own, when to read a file, search the web, or execute a build. Claude Code uses semantic understanding — not keyword matching — to pick the right tool and interpret the result. The model is not just writing a response; it is deciding what to do next.

This is also why better prompts produce dramatically better runs. A precise prompt gives the model enough information to make smart tool choices. A vague prompt leads to exploratory tool calls that burn context.

Three permission modes

Claude Code ships with three permission modes. Cycle between them at any time with Shift+Tab.

Default (Approval). Claude asks for explicit permission before editing a file or running a shell command. The safest setting — and the right default while you are building intuition for what Claude Code will do.

Auto-accept. File edits are applied without asking. Commands still require approval. Good for focused refactor runs where you trust the plan but still want a hand on the shell.

Plan mode. Claude uses only read-only tools and compiles an action plan before touching anything. Nothing is written, nothing is executed. You review the plan, ask for revisions, and only then drop out of plan mode to execute. This is how you course-correct cheaply.

All three modes are configurable in your settings file. Be cautious when skipping permissions — giving Claude Code free rein means a mistake can land before you notice it.

Recap

Claude Code combines four agentic concepts: a loop, a managed context window, tools, and configurable permissions — all inside your terminal. It reads your codebase, acts on it, and verifies its own work. That is what separates it from a chat window. And once you can see the loop running, you can start writing prompts that work with it instead of against it.

Key Takeaways

  • 1Claude Code runs a five-step agentic loop: prompt, gather context, take action, verify, and loop or finish.
  • 2You can add context, interrupt, or steer the model at any point during the loop — intervention is part of the design.
  • 3Tools are what separate agents from chatbots; the model decides semantically when to call them and how to use the results.
  • 4The context window is finite — Claude Code compacts automatically when it fills up, but compaction loses detail.
  • 5Shift+Tab cycles between Approval, Auto-accept, and Plan mode; skipping permissions trades safety for speed.