Skip to content

Lesson 12 ยท Claude Code and Agents

Claude Code: First Steps

Meet Claude Code, Anthropic's coding agent: where it runs, how to install it, a safe first session, useful commands and how to review the changes it makes.

Claude Code is Anthropic's coding agent. Instead of only suggesting snippets in a chat, it can read your project, edit files, run commands and use tools such as Git, within the permissions you give it. You describe a task, it works in steps, and you review the result.

Where it runs

As of December 2026, the documentation lists the terminal, extensions for VS Code and JetBrains editors, a desktop app and the web at claude.ai/code. Most of these need a Claude subscription or a Claude Console account; the terminal and editor versions also support some third-party model providers.

Install the terminal version

These commands come from the official setup instructions as of December 2026. Check the documentation before you run any install script, and make sure that you are copying from the official site. All commands in this lesson are read-only here.

Terminal
# macOS, Linux or WSL
curl -fsSL https://claude.ai/install.sh | bash
POWERSHELL
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

Package managers such as Homebrew and WinGet are also supported. Then open a new terminal, check the installation and start it inside a project:

Terminal
claude --version
cd your-project
claude

The first run asks you to sign in.

A safe first session

Use a project that is under version control, with your current work committed. Then you can see every change to your files and undo it.

  1. Explore without changing anything. "Explain how this project is organized and how the tests run. Don't edit files."
  2. Plan. "I want to reject empty usernames at signup. Propose a plan and name the files you would change."
  3. Implement. "Go ahead with the plan. Add a test for the empty case."
  4. Verify. "Run the tests and show me the output."
  5. Review. Read the diff yourself before you commit.

Give Claude a way to check its work. "Make the failing test in test_signup.py pass without changing the test" is much stronger than "fix signup".

flowchart LR
  A["Explore"] --> B["Plan"]
  B --> C["Edit"]
  C --> D["Run tests"]
  D -->|fails| C
  D -->|passes| E["You review the diff"]

The edit and test steps repeat until the check passes; the review is still yours.

Commands worth knowing

Inside a session, type / to see the available commands. Some useful ones:

Command Purpose
/help Show help
/clear Start a new conversation with empty context
/compact Summarize the conversation to free context
/context See what is using the context window
/resume Return to an earlier conversation
/rewind Go back to an earlier point in the conversation or code
/diff Review changes in your working tree
/model Choose the model
/permissions Manage permission rules

/rewind relies on checkpoints that Claude Code makes. Do not treat it as a replacement for Git. A command that Claude runs, such as one that changes a database, can have effects that you cannot rewind.

From the shell

You can also run Claude Code without an interactive session using -p (print mode), which suits scripts. -c continues the latest conversation in the current folder, and -r resumes a chosen session.

Terminal
claude "explain this project"
claude -p "list the public functions in src/signup.py"
git diff main | claude -p "review this diff for bugs"
claude -c

In scripts, --output-format json gives machine-readable output, and --max-turns limits how long a print-mode run may go. Check the CLI reference for the full list.

Test the change yourself

Here is the kind of small task you might give an agent, with the checks that decide whether it is done. The function is hand-written for this lesson.

Python Acceptance tests for a small coding task

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Try removing .strip() and run it again. The test with only spaces catches the mistake. Put such cases in your request so that the agent knows what "done" means.

Review like it matters

When you read the diff, ask:

  • Did it change only what the task needed?
  • Did it weaken, skip or delete tests to make them pass?
  • Are there new dependencies? Do they exist, and can you trust them?
  • Are there secrets, debug output or unsafe commands?
  • Can you explain the change to a teammate?

Manage context as you work

A coding session fills up with file contents, command output and discussion. When you finish one task and start an unrelated one, use /clear. When you want to continue the same task but the context is getting full, use /compact, optionally with a note about what the summary must keep. If Claude keeps going in the wrong direction, interrupt it early and correct the course. Two failed corrections are often a sign that a fresh start with a better description will work better than a third.

For larger changes, ask for a written plan that you can keep in a file, then work through it one step at a time with a commit after each verified step.

Let it read before it writes

If you are new to a codebase, spend a first session only on questions: where requests enter, how data is stored and which parts have no tests. Check a few answers against the files. This teaches you how reliable the explanations are before any code changes.

Common mistake: "Fix everything that's wrong with this code." Vague, huge tasks produce large diffs that nobody reviews properly. Small tasks with a clear check are safer and easier to get right.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why commit your work before a first session?

    Version control gives you a dependable before-and-after view.
  2. 2. Which task description is best?

    It is small and has a clear, checkable finish.
  3. 3. What does the -p flag do?

    Print mode returns the response without an interactive session.
  4. 4. Tests pass after an agent's change. What is still needed?

    Passing tests can miss problems, and the tests themselves may have changed.

Summary

  • Claude Code is an agent that reads, edits and runs code under your permissions.
  • Follow the steps: explore, plan, edit, verify and review.
  • Give a clear check, and keep tasks small.
  • Slash commands manage the session; -p supports scripting.

Next: CLAUDE.md and Permission Modes

Your progress is saved in this browser. No account needed.