The Claude Bible
Home / Claude Code: fundamentals
Level: Intermediate · 16 lessons

Claude Code: fundamentals

The agent in the terminal. The loop, slash commands, CLAUDE.md, permissions.

Open the interactive course212 lessons, quizzes, exercises, 3 languages, free.

What Claude Code is and the agent loop

Claude Code is Anthropic's agent for code. It lives in your terminal (also in the IDE and on the web) and, unlike the chat, it has tools: read and write files, run shell commands, search the code, do git, fetch the web.

Its operation is an agentic loop:

  1. You give a goal.
  2. It thinks, picks a tool, calls it (read a file, run a test...).
  3. It observes the tool result.
  4. It repeats until the goal is reached, then answers you.

That is the fundamental difference from chat: Claude Code acts, observes, corrects autonomously. You don't dictate each command, you give it a goal and a guardrail.

Install: npm install -g @anthropic-ai/claude-code then claude in your project folder. The first thing it reads is your CLAUDE.md (next lesson).

Key points
  • Claude Code = code agent with tools (files, shell, git, web)
  • Loop: goal -> think -> call a tool -> observe -> repeat
  • It acts and corrects autonomously, you give a goal not commands

CLAUDE.md: the project memory

CLAUDE.md is a markdown file at the root of your project (or globally in ~/.claude/) that Claude Code reads automatically on startup. It is its persistent memory of your conventions.

What goes in it:

Pierre's CLAUDE.md is a textbook case: it encodes his non-negotiable rules (never an em-dash, no emoji, archive never delete, the exact path is 00_SEPT TOOLS with an underscore) and his session-startup routing. These instructions override the model's default behavior.

Generate a first draft with the /init command: Claude scans the repo and proposes a CLAUDE.md. You then refine it. Core rule: a short, sharp CLAUDE.md beats a sprawling one nobody respects.

Key points
  • CLAUDE.md = project memory read automatically on startup
  • Commands, conventions, absolute rules, routing
  • These instructions override default behavior
  • /init generates a first draft to refine; short and sharp > sprawling

The essential slash commands

Slash commands drive the session. The essentials:

The most useful daily distinction: /clear forgets everything, /compact summarizes. Too many people let context swell until quality degrades. The pro reflex: /clear when you change subject, /compact when you are mid big task.

You can also create your own slash commands (reusable prompt templates) in .claude/commands/. That is the gateway to skills (module 5).

Key points
  • /init generates CLAUDE.md, /clear resets, /compact summarizes
  • /agents, /mcp, /hooks, /review for advanced functions
  • Context reflex: /clear if you change subject, /compact mid big task
  • Custom slash commands in .claude/commands/

Permissions and plan mode

Claude Code can run real commands. The permissions system controls what it does without asking you. Four core modes:

You set this in settings.json (global or project), also with a precise allowlist: "allow npm run build and git status without asking, but ask for any rm".

Pierre's case is instructive: he runs in bypassPermissions by default (speed), so the automatic guardrail on rm is disabled. His countermeasure is not technical but an absolute rule in the CLAUDE.md: archive to _ARCHIVES/, never delete. Lesson: the more autonomy you grant, the more your written rules matter.

Key points
  • Permissions: ask / accept-edits / plan / bypass
  • Plan mode: proposes an approvable plan before any action (big changes)
  • settings.json + precise per-command allowlist
  • More autonomy => the CLAUDE.md written rules become the real guardrail

Install Claude Code and first run

Claude Code is Anthropic's command-line coding agent. It reads your files, writes code, runs commands, and reasons over your entire project, all from a terminal. Before you can use it you need Node.js (the JavaScript runtime) version 18 or higher, and its bundled package manager npm (Node Package Manager). Check what you have by running node -v and npm -v in any terminal.

Install Claude Code globally with a single npm command so it is available from any folder on your machine:

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

The -g flag means "global": npm places the claude binary on your system path. Once installed, authenticate once by running claude with no arguments. Claude Code opens a browser window (or prints a URL) so you can log in with your Anthropic account. Your credentials are stored locally and reused in every future session.

Where you launch Claude Code matters. The home directory is your user folder (for example C:\Users\yourname on Windows or /Users/yourname on Mac). Starting Claude there loads only your global memory and settings. The project directory is the folder that holds your code. Starting Claude inside it loads project-specific memory and gives Claude Code full context about that codebase. Always cd into your project first, then run claude.

Key points
  • npm install -g @anthropic-ai/claude-code to install globally
  • Run claude with no arguments to authenticate on first use
  • Always launch from the project directory, not your home folder
  • Node.js 18 or higher is required before installing

The prompt box: modes and steering

The Claude Code prompt box does more than accept text. It is also a steering wheel you can grab at any point during a task. Understanding its modes keeps you in control instead of waiting helplessly for a long run to finish.

When Claude Code is running, pressing Escape sends an interrupt signal (a request to stop the current action). Claude Code finishes the atomic step it is on, then pauses and returns control to you. You can then redirect, correct, or continue with a new instruction.

For multiline input (multiple lines in one prompt, useful for pasting a spec or a code block), press Shift+Enter to insert a newline without submitting. Press Enter alone to send.

Three prompt modes let you shape how Claude Code responds:

Key points
  • Escape interrupts a running task without losing context
  • Shift+Enter inserts a newline; Enter sends the prompt
  • --plan flag makes Claude Code show a plan before acting
  • Mid-task redirection: interrupt, then type a correction

Pointing at files with @

In Claude Code, the @ reference is how you point at a file or folder without copying its contents. Type @ followed by a path and Claude Code reads that file directly from your disk. This means you never have to paste walls of code into the chat.

As you type @, Claude Code shows a tab-completion menu of files and folders in your project. Press Tab to cycle through matches and Enter to confirm. You can reference multiple items in one message.

Why does this beat pasting? Three reasons:

You can mix @ references with plain instructions in the same message. For example: Review @src/auth.js and check @tests/auth.test.js for missing coverage.

Key points
  • @ reference reads a file directly from disk
  • Tab completion helps you find files quickly
  • Folder references let Claude scan a whole directory
  • No pasting means no copy-paste errors

Running shell commands

Claude Code can execute real shell commands on your machine through its built-in Bash tool. A shell (also called a terminal or command line) is the text interface that controls your operating system. When you ask Claude Code to install a package, run tests, or check a file, it sends those commands to the Bash tool and reads the output before responding.

Before running any command, Claude Code shows you what it is about to execute and waits for your approval. This permission prompt is your safety gate. You can approve the command, edit it, or deny it. Once approved, the output feeds directly back into Claude Code so it can react to errors or results without you copying and pasting anything.

You can control which commands need approval. The allowed list in your settings lets you whitelist safe commands (such as npm test or ls) so they run without interruption. Dangerous operations like deleting files will still prompt unless you explicitly allow them.

Key points
  • Bash tool executes real shell commands
  • Permission prompt shown before every new command
  • Claude reads stdout and stderr to continue reasoning
  • Allowed list skips prompts for trusted commands

Reading and approving edits

When Claude Code modifies a file it shows a diff (short for "difference"), a side-by-side or inline view where lines marked with - are removed and lines marked with + are added. Nothing is written to disk until you approve.

Claude Code aims for surgical edits: it touches only the lines that need to change, leaving the rest of the file intact. This keeps diffs small and easy to review. If a proposed change looks larger than expected, that is a signal to read carefully before accepting.

You have three responses available each time an edit is proposed:

If you are running Claude Code with the --dangerously-skip-permissions flag (auto-approve mode), all edits are written immediately without a prompt. Use that flag only in throw-away environments where speed matters more than review.

Key points
  • A diff marks removed lines with - and added lines with +
  • Surgical edits change only what is necessary
  • y accepts, n rejects, e opens the change for manual adjustment
  • --dangerously-skip-permissions bypasses all approval prompts

Git from inside Claude Code

Claude Code understands Git (the version-control system that tracks every change to your code) natively. You can describe what you want in plain English and Claude Code will run the right Git commands, explain the output, and ask before doing anything destructive.

The four everyday Git operations Claude Code handles for you are: checking status (what has changed), reading a diff (the exact lines added or removed), writing a commit message (a saved snapshot with a description), and opening a pull request (a formal proposal to merge your changes into the main codebase).

Claude Code also manages branches (parallel versions of the codebase). You can ask it to create a branch, switch to one, or merge changes, all without memorising flags. The key commands it runs under the hood are git status, git diff, git add, git commit, git checkout -b, and gh pr create (using the GitHub CLI).

Key points
  • Ask Claude Code to summarise git status in plain English
  • Let Claude Code write commit messages following conventional style
  • Use natural language to create branches and pull requests
  • Claude Code will not force-push or delete branches without explicit instruction

The task list

When you give Claude Code a complex, multi-step job, it does not hold the entire plan in its head invisibly. Instead, it maintains a task list: a structured checklist of subtasks it creates at the start of the job and updates as it works. Think of it as a shared whiteboard between you and the agent.

The task list serves two purposes. First, it keeps Claude Code on track across many file edits, tool calls, and decisions. Second, it lets you watch progress in real time without reading every line of output. Each item moves from "pending" to "in progress" to "completed" (or "blocked") as the session advances.

You can interact with the task list at any point:

In the VS Code extension and the web interface, the task list appears as a collapsible sidebar panel. In the CLI (command-line interface, the terminal version), it is printed inline as the session runs. Either way, completed items are checked off and the current item is highlighted.

Key points
  • Task list: the live checklist Claude Code builds for multi-step jobs
  • Items cycle through pending, in progress, and completed states
  • You can add, skip, or reprioritize tasks mid-session with plain English
  • Blocked tasks surface immediately instead of being silently skipped

Plan mode in depth

Plan mode is a read-only phase in Claude Code where the agent analyzes your codebase and proposes a structured plan before writing or modifying a single file. Think of it as a blueprint review: Claude maps out every step, and nothing changes on disk until you give the go-ahead.

To enter plan mode, pass the --plan flag when you start a task, or type /plan inside an active Claude Code session. Claude will read files, trace dependencies, and output a numbered action list. During this phase it has no write permissions, so it cannot accidentally overwrite your work.

Once the plan appears, you have three options:

Use plan mode whenever a task touches multiple files, involves a risky refactor, or when you want a second opinion before committing changes. It costs a bit more time upfront but prevents hard-to-reverse mistakes and gives you a clear audit trail of what Claude intends to do.

Key points
  • Plan mode is read-only: no files change until you approve.
  • Trigger with the <code>--plan</code> flag or the <code>/plan</code> command.
  • You can approve, edit, or abort before any write happens.
  • Best for multi-file tasks, risky refactors, or unfamiliar codebases.

Permission modes and bypass

Claude Code asks for your approval before taking actions like editing files or running commands. How often it asks depends on its permission mode, a setting that controls the balance between safety and speed.

There are four modes you need to know:

You can set a mode for a single session with the --permission-mode flag (for example, claude --permission-mode acceptEdits), or you can lock it in for a project by adding it to .claude/settings.json under the key permissionMode.

The safety tradeoff is real: bypassPermissions removes the guardrail that catches accidental deletions or destructive shell commands. Use it only in throwaway environments, sandboxes, or when you have version control and know exactly what Claude will do.

Key points
  • Four modes: default, acceptEdits, plan, bypassPermissions
  • Set per-session with --permission-mode or per-project in settings.json
  • bypassPermissions removes all approval prompts
  • More speed always means less safety net

The status line

Every time Claude Code responds, a status line appears at the bottom of the terminal. It gives you a live snapshot of three things: how much of the context window (the total memory Claude can hold for your session) you have used, the estimated cost of the session so far in USD, and the active model identifier.

The context usage is shown as a fraction and a percentage, for example 12 340 / 200 000 tokens (6%). A token is roughly three to four characters of text. When you approach 100 percent, Claude begins to lose the earliest parts of the conversation, so watching this number helps you decide when to start a fresh session with /clear.

The status line is driven by a small script called statusline.cjs. Claude Code sends a JSON object to that script after each turn. The object includes these fields:

You can fully customize what the status line displays by editing statusline.cjs in your Claude Code config folder. Parse the incoming JSON with Node.js (not jq, which may not be installed) and format the output string however you like: color codes, extra fields, abbreviated labels, or anything else your terminal supports.

Key points
  • Status line shows context usage, cost, and active model after every turn.
  • Context window fills up as the session grows; use /clear to reset.
  • Rate-limits fields are optional: the bar disappears when they are absent.
  • Customize the status line by editing statusline.cjs with plain Node.js.

/init and onboarding a repo

When you open a project for the first time in Claude Code (the CLI and IDE coding agent), run /init in the chat panel. Claude Code scans your repository and generates a file called CLAUDE.md at the project root. This file is the single source of truth Claude reads at the start of every future session, so it never has to rediscover what the project is about.

During the scan, /init inspects several things:

The resulting CLAUDE.md contains a short project description, the commands for running, testing, and building the project, any coding conventions Claude inferred, and a placeholder section for you to add team rules manually. You should review and edit this file before committing it: remove anything wrong, add constraints Claude missed (environment variables, forbidden packages, style rules), and keep it concise because Claude reads every word on each session start.

Once CLAUDE.md exists, every collaborator (human or agent) who opens the repo in Claude Code inherits the same context automatically. If the project evolves, re-run /init at any time to refresh the file, or edit it directly like any other text file.

Key points
  • /init generates CLAUDE.md from a real scan of the repo
  • CLAUDE.md is read automatically at every session start
  • Review and edit CLAUDE.md: remove errors, add team rules
  • Re-run /init whenever the project structure changes significantly

Keyboard shortcuts and vim mode

Claude Code runs inside your terminal, so it relies on keyboard shortcuts rather than mouse clicks. Learning a handful of bindings turns slow, repetitive interactions into fast, fluid ones. The shortcuts below work in the default readline mode (the standard line-editing layer built into most Unix-style shells and terminals).

The most valuable bindings during a session are navigation and history. Ctrl+A jumps to the start of the current line, Ctrl+E jumps to the end. Ctrl+U clears everything before the cursor, which is faster than holding Backspace. Ctrl+W deletes the last word. To cycle through your prompt history, use the Up arrow and Down arrow keys, or use Ctrl+P (previous) and Ctrl+N (next) as alternatives.

Claude Code also ships an optional vim mode for the prompt input. Vim is a keyboard-driven text editor whose "modal" design lets you switch between inserting text and issuing movement or editing commands. To enable it, run /vim inside a Claude Code session. Once active, the input starts in Insert mode (type normally). Press Escape to enter Normal mode, where single keys become commands: h j k l for movement, dd to delete a line, 0 to go to the start, $ to go to the end. Press i to return to Insert mode. Press Enter in either mode to submit the prompt.

A few additional shortcuts are worth knowing at the session level:

Key points
  • Ctrl+C cancels the running task without quitting
  • Ctrl+R searches prompt history by keyword fragment
  • /vim toggles modal vim editing for the input line
  • Escape + dd in vim Normal mode deletes the current input line
Work with me

Master Claude, Claude Code and LLMs, from your first prompt to multi-agent orchestration.

Like this course? I built it end to end. Need a web app, mobile app, AI automation or SEO/GEO? Let us talk.

Contact me on LinkedInSee a site I built