New

💻 Claude Code Tutorial for Beginners: Your First Project

A hands-on first session: install Claude Code, explore a tiny Python project, generate CLAUDE.md, plan and add a feature with tests, and commit it with git.

Beginner ⏱️ ~35 minutes 🧰 Terminal, git, Python 3.9+
← AI Agents Track

What You'll Do in This Claude Code Tutorial for Beginners

This Claude Code tutorial for beginners walks you through one complete, low-risk session with Anthropic's coding agent. Claude Code runs in your terminal, reads your project, edits files and runs commands, asking you before it acts. You will install it, point it at a two-file Python project called study-timer, let it explain the code, create a CLAUDE.md with /init, use plan mode to design a new plan_session function, have it write and run tests, and finally commit the change. Along the way you learn the commands and permission modes you will use every day.

Prerequisites

  • A paid account: the setup docs say Claude Code needs a Pro, Max, Team, Enterprise or Console account; the free Claude.ai plan does not include it.
  • macOS 13+, Windows 10 1809+, or Ubuntu 20.04+ / Debian 10+, with 4 GB+ RAM and an internet connection.
  • git installed (on native Windows the docs recommend Git for Windows), and Python 3.9 or newer to run the sample code.
  • Basic terminal use: cd, ls and running a script.

Learn Claude Code Step by Step

1 Install Claude Code

The docs recommend the native installer, which also updates itself in the background. Run the one line for your system:

# macOS, Linux or WSL
curl -fsSL https://claude.ai/install.sh | bash

# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

Prefer a package manager? brew install --cask claude-code (Homebrew) and winget install Anthropic.ClaudeCode (WinGet) also work, but they do not auto-update. The npm package is still available and needs Node.js 22 or later; the docs warn not to install it with sudo. Check the install:

claude --version
claude doctor    # read-only health check if something looks wrong

2 Create the practice project

Always learn on a small project under git, so every change is easy to see and undo. Make a folder with one file:

mkdir study-timer && cd study-timer
git init

Save this as timer.py:

"""Tiny study timer helpers for the Claude Code tutorial."""

POMODORO_MINUTES = 25


def minutes_to_pomodoros(minutes: int) -> int:
    """Return how many full 25-minute pomodoros fit in `minutes`."""
    if minutes < 0:
        raise ValueError("minutes cannot be negative")
    return minutes // POMODORO_MINUTES


if __name__ == "__main__":
    print(minutes_to_pomodoros(60))

Run python3 timer.py (it prints 2), then commit the starting point with git add . && git commit -m "Initial timer".

3 Start your first session and explore

Inside the folder, start Claude Code. On first use it asks you to log in in your browser:

claude

Now talk to it in plain English. Start with questions, which only read files:

> what does this project do?
> explain minutes_to_pomodoros and any edge cases it misses

Exploring first is a good habit: you check that Claude understands the code before it changes anything. Press ↑ for previous prompts, Tab to complete commands, and type / to see every command.

4 Give Claude project memory with /init and CLAUDE.md

Type /init. Claude Code reads the project and writes a CLAUDE.md file: instructions it loads at the start of every session. Open the file and edit it to say how you work. For this project, something like:

# study-timer

- Python 3, standard library only (no pip installs).
- Run tests with: python3 -m unittest -v
- Keep functions small, typed and documented with a docstring.
- Never change POMODORO_MINUTES without asking.

A project CLAUDE.md lives at ./CLAUDE.md (or ./.claude/CLAUDE.md) and can be committed for your team; personal rules for every project go in ~/.claude/CLAUDE.md. Use /memory to edit these files later. The docs stress that CLAUDE.md is context, not enforced configuration, so it guides Claude but does not block anything by itself.

5 Plan the change before any edits

Press Shift+Tab to cycle permission modes until the status line shows plan mode (or type /plan). In plan mode Claude reads and proposes, but does not edit. Ask for the feature:

> add a plan_session(total_minutes, break_minutes=5) function that returns
  a list like ["focus 25", "break 5", "focus 25"], plus unittest tests
  for it and for minutes_to_pomodoros. Explain your plan first.

Read the plan. If something is off, say so ("no break after the last focus block") before you approve it. Planning is cheap; undoing a wrong edit takes longer.

6 Let Claude edit and run the tests

Approve the plan. In the default mode Claude Code shows each file edit and command and asks before running it, so you see every diff. You should end up with a function close to this in timer.py:

def plan_session(total_minutes: int, break_minutes: int = 5) -> list[str]:
    """Return a simple study plan such as ['focus 25', 'break 5', 'focus 25']."""
    plan = []
    for i in range(minutes_to_pomodoros(total_minutes)):
        if i > 0:
            plan.append(f"break {break_minutes}")
        plan.append(f"focus {POMODORO_MINUTES}")
    return plan

and a test_timer.py along these lines:

import unittest

from timer import minutes_to_pomodoros, plan_session


class TimerTests(unittest.TestCase):
    def test_full_pomodoros(self):
        self.assertEqual(minutes_to_pomodoros(60), 2)

    def test_negative_minutes(self):
        with self.assertRaises(ValueError):
            minutes_to_pomodoros(-1)

    def test_plan_has_breaks_between_focus_blocks(self):
        self.assertEqual(plan_session(60), ["focus 25", "break 5", "focus 25"])


if __name__ == "__main__":
    unittest.main()

Claude will ask to run python3 -m unittest -v (it learned that command from your CLAUDE.md). Approve it and check that all three tests pass. Your exact code may differ, because the model writes it fresh each time; what matters is that you review it and the tests pass. If you dislike a change, /rewind takes the conversation and code back to an earlier point.

7 Review and commit with git

Git works conversationally too. Try:

> what files have I changed?
> review my changes and suggest improvements
> commit my changes with a descriptive message

Run git log --oneline yourself afterwards to confirm the commit. Reviewing before committing is your job: Claude Code is a fast pair programmer, not a replacement for reading the diff.

8 Commands and shortcuts worth knowing

These are the built-in slash commands a beginner uses most, as described in the official commands reference:

CommandWhat it does
/helpShow help and available commands
/initCreate a CLAUDE.md guide for the project
/planEnter plan mode, optionally with a description of the task
/clearStart a new conversation with empty context
/compactFree up context by summarizing the conversation so far
/contextShow how much of the context window is in use
/memoryEdit CLAUDE.md files and manage auto memory
/modelSwitch the AI model
/permissionsManage allow, ask and deny rules for tools
/rewindRewind the conversation and/or code to an earlier point
/usageShow session cost, plan usage limits and activity
/resumeContinue a previous conversation

And from your normal terminal:

claude "fix the failing test"   # start a session with a first prompt
claude -c                       # continue the most recent conversation here
claude -r                       # pick an older conversation to resume
claude -p "explain timer.py"    # one-off answer, then exit

Use /exit (or Ctrl+D twice) to leave a session.

9 Pick the right permission mode and stay safe

Permission modes decide what Claude can do without asking you first. The docs list these:

  • default: reads files freely and asks before edits, shell commands and network access. Best while learning.
  • acceptEdits: also applies file edits and common file commands without asking. Handy when you are iterating and reviewing diffs afterwards.
  • plan: read and propose only, as in step 5.
  • auto: runs actions with background safety checks by a classifier, for long tasks.
  • dontAsk: only pre-approved tools run; anything else is refused.
  • bypassPermissions: runs everything. The docs say to use it in isolated containers and VMs only.

Simple rules keep you safe: work in a git repository, start in the default or plan mode, read every diff, never paste secrets into prompts, and use /permissions deny rules for anything Claude must never do. Text in web pages or files can carry hidden instructions aimed at AI agents; our prompt injection guide explains why that matters for coding agents.

Practice Task

Do these in new Claude Code sessions, then check yourself with the quiz below.

  1. Ask Claude to add a --minutes command-line option to timer.py using argparse, in plan mode first.
  2. Add a rule to CLAUDE.md ("print plans one item per line") and confirm a fresh session follows it.
  3. Run claude -p "list the functions in timer.py" and compare it with an interactive session.
  4. Make a deliberately bad change, then use /rewind to undo it.

Claude Code Tutorial Quiz

Five quick questions on this tutorial.

Frequently Asked Questions

Is Claude Code free?

No. Anthropic's setup docs say Claude Code needs a Pro, Max, Team, Enterprise or Console account, and that the free Claude.ai plan does not include Claude Code access.

Do I need Node.js to install Claude Code?

Not with the native installer, which is the recommended method. Node.js 22 or later is only needed if you install the npm package instead.

What is CLAUDE.md in Claude Code?

CLAUDE.md is a Markdown file of instructions that Claude Code loads at the start of every session, such as how to run tests and your coding rules. Run /init to generate one for a project. It is context, not enforced configuration, so use permission rules to actually block actions.

How do I use plan mode in Claude Code?

Press Shift+Tab to cycle permission modes until plan mode is shown, or type /plan followed by a description. In plan mode Claude reads and proposes a plan instead of editing files.

How do I continue a previous Claude Code conversation?

Run claude -c to continue the most recent conversation in the current folder, claude -r to pick an older one, or use /resume inside a session.

Sources

Checked against the official Claude Code docs on November 24, 2026. The sample Python code and tests were run on Python 3. Claude Code updates often, so if a command looks different, type /help or check the commands reference.

What to Try Next

Keep learning AI agents

Head back to the AI Agents & Automation track for the full learning path and more hands-on projects.

Back to the AI Agents Track