Lesson 8 of 40AI coding tools
Claude Code in the Terminal
Install Claude Code, run a session in your project, control what it may do with permission modes, and take a real task from plan to commit.
So far you have used AI through a chat window, as a tutor and a mentor. A chat window can only see what you paste into it. Claude Code is different: it runs inside your project, so it can read your files, search the codebase, edit code and run commands like your tests, always within permissions you set. That makes it an agent: you describe a goal, and it works in a loop of reading, acting and checking until the goal is met. This lesson gets you from install to a finished, committed change in the terminal. Commands and shortcuts change between versions, so if something here does not match what you see, check code.claude.com/docs for the current details.
Install and start
Install Claude Code with the native installer for your system. Native installs keep themselves up to date, and claude update updates manually.
curl -fsSL https://claude.ai/install.sh | bashOr with Homebrew:
brew install --cask claude-codeIn PowerShell:
irm https://claude.ai/install.ps1 | iexOr with WinGet:
winget install Anthropic.ClaudeCodeCheck that it worked, then start a session from the root of a project:
claude --versioncd my-appclaudeThe first run asks you to sign in. You can also sign in later with /login inside a session, or claude auth login from your shell.
Always start Claude Code from your project folder. The folder you launch it in is its working area: that is where it looks for files, where it runs commands, and where it looks for project memory.
What a session is
A session is one conversation with Claude Code. You type a request, and Claude answers by taking actions: reading a file, searching for a function, running a command. Each action is a tool call. After each one, Claude sees the result and decides what to do next.
Before Claude edits a file or runs a command, it may ask for your permission, depending on the mode you are in. You see exactly what it wants to do, and you approve or decline.
You describe the problem in plain language. No need to paste files.
Useful keys while a session is running:
| Key | What it does |
|---|---|
| Esc | Interrupt Claude mid-task |
| Esc Esc | Rewind to an earlier checkpoint |
| Shift+Tab | Cycle permission modes |
/ | Open the command menu |
! | Run a shell command yourself, for example ! git status |
| Ctrl+G | Edit your prompt or a plan in your text editor |
Sessions are saved. claude -c continues the most recent conversation in this folder, and claude -r opens a picker so you can resume an older one.
Permission modes
A permission mode decides how much Claude may do without asking. Shift+Tab cycles through them, or you can start in one with a flag such as claude --permission-mode plan.
| Mode | Behaviour | Good for |
|---|---|---|
| default (Manual) | Asks before edits and commands | Learning, sensitive repos |
| acceptEdits | Edits files without asking | Trusted, well-scoped work |
| plan | Read-only: researches and proposes a plan, changes nothing | Anything non-trivial, before you build |
| auto | A classifier reviews each action; only risky ones need you | Longer tasks you supervise loosely |
| dontAsk | Only pre-allowed tools run | Headless scripts |
| bypassPermissions | No checks at all | Only inside an isolated container or VM |
On recent versions, auto is the default starting mode for interactive sessions, though organizations can disable it. Whatever the mode, you can set rules for specific commands in a settings file. Team rules go in .claude/settings.json (committed), your personal rules for this project in .claude/settings.local.json (gitignored), and rules for every project in ~/.claude/settings.json:
{
"permissions": {
"allow": ["Bash(npm run test *)", "Bash(git commit *)"],
"ask": ["Bash(git push *)"],
"deny": ["Read(./.env)"]
}
}Deny beats ask, and ask beats allow. Here Claude can run tests and commit freely, must ask before pushing, and can never read your .env secrets file. Type /permissions in a session to manage these rules.
- ~/.claude/
- settings.jsonyour rules, every project
- my-app/
- CLAUDE.mdproject memory, committed (see /init)
- .claude/
- settings.jsonteam rules, committed
- settings.local.jsonyour rules here, gitignored
- .envsecrets: deny reads to it
- src/
Bash(git commit *), and also denies it. What happens when Claude tries to commit?Slash commands worth knowing
Type / to see every command. These are the ones you will use most:
| Command | Use it to |
|---|---|
/init | Generate a starter CLAUDE.md for this project |
/clear | Start a fresh conversation (new task, clean context) |
/compact | Summarise the conversation to free up space |
/context | See what is filling the context window |
/rewind | Go back to an earlier checkpoint |
/model and /effort | Choose the model and how hard it thinks |
/usage | See cost and usage (/cost also works) |
/permissions | Manage allow, ask and deny rules |
/review | Get a code review of your changes |
/diff | See what has changed |
/doctor | Diagnose installation problems |
CLAUDE.md is a Markdown file in your project that Claude reads at the start of every session: your build and test commands, conventions and gotchas. Run /init once in a new project to get a starter version, then trim it. The Context Engineering lesson covers what belongs in it.
Match each situation to the command.
A first real task
The workflow that works best is explore, plan, code, commit. Here is what it looks like for a realistic task: adding input validation to a signup form.
- Explore. Start in plan mode with
claude --permission-mode plan, or press Shift+Tab until plan mode shows. Ask: "Read the signup form and its API route. How is validation done elsewhere in this project?" Claude reads files and answers. Nothing changes. - Plan. Ask: "Plan how to validate email and password length on both the client and the server. List the files you would change and the tests you would add." Read the plan. Press Ctrl+G if you want to edit it in your editor. Push back on anything you disagree with.
- Code. Switch out of plan mode and say "Implement the plan. Write the tests first, run them, then make them pass." Approve commands as Claude asks, or use acceptEdits if you trust the plan. If it heads the wrong way, press Esc and redirect it.
- Verify. Ask it to run the full test suite and the linter. Then read the diff yourself with
/diffor! git diff. The Trust but Verify lesson explains what to look for. - Commit. Say "Commit this with a clear message." Claude writes the message from the changes.
The most important habit in step 3 is giving Claude a way to check its own work: tests, a build, a linter. An agent that can run the tests can find and fix its own mistakes. One that cannot is guessing.
Put the recommended workflow in order.
- Tap the steps below in the right order.
Headless mode for scripts
Claude Code also runs without the interactive screen. Print mode (-p) runs one request, prints the answer and exits, which makes it usable in scripts and pipelines:
claude -p "summarise what this project does in three sentences"cat logs.txt | claude -p "explain these errors"claude -p "list the TODO comments in src" --output-format json--output-format accepts text, json or stream-json, so other programs can read the result. For unattended runs, combine it with a permission mode such as dontAsk and pre-allowed tools, so the script never stops to wait for a human.
- Claude Code
- Anthropic's coding agent that runs in your project and can read, edit and run code with permission.
- session
- One conversation with Claude Code; it can be continued with claude -c or resumed with claude -r.
- tool call
- A single action the agent takes, like reading a file or running a command.
- permission mode
- A setting that controls what Claude may do without asking, from plan (read-only) to bypassPermissions.
- plan mode
- A read-only mode where Claude researches and proposes a plan but changes nothing.
- print mode
- Running claude -p to answer once and exit, for scripts and pipelines.
- CLAUDE.md
- A Markdown file of project instructions that Claude Code loads at the start of every session.