Before we start
This course is independent. It is not affiliated with, endorsed by or produced by Anthropic, and it reproduces none of Anthropic's course or documentation text. Its lessons are exercises you run on your own machine.
Claude Code changes often. Feature names, limits and plans in any course, this one included, can go stale within weeks. When a detail matters, check Anthropic's current documentation at code.claude.com/docs.
The one idea: who does the legwork?
A chat assistant is like a knowledgeable colleague on the phone. They only know what you read out to them, and you do everything they suggest yourself.
A coding agent is like that colleague sitting at your keyboard. It can open the files, run the tests and make the change itself, while you watch and approve.
Anthropic describes Claude Code as an agentic coding tool that reads your codebase, edits files and runs commands. Those three verbs are the whole difference:
- Reads: it finds the relevant code itself, so you don't paste it in.
- Edits: it changes the files on disk, so you don't copy code back.
- Runs: it executes commands such as your tests and sees the output.
It runs in a terminal, in editors such as VS Code and JetBrains, in a desktop app and in a browser. We pick a surface later. The idea is the same on all of them.
A bug fix, both ways
The sample project you are about to create has a function that splits a restaurant bill. Splitting between zero people crashes it with a ZeroDivisionError.
With a chat assistant:
- You run the code and see the crash.
- You copy the error and paste it into the chat.
- The chat asks to see the function, so you find the file and paste that too.
- It suggests a fix, and you copy it back into your editor.
- You re-run the tests, and if something else breaks you start pasting again.
You are the courier. The assistant only sees what you remembered to paste.
With an agent, you type one request in the project folder:
split_total crashes when people is 0. Find out why, fix it,
add a test for that case and run the tests.
The agent then searches the project for split_total and reads tipcalc.py. It proposes an edit and a new test, runs the test suite, reads the result and reports back. If the test fails, it sees the failure itself and tries again.
Gotcha: "does it itself" does not mean "unsupervised". In its default mode Claude Code reads files freely but asks your approval before it modifies a file or runs most shell commands. You are still the reviewer. Later lessons cover those prompts properly.
The next lesson covers how that read, act and check cycle works. For now, remember that the agent gathers its own evidence and checks its own work.
When an agent is the right tool
An agent is not always faster. This is my rule of thumb:
| Task | Best fit | Why |
|---|---|---|
| Fix a bug whose cause could be in several files | Agent | It can search, read and run tests |
| Explain how an unfamiliar project fits together | Agent | The answer is in files it can open |
| Rename a function used in 30 places, then run tests | Agent | Tedious, checkable work across many files |
| Fix a typo you are already looking at | By hand | Typing the request takes longer than the fix |
| "What is the difference between a list and a tuple?" | Chat | A general question that needs no project files |
| Brainstorm a name or draft an email | Chat | No files to read, nothing to run |
The test I use: does the task need facts from my project, or need something to be run? If so, use an agent. If the answer does not depend on your files, chat is fine. If you can make the change in ten seconds, just make it.
The trade-off is that an agent can make many changes quickly, including wrong ones. That is why the sample project goes into git before an agent touches it.
Set up the sample project
You need git and Python 3. Check both:
git --version # any recent version is fine
python --version # on macOS/Linux you may need: python3 --version
Create the folder and a repository:
mkdir tipcalc
cd tipcalc
git init -b main # -b names the first branch; without it git still defaults to master
Expect: Initialized empty Git repository in .../tipcalc/.git/
In your editor, create three files in that folder.
tipcalc.py:
def tip_amount(bill, percent):
# 10 percent of 50.00 -> 5.0
return round(bill * percent / 100, 2)
def split_total(bill, percent, people):
# Deliberate bug, left for a later lesson: people=0 crashes
total = bill + tip_amount(bill, percent)
return round(total / people, 2)
test_tipcalc.py:
import unittest
from tipcalc import tip_amount, split_total
class TipCalcTests(unittest.TestCase):
def test_tip_amount(self):
self.assertEqual(tip_amount(50, 10), 5.0)
def test_split_total(self):
# 100 + 20 tip = 120, split 4 ways = 30 each
self.assertEqual(split_total(100, 20, 4), 30.0)
if __name__ == '__main__':
unittest.main()
.gitignore:
__pycache__/
Run the tests, then commit:
python -m unittest # expect: Ran 2 tests ... OK
git add .
git commit -m "Initial sample project"
git status # expect: nothing to commit, working tree clean
Gotcha: if the commit fails asking who you are, set your identity once with
git config --global user.name "Your Name"andgit config --global user.email "you@example.com", then commit again.
Best practice: a clean
git statusbefore you hand work to an agent means every change it makes shows up as a diff you can review or throw away.
Exercise
- Run
python -c "from tipcalc import split_total; print(split_total(100, 20, 0))"and read the crash. - Write down each step you would take to fix it with a chat assistant, and count the copy-and-paste trips.
- Write the single request you would give an agent instead. Keep it; you will use it later.
Key takeaways
- A chat assistant advises and you do the work. A coding agent reads your files, edits them and runs commands in your project.
- An agent can check its own work, for example by running the tests and reading the result.
- Use an agent when the task needs project facts or something run. Use chat for general questions, and your own hands for trivial edits.
- By default the agent asks before changing files or running most commands, so you remain the reviewer.
- Commit to git first, so the agent's changes are visible and reversible.
- This course is independent of Anthropic. Check feature details against Anthropic's current pages.