Claude Code for Beginners / Chapter 1 — Getting Started with Claude Code (lessons 1–4) / Lesson 1
What Claude Code Is
Time needed: about 7 min (estimate)
Reading settings
These settings are remembered on this device only.
You can try the opening of this lesson without an account.
This course's ground rules
This course teaches how to use, configure, and extend the tool called Claude Code. A few ground rules up front. Claude's replies (the text and code Claude writes) change every time, even for the same request, so we don't print them. The only output shown here is what we actually recorded on a real machine, plus the results of Python you can run in your browser. Everything was checked on Claude Code 2.1.326, but screens and commands change between versions. And this course doesn't recommend any particular plan or subscription. For the general mindset of writing code with AI, see the AI coding course.
The difference from a chat: it does the work
A chat AI stops once it returns text. It reads the code you pasted and writes an answer; trying it out is your job. Claude Code runs in your terminal and calls tools itself: reading local files, running commands, editing files. It looks at each result, decides the next move, and calls again, repeating until the request is done. That cycle is the agent loop.
A real tool call, up close
We put calc.py (a file holding just an add function) in a small folder and asked, in Japanese, "Read calc.py and tell me in one sentence what add does. Then run ls." Claude Code has hooks (Lesson 15) that run your own commands just before and after a tool call, and we saved the JSON they received. Below is one record from just before the tool call (PreToolUse). Long paths and IDs are shortened.
JSON received by the PreToolUse hook (recorded)
tool_name is the tool being called, and tool_input is what's passed to it. This time Claude chose to read the file by running cat calc.py with the Bash tool. Claude decides on the spot which tool to call and how, so the same request won't always go the same way. We'll cover permission_mode's default in Lesson 4.
JSON received by the PostToolUse hook (recorded)
Just after the call (PostToolUse), the result of that same call arrives in tool_response. Its stdout is the contents of calc.py. Claude read this result, called ls next, and finally wrote its answer without calling a tool and stopped. Because the tool_use_id matches, you can pair up the before and after records.
Running the loop as a Python model
Let's imitate that flow in a few lines of Python. The real Claude works out its next move on the spot; here a fixed plan table stands in for it. Every tool call adds its result to the "context", and the loop stops when a move calls no tool.
Tab indents. To leave the editor, press Esc, then Tab.
Create a free account to keep reading
With an account you can read the rest of this lesson, take the quiz, and read every free lesson in this course. Lessons you answer correctly are recorded as complete.
Report a problem with this lesson
Log in to send a report.