Skip to content

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.

16 min read0/4 questions

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 | bash

Or with Homebrew:

brew install --cask claude-code

Check that it worked, then start a session from the root of a project:

claude --versioncd my-appclaude

The 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.

One request, several tool calls
YouClaude CodeYour projectwhy does signup fail?search for 'signup'3 matching filesread signup.tsfile contentsrun npm test? (approve)yesfound it: missing await

You describe the problem in plain language. No need to paste files.

1/8

Useful keys while a session is running:

KeyWhat it does
EscInterrupt Claude mid-task
Esc EscRewind to an earlier checkpoint
Shift+TabCycle permission modes
/Open the command menu
!Run a shell command yourself, for example ! git status
Ctrl+GEdit 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.

ModeBehaviourGood for
default (Manual)Asks before edits and commandsLearning, sensitive repos
acceptEditsEdits files without askingTrusted, well-scoped work
planRead-only: researches and proposes a plan, changes nothingAnything non-trivial, before you build
autoA classifier reviews each action; only risky ones need youLonger tasks you supervise loosely
dontAskOnly pre-allowed tools runHeadless scripts
bypassPermissionsNo checks at allOnly 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:

.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.

Where Claude Code settings and memory live
  • ~/.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/
Quick check
You want Claude to study a large codebase and propose how to add a feature, without touching any files yet. Which mode fits?
Need a nudge? A hint rules out a wrong answer.
Quick check
A settings file allows Bash(git commit *), and also denies it. What happens when Claude tries to commit?
Need a nudge? A hint rules out a wrong answer.

Slash commands worth knowing

Type / to see every command. These are the ones you will use most:

CommandUse it to
/initGenerate a starter CLAUDE.md for this project
/clearStart a fresh conversation (new task, clean context)
/compactSummarise the conversation to free up space
/contextSee what is filling the context window
/rewindGo back to an earlier checkpoint
/model and /effortChoose the model and how hard it thinks
/usageSee cost and usage (/cost also works)
/permissionsManage allow, ask and deny rules
/reviewGet a code review of your changes
/diffSee what has changed
/doctorDiagnose 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 the pairs0/5 matched

Match each situation to the command.

Choose an item, then its match on the other side.

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.

  1. 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.
  2. 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.
  3. 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.
  4. Verify. Ask it to run the full test suite and the linter. Then read the diff yourself with /diff or ! git diff. The Trust but Verify lesson explains what to look for.
  5. 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 it in order5 steps

Put the recommended workflow in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

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.

Key terms
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.