Skip to content

Getting Started with Claude Code: Your First Session

Core Concept LearningAugust 18, 202612 min readUpdated October 17, 2026

Claude Code is an agent that works in your project: it reads files, edits them, and runs commands such as your test suite. That makes the first session different from using a chat assistant. The useful habits are less about prompts and more about setup: which permission mode you are in, what Claude can run to check its own work, and how to undo a change that went wrong.

This guide walks through a first session in the terminal, following Anthropic's quickstart and best-practices pages: install, log in, generate a CLAUDE.md, ask questions before changing anything, make a change with a test as the check, and recover with Esc, /rewind, and git. The last sections cover the other places Claude Code runs (VS Code, JetBrains, the desktop app, the web, and the Claude mobile app) and a short exercise.

If agents are new to you, read What Is Agentic AI first. For the loop underneath, see How Claude Code Works.

A first Claude Code session in three parts: set up, work with a check, and recover when something goes wrong
A first Claude Code session in three parts: set up, work with a check, and recover when something goes wrong

Install the CLI and log in

You need a terminal, a project to work in, and one of: a Claude Pro, Max, Team, or Enterprise subscription; a Claude Console account (pay-as-you-go API credits); or access through Amazon Bedrock, Google Cloud, or Microsoft Foundry.

Install with the native installer, which Anthropic recommends:

1# macOS, Linux, WSL2curl -fsSL https://claude.ai/install.sh | bash3 4# Windows PowerShell5irm https://claude.ai/install.ps1 | iex

Alternatives are brew install --cask claude-code on macOS and winget install Anthropic.ClaudeCode on Windows. Open a new terminal and run claude --version. If the shell says claude is not found, the install directory is not on your PATH yet.

Then start Claude Code inside a project and log in:

1cd ~/code/my-project2claude

On first use Claude Code opens a browser to log in. Credentials are stored, so you do this once. Use /login later to switch accounts. If ANTHROPIC_API_KEY is set in your environment, Claude Code asks whether to use it, and if you approve it skips the browser login and bills that key instead of your subscription.

From install to first prompt: install the CLI, check the version, start claude in a project, and log in
From install to first prompt: install the CLI, check the version, start claude in a project, and log in

Quick reference

  • Native installs update themselves in the background. Homebrew and WinGet installs do not; run brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode.
  • Homebrew has two casks: claude-code follows the stable channel, which is typically about a week behind, and claude-code@latest gets each release as it ships.
  • On native Windows, install Git for Windows so Claude Code can use Bash. Without it, Claude Code uses PowerShell for shell commands. WSL does not need it.
  • Check for a stray ANTHROPIC_API_KEY before you start. Approving it means usage is billed to that API key, not your subscription.

Remember this

Install once, run claude --version, then start claude from the project you want to work on.

Ask questions first, then run /init

Claude Code reads files as it needs them, so you do not paste code in. The safest first prompts change nothing:

1what does this project do?2where is the main entry point?3how are the tests run, and do they pass right now?

Questions like these show you how Claude searches the codebase, which files it opens, and whether it understands the build. They also tell you how far to trust its later edits.

Next, run /init. It writes a starter CLAUDE.md based on the project. Claude reads that file at the start of every session, so it is where you put what Claude cannot work out from the code: the exact test and build commands, conventions that differ from the defaults, and gotchas.

1# Commands2- Test: pnpm test -- --run3- Typecheck: pnpm tsc --noEmit4 5# Conventions6- Use the logger in src/lib/log.ts, never console.log7- New API routes need a test in tests/api/

Keep it short. Anthropic's guidance is to ask of each line whether removing it would cause mistakes, and to cut it if not. A long CLAUDE.md gets parts of it ignored. Run /context to confirm the file loaded, and commit it so the team shares it.

Quick reference

  • Use @path/to/file in a prompt to point Claude at a specific file instead of describing where it is.
  • If the repository already has an AGENTS.md for other coding agents, Claude Code can read that instead of a CLAUDE.md.
  • Domain knowledge needed only sometimes belongs in a skill (.claude/skills/<name>/SKILL.md), which loads on demand, not in CLAUDE.md.
  • If Claude's answer about the test command is wrong, that is the first line to add to CLAUDE.md.

Remember this

Start with read-only questions, then let /init draft a CLAUDE.md and cut it down to what Claude cannot infer.

Know which permission mode you are in

The permission mode decides what Claude can do without asking. Press Shift+Tab to cycle modes; the status bar shows the current one.

  • Manual (default): asks before file edits, most shell commands, and MCP tools.
  • acceptEdits: edits files without asking, still asks for commands.
  • plan: reads and plans, makes no changes.
  • auto: a separate classifier model reviews actions and blocks those that look risky, such as reaching beyond the task or touching unknown infrastructure. Routine work runs without prompts.

With Claude Code v2.1.283 or later, auto mode is the starting mode for interactive terminal and VS Code sessions. That surprises people who expect a prompt before every command. If you want to approve each edit and command yourself while you learn, switch to Manual with Shift+Tab, or start with claude --permission-mode default.

Whatever the mode, you can pre-approve commands you trust and forbid things you never want with permission rules in .claude/settings.json:

1{2  "permissions": {3    "allow": ["Bash(pnpm test *)", "Bash(pnpm tsc *)"],4    "deny": ["Read(./.env)", "Read(./.env.*)"]5  }6}

Rules are covered in depth in Claude Code Permissions, and the modes in Claude Code Auto Mode.

Quick reference

  • Deny rules apply in every mode, including auto. They are how you keep .env and credentials out of reach.
  • Run /permissions to see every active rule and which settings file it came from.
  • Auto mode lowers prompts, not risk to zero. The classifier can miss things; keep production credentials out of the environment Claude runs in.

Remember this

Check the status bar before your first change. On recent versions you start in auto mode, not in a prompt-for-everything mode.

Make a first change with a check Claude can run

Claude stops when the work looks done. Without something that returns pass or fail, you are the only check. Anthropic's best-practices page puts this first: give Claude a test, a build, or a script it can run, and it will run it, read the result, and keep going until it passes.

Compare two prompts for the same task:

1# vague: success is "looks done"2add email validation to signup3 4# checkable: success is a passing test5add a validateEmail function in src/lib/validate.ts.6user@example.com is valid; "invalid" and user@.com are not.7add these as tests, run pnpm test, and fix any failures.

For a change that touches several files or code you do not know, separate thinking from editing. Switch to plan mode, ask Claude to read the relevant code and propose a plan, and press Ctrl+G to edit the plan yourself. Then leave plan mode (approve the plan or press Shift+Tab) and let Claude implement it and run the tests. Finish by reading the diff before you ask for a commit.

Planning has a cost. For a typo, a log line, or a rename, ask directly. A useful rule from the docs: if you could describe the diff in one sentence, skip the plan.

Explore and plan in plan mode, then implement with a test as the check, then commit
Explore and plan in plan mode, then implement with a test as the check, then commit

Quick reference

  • Ask for evidence, not a claim: the test command Claude ran and its output, or the build result.
  • Good first tasks have an existing test, or a bug you can reproduce with a new failing test before the fix.
  • Bad first tasks are open-ended ("improve the code") in a large monorepo; Claude reads many files and fills its context before doing anything useful.
  • Read the diff yourself before committing. A passing test only proves what the test checks.

Remember this

Write the success check into the prompt. A test Claude can run turns a session you watch into one that checks itself.

Stop, rewind, and start fresh

Mistakes are cheap if you know the controls:

  • Esc stops Claude mid-turn. Context is kept, so you can redirect it.
  • Esc twice, or /rewind, opens the rewind menu. Every prompt you send creates a checkpoint, and you can restore the code, the conversation, or both to any of them, or summarise part of the conversation.
  • /clear resets the conversation. Use it between unrelated tasks.
  • claude -c continues the most recent conversation in the directory; claude -r lets you pick an older one. /rename gives a session a name you can find later.

Checkpoints have a hard limit: they only track edits made through Claude's file-editing tools. Files changed by a Bash command, an npm install, a database migration, or a push are not restored by a rewind. That is why the docs say checkpoints are not a replacement for git. Commit before you ask for anything large, and you can always get back with git.

The other common failure is a cluttered session. If you have corrected Claude twice on the same problem, the context is full of failed attempts. /clear and write a better first prompt that includes what you learned; a fresh session with a clear prompt usually beats a long one.

Checkpoints restore edits made by Claude's file tools, but not changes made by shell commands or other programs
Checkpoints restore edits made by Claude's file tools, but not changes made by shell commands or other programs

Quick reference

  • Checkpoints are saved with the conversation, so you can close the terminal, resume later, and still rewind.
  • Mixing unrelated tasks in one session ("the kitchen sink session") fills context with material that no longer matters. One task per session is a good default.
  • Use /btw for a quick side question whose answer should not stay in the conversation.

Remember this

Esc to stop, /rewind for Claude's own edits, git for everything else, /clear when the session has gone stale.

The same agent in your IDE, the desktop app, and the browser

Every surface uses the same Claude Code engine, so your CLAUDE.md files, settings, and MCP servers apply in all of them. The differences are where the code runs and how you review changes. The terminal, IDE extensions, and the desktop app work on files on your machine. The web and mobile app run sessions in Anthropic-managed cloud environments against a cloned repository.

Sessions can move between surfaces. claude --teleport pulls a web or mobile session into your terminal, /desktop hands the current terminal session to the desktop app, and Remote Control lets you keep driving a local session from your phone or a browser. Teleport and the /desktop handoff need a claude.ai subscription.

Each surface has its own guide on this site: VS Code, JetBrains, Desktop app, web sessions, and mobile.

Where Claude Code runs and what each surface needs
SurfaceHow to startNeedsGood for
Terminal (CLI)claude in a projectSubscription, Console, or cloud providerEverything; scripting with claude -p
VS Code / CursorInstall the Claude Code extension, then "Open in New Tab"Same accounts as the CLIInline diffs, @-mentions, plan review in the editor
JetBrains IDEsClaude Code plugin from the MarketplaceThe CLI installed separatelyDiff viewing and selection context in IntelliJ, PyCharm, WebStorm
Desktop appInstall Claude, open the Code tabA paid subscriptionSeveral sessions side by side, visual diffs, scheduled tasks
Webclaude.ai/codePro, Max, Team, or an eligible Enterprise seat; a GitHub repoLong tasks on repos you do not have locally; runs in a cloud VM
Claude mobile appCode tab in the iOS or Android appSame plans as the webStarting or checking cloud sessions away from a desk

Quick reference

  • Start in the terminal or your IDE for the first session; you see every command Claude runs, and the files are your own.
  • Cloud sessions (web and mobile) clone the repository fresh. They do not use your local settings or see files that exist only on your laptop, and they offer Auto, Accept edits, and Plan modes but not Manual.
  • Third-party providers (Bedrock, Google Cloud, Foundry) work with the CLI, VS Code, and JetBrains; most other surfaces need a Claude subscription or Console account.

Remember this

Pick the surface by where the code lives and how you want to review diffs; the agent and your settings are the same everywhere.

Hands-on: a 30-minute first session

Use a small repository with a working test command.

1. Install, run claude --version, start claude in the repository, and log in. 2. Ask: "what does this project do, how are tests run, and do they pass?" Check the answer against what you know. 3. Run /init, then cut the generated CLAUDE.md to the lines Claude could not have guessed. Confirm it loaded with /context. 4. Check the mode in the status bar. Switch to Manual with Shift+Tab for this exercise. 5. Commit, then ask for a small change with a test as the check, using the "checkable" prompt pattern above. Approve the edit and the test run when prompted. 6. Press Esc twice, rewind the code to before the change, and confirm with git status that the working tree is clean again.

Pass criterion: Claude's description of the test command matches reality, the change ends with a passing test run you can see in the transcript, and the rewind leaves no edited files behind.

Quick reference

  • If the rewind leaves files changed, they were changed by a shell command, not the edit tools. Use git checkout -- . and note the limit.
  • If Claude never asks before editing, you are still in auto or acceptEdits mode. Check the status bar.
  • If the test command was wrong in step 2, add the right one to CLAUDE.md and ask again in a fresh session with /clear.

Remember this

A good first session ends with a passing check you saw run, a short CLAUDE.md, and a rewind you have tried once.

Key takeaway

Getting started with Claude Code is mostly about three habits. Know your permission mode, because recent versions start in auto mode rather than prompting for everything. Give Claude something it can run to check its work, so success means a passing test and not text that looks right. And know how to back out: Esc to stop, /rewind for Claude's own edits, git for everything a shell command touched.

From here, read Claude Code Permissions to set allow and deny rules for your project, Claude Code Hooks to make checks run automatically, and Claude Code Context Window to understand why long sessions degrade.

Practice (30 min): run the six steps above on a real repository, then write down the one line you added to CLAUDE.md and why.

Share:

References

  1. Claude Code docs: Quickstart — checked Oct 17, 2026
  2. Claude Code docs: Best practices for Claude Code — checked Oct 17, 2026
  3. Claude Code docs: Overview — checked Oct 17, 2026
SH

Shoaib Hossain

Lead Author & Systems Architect

Software engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.

Human-Engineered & Fact-CheckedOriginal Visual DiagramsEditorial Standards →Send Feedback

Related Articles

Running several Claude Code sessions in separate terminals works until you lose track of which one is waiting for you. A…

Read

Two Claude Code sessions in the same checkout edit the same files, and sooner or later one overwrites the other's work o…

Read

Plan mode is the Claude Code permission mode for thinking before touching code. Claude reads files, runs commands to exp…

Read

Keep learning

Follow a structured path or browse all courses to go deeper.