Guide

Claude Code Tutorial: From Install to Your First Task

Claude Code is Anthropic's terminal coding agent. This tutorial takes you past installation into actually using it: your first interactive session, how it edits files and runs commands, slash commands, one-shot scripting mode, giving it project context, and extending it with MCP — with commands verified against Claude Code v2.1.183 on 2026-06-20.

By DK, Editor  ·  Last verified: 2026-06-20  · Claude Code v2.1.183 (installed and run 2026-06-20)  ·  How we test

Before you start

  • Node.js 18 or later (check with: node --version)
  • A Claude Pro, Max, or Team subscription — or an ANTHROPIC_API_KEY from console.anthropic.com
  • A terminal (macOS, Linux, or Windows WSL) and a project directory to work in
  • Claude Code installed — if you have not, see our install guide (linked below)

Steps

  1. 01

    Install Claude Code (quick recap)

    If Claude Code is not installed yet, install it globally with npm and confirm the version. Our dedicated install guide covers authentication and PATH issues in depth; this is the short version to get you to a prompt.

    npm install -g @anthropic-ai/claude-code
    claude --version
  2. 02

    Start your first interactive session

    Change into your project directory and run claude with no arguments to open the interactive session. On first launch it prompts you to authenticate — log in with your Anthropic account, or set ANTHROPIC_API_KEY first if you prefer key-based auth. The agent works from your current directory, so always start it inside the repo you want it to act on.

    cd /path/to/your/project
    claude
  3. 03

    Give it a task in plain language

    Type what you want in natural language — for example, 'find and fix the off-by-one bug in src/pagination.ts' or 'add a unit test for the parseDate helper'. Claude Code reads the relevant files, proposes edits, and can run shell commands as part of the task. It asks for approval before making changes or running commands, so you stay in control of every edit.

    # Example prompts you can type at the prompt:
    # > explain what this repo does
    # > add input validation to the signup form and write a test for it
    # > run the test suite and fix any failures
  4. 04

    Use slash commands

    Inside the session, slash commands control Claude Code itself rather than sending a prompt. Type /help to list the available commands for your installed version, and /exit (or Ctrl+C) to quit. Explore the list from /help rather than memorizing commands — they evolve between releases.

    /help     # list available slash commands
    /exit     # quit the session (or press Ctrl+C)
  5. 05

    Run one-shot prompts for scripting and CI

    For quick tasks or automation, you do not need the interactive shell. The -p (--print) flag runs a single prompt and prints the result to stdout, which makes Claude Code scriptable in pipelines and CI. You can also pass the prompt as a bare positional argument.

    # Non-interactive (prints result and exits)
    claude -p "list all TODO comments in src/"
    
    # Positional prompt form
    claude "summarize the changes in the last commit"
  6. 06

    Give Claude Code project context with CLAUDE.md

    To avoid re-explaining your project every session, put durable instructions — conventions, architecture notes, commands to run tests — in a CLAUDE.md file at your repository root. Claude Code reads it as project memory so its edits match your standards. Keep it short and high-signal; confirm the current memory-file conventions in Anthropic's docs as they evolve.

    # Create a project memory file at the repo root
    # CLAUDE.md (example contents):
    #   - Run tests with: npm test
    #   - Use TypeScript strict mode; no any
    #   - API routes live in src/server/routes
  7. 07

    Extend Claude Code with MCP servers

    Claude Code has first-class MCP support, so you can give it new tools — GitHub, web search, browser automation, your Figma designs. Add a server with claude mcp add, then confirm it inside the session with /mcp. See our dedicated Claude Code MCP guide for the full command surface.

    # Add a server (example: Context7 docs)
    claude mcp add context7 -- npx @upstash/context7-mcp
    
    # Inside the session, confirm connected servers/tools
    /mcp
  8. 08

    Keep Claude Code up to date

    Claude Code ships frequent updates. Re-run the install command to pull the latest version, and check the version afterward. New slash commands and features appear regularly, so it is worth updating often.

    npm install -g @anthropic-ai/claude-code
    claude --version

Troubleshooting

command not found: claude after installing
npm's global bin directory is not on your PATH. Find it with npm config get prefix, then add its /bin to your PATH: export PATH="$(npm config get prefix)/bin:$PATH" in ~/.zshrc or ~/.bashrc, and reload with source ~/.zshrc. See our install guide for the full PATH walkthrough.
Authentication loop — the browser opens but login never completes
The callback was likely blocked or the browser closed too early. Retry in a browser that allows the redirect, or switch to key-based auth: set export ANTHROPIC_API_KEY="sk-ant-..." and run claude again, which skips the interactive login.
Claude Code edits files you did not expect
Claude Code asks before editing or running commands — review each proposed change before approving, and decline ones that go too far. Keep tasks scoped ('fix this function' rather than 'refactor the app'), and use git so any change is easy to review and revert. A CLAUDE.md with your conventions also reduces over-eager edits.
An MCP server's tools never show up
Run /mcp inside the session (or claude mcp list from the shell) to see the server's status. Project-scoped servers in .mcp.json must be approved on first run; if you missed the prompt, run claude mcp reset-project-choices and restart. See the Claude Code MCP guide for details.

FAQ

Do I need a paid plan to follow this Claude Code tutorial?
Yes — Claude Code requires either a Claude Pro, Max, or Team subscription (for account login) or an ANTHROPIC_API_KEY (pay-per-token). A free Claude account is not sufficient. Confirm current pricing and plan availability at anthropic.com.
What is the difference between interactive mode and claude -p?
Running claude with no arguments opens a persistent interactive session where you converse, approve edits, and use slash commands. claude -p "..." (print mode) runs a single prompt non-interactively and prints the result — ideal for scripts and CI. Use interactive mode to work, print mode to automate.
How do I give Claude Code context about my project?
Put durable project instructions — conventions, architecture, how to run tests — in a CLAUDE.md file at your repository root. Claude Code reads it as project memory so its edits follow your standards without you re-explaining each session. Keep it concise and confirm the current conventions in Anthropic's docs.
Is Claude Code the same as the claude.ai website?
No. Claude Code is a terminal agent that reads and edits files on your machine and runs commands as an agentic loop. claude.ai is a chat UI. They use the same underlying models, but Claude Code is built for hands-on software work in your terminal or IDE.
How do I add tools like GitHub or web search to Claude Code?
Use MCP. Add a server with claude mcp add (stdio or remote), then confirm it with /mcp inside the session. Popular servers include Context7 (docs), GitHub, Exa (search), and Playwright (browser). Our Claude Code MCP guide covers every command and scope.