Skip to content
PrepMint

Claude Code

Claude Code Basics

Installation, CLI usage, core commands

50 questions
Easy· 20Medium· 20Hard· 10

Last reviewed

Recommended

Claude Code Basics — Timed Test 2 (10 questions)

TimedEasy10 questions · 10 min
Start test

No account needed. Answers and explanations arrive when you submit.

What this topic tests

The mix every Claude Code Basics set is built to, and the questions published against it so far. Nothing here is hidden before you start.

Claude Code Basics — target difficulty mix and published question count per level
LevelTarget sharePublished
Easy40%20
Medium40%20
Hard20%10
Total50

Claude Code Basics — the theory

What Claude Code Is

Claude Code is an AI-powered coding assistant that helps you build features, fix bugs and automate development tasks. The word carrying the weight is agentic: it reads files, runs commands and makes changes while you watch, redirect or step away, rather than returning text you then apply yourself. A chat assistant advises; Claude Code acts, then checks whether it worked.

Anthropic's framing splits the halves cleanly: Claude is the model, Claude Code the harness around it — the tools, context management and execution environment that turn a language model into a capable coding agent.

It also sees more than an editor plugin does. Working across the whole project rather than the open file, "fix the authentication bug" can mean finding the relevant files, reading several, editing across them and running the tests — unlike inline assistants that see only the current file.

The Loop It Runs

Every task runs the same cycle: gather context, take action, verify results, repeat until done. Little else here makes sense without it.

Tools make it possible. Without them Claude can only respond with text; with them it can read a file, edit code, run a shell command, search the web or spawn a subagent. Each result informs the next decision, which is why the loop course-corrects — a failing test is information, not a dead end. You are in the loop too: Claude works autonomously but stays responsive, so you can interrupt and steer at any point.

Where It Runs

Claude Code runs on several surfaces — the terminal, IDE extensions, a desktop app and the web — and all share the same engine, so what you learn in the terminal transfers.

One install-time detail quietly costs people weeks. Native installations update automatically in the background; Homebrew installations do not auto-update and must be upgraded by hand. Know which you chose.

Sessions Are the Unit of Work

A session is a conversation tied to your current directory, with its own independent context window. Sessions do not remember each other: each starts fresh, with no history from previous ones — exactly why the memory files below exist. Switching git branches mid-session confuses nothing, though: Claude sees the new branch's files while your conversation history stays put.

Resuming and forking differ, and it is worth knowing before you need it. Resuming reopens a session under the same ID and appends to it. Forking copies the history into a new session ID and leaves the original unchanged — what you want before trying something you may walk back. /clear starts a new session; the previous one stays stored and reachable via /resume.

Permissions: Why It Asks Before It Acts

Claude Code uses strict read-only permissions by default, and requires approval before running Bash commands that can modify your system. Underneath sits a boundary independent of what you approve in the moment: it can only write to the folder where it was started and its subfolders, and cannot modify parent directories without explicit permission.

A permission mode sets which actions Claude takes without asking first. Plan mode is the one to learn early: Claude researches and proposes changes without editing your source files, so you review the approach before any of it lands on disk.

Modes are only a baseline. Permission rules layer on top to pre-approve or block specific tools, evaluated deny, then ask, then allow, first match wins — an allow rule further down cannot undo a deny. None of this transfers responsibility: Claude Code only has the permissions you grant it, and reviewing what it proposes is your job.

Undo, and the Four Things It Does Not Cover

Before Claude edits a file it snapshots the contents, and every prompt creates a checkpoint. /rewind then restores code, conversation, or both. The gaps matter more than the feature:

  • Bash is not tracked. Only direct edits made through Claude's file editing tools are captured, so an rm or mv inside a shell command is not reversible this way.
  • Work from outside the session is not tracked — only files edited within it.
  • Symlinked and hard-linked paths are skipped on restore, keeping their current contents.
  • Remote side effects cannot be undone at all. Actions affecting databases, APIs and deployments cannot be checkpointed — which is why Claude asks before running commands with external side effects.

The framing to keep: checkpoints are separate from git — built for quick, session-level recovery, not permanent history. Keep committing.

Memory: What You Write, and What Claude Writes

Two mechanisms carry knowledge across sessions, and confusing them is this tool's most common configuration mistake.

CLAUDE.md is a markdown file of persistent instructions you write, loaded at the start of every session. Treat it as where you record what you would otherwise re-explain, and keep it short: the guidance targets under 200 lines per file, because longer files consume more context and reduce adherence. Auto memory is the other half — notes Claude writes for itself from your corrections and preferences. It is machine-local, and Claude does not save something every session.

Three details save real debugging time:

  • Discovered memory files are concatenated into context rather than overriding each other, so a nested file adds to a parent rather than replacing it.
  • If two rules contradict each other, Claude may pick one arbitrarily. A contradiction is worse than an omission.
  • CLAUDE.md is context, not enforcement. It arrives as a user message after the system prompt and shapes behaviour without being a hard enforcement layer, whereas settings rules are enforced by the client regardless of what Claude decides. When something must happen every time, it does not belong in a memory file.

Claude Code reads CLAUDE.md, not AGENTS.md — and where one exists, /init suggests improvements rather than overwriting it.

The Context Window

The context window is a session's working memory: conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills and system instructions. Filling it is not fatal. Claude Code compacts automatically as you approach the limit, clearing older tool outputs first, then summarising the conversation if needed.

What survives compaction depends on how it was loaded, and that is this section's payoff. Project-root CLAUDE.md survives — Claude re-reads it from disk and re-injects it — while instructions given only in conversation may not. So put persistent rules in CLAUDE.md, and if a path-scoped rule has to survive, drop its paths: frontmatter or move it into the project-root file. Splitting into @path imports does not help: imported files load at launch anyway, so the context cost is unchanged.

Getting Good Results

One habit outperforms the rest: give Claude something to check against. It performs better when it can check its own work, and a test suite, a build or a screenshot comparison turns a guess into a verification loop — Claude iterates until the check passes instead of stopping at one attempt. Being specific helps too: vague prompts work, but you spend the saved time steering.

Trust, Injection and Cost

Prompt injection — hostile instructions embedded in a file, web page or tool result that try to redirect Claude toward actions you never asked for — is the risk specific to agentic tools. The defences are real: web fetch uses a separate context window, commands that fetch from the web such as curl and wget are not auto-approved by default, and suspicious bash commands require manual approval even if previously allowlisted. The caveat is Anthropic's own — these protections significantly reduce risk, but no system is completely immune. Read what you approve.

On cost, Claude Code charges by API token consumption, and the session totals it shows reset when /clear starts a new session.

Where to Go Next

Claude Code Workflows picks up where this page stops, with task-shaped guides built on these mechanisms. MCP Integration in Claude Code covers connecting it to external tools, and MCP Fundamentals the protocol underneath. Claude.ai Basics covers the assistant itself — the layer Claude Code sits on — Prompt Engineering for Code the craft of asking well, and AI Agents Basics what changes once any assistant is given tools and left to work.

Sources

Official Anthropic documentation for Claude Code. Overview · How Claude Code works · Glossary · Memory · Security · Checkpointing · Permission modes · Context window · Costs

Sample questions

Three questions from this topic, with the answer and the reasoning shown.

Q1EasyAfter Claude Code runs a command or edits a file, what does the result of that action do?
  • It is reported to you and discarded, since each action stands on its own
  • It decides whether the whole task succeeded or failed, and ends it either way
  • It pauses the session until you confirm the outcome was what you wanted
  • It gives Claude new information that shapes the next stepCorrect

Explanation

The principle — every action is also an observation.

Why the key is correct — Anthropic puts it directly: each tool use gives Claude new information that informs the next step. That feedback is what allows the loop to course-correct rather than commit to a plan made before anything was known.

Why the others are wrong — discarding results would leave the next step with nothing to work from. Treating one result as the verdict on the whole task ends the loop far too early. And pausing for confirmation after every action describes a different interaction model; you can interrupt at any point, but it does not stop to ask.

Remember this — a failing test is input, not a verdict.

Sources — Anthropic's How Claude Code works.

Open this question on its own page

Q2EasyBefore you configure any permissions, what decides what Claude Code is allowed to do?
  • Nothing yet — until you add rules it does whatever it judges useful
  • The approvals you gave in earlier sessions, which carry forward silently
  • Its own judgement, since anything risky is put to you as a prompt first
  • The permission mode the session starts in, which your plan decidesCorrect

Explanation

The principle — permissions are not a blank slate that rules get written onto. A session begins in a mode, and the mode is the thing that decides whether an action runs, gets checked by something else, or stops for you.

Why the key is correct — Anthropic states it plainly: which permission mode a session starts in depends on your plan, the surface you start it from, and your settings and your organization's. The plan is the part that surprises people, because on Pro, Max, and Team plans the built-in starting permission mode is auto mode — not the mode most guidance still describes. In Manual mode, Claude Code starts with read-only permissions and asks before it edits or runs anything that changes your system. In auto mode, a separate classifier model reviews actions instead of you and blocks the ones it judges unsafe, and read-only actions and file edits in your working directory are auto-approved outright. Same install, same empty configuration, two genuinely different answers to "what is it allowed to do" — so the honest answer to the question is the mode, and then your plan.

Why the others are wrong — rules matter, but they sit on top of a mode that already exists. Approvals do not travel between sessions; configuration does. And a prompt for everything risky is a description of Manual mode specifically, not of the tool.

Remember this — check which mode you are in before you reason about what will happen. Shift+Tab cycles them, and the indicator tells you where you started.

Sources — Anthropic's Claude Code permission-modes and security pages.

Open this question on its own page

Q3EasyBesides your conversation, which of these is taking up room in the same context window?
  • Nothing else; instruction files are held separately from the conversation
  • Only what you type, since files are re-read from disk each time
  • Your CLAUDE.md, auto memory, loaded skills and command outputCorrect
  • Imported files only until launch finishes, after which they are dropped

Explanation

The principle — the window holds far more than the messages you can see.

Why the key is correct — Anthropic describes the context window as the working memory for a session, holding conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills and system instructions. Everything on that list competes for the same space, which is why a very long instruction file has a cost beyond being tedious to read.

Why the others are wrong — instruction files are not held separately. File contents already read do stay in the window. And imports are not dropped after launch; they load and remain.

Remember this — your instruction files are not free. They occupy the same room as the work.

Sources — Anthropic's Claude Code glossary.

Open this question on its own page

Practise all 50 questions

Every published question in Claude Code Basics, with its answer and explanation.

Frequently asked

What people ask about claude code basics.

What makes Claude Code different from a chat assistant that writes code?
It acts rather than advises. Claude Code reads files, runs commands and makes changes while you watch, redirect or step away, instead of returning text you then have to apply yourself. Tools are what make that possible: without them Claude can only respond with text, and with them it can read a file, edit code, run a shell command, search the web or spawn a subagent. Each tool result informs the next decision, so it can run a test, read the failure and revise. It also works across your whole project rather than the file you have open, which is different from inline code assistants that only see the current file.
Can Claude Code edit files outside my project folder?
Not without you saying so. Claude Code can only write to the folder where it was started and its subfolders, and cannot modify files in parent directories without explicit permission. That boundary sits underneath everything else: it uses strict read-only permissions by default and requires approval before running Bash commands that can modify your system. Permission modes and rules adjust how often you are asked, not what the boundary is. And the responsibility stays with you — Claude Code only has the permissions you grant it, and reviewing proposed code and commands for safety before approval is your job.
If I press Esc twice to rewind, does that undo everything Claude did?
No, and this is the most useful thing to know about checkpoints. Before Claude edits a file it snapshots the contents, and every prompt you send creates a checkpoint, so direct file edits made through Claude's file editing tools can be restored. Four things are not covered: files modified by bash commands are not tracked, changes made outside the current session are not tracked, symlinked and hard-linked paths are skipped on restore, and actions affecting remote systems such as databases, APIs and deployments cannot be checkpointed at all — which is why Claude asks before running commands with external side effects. Checkpoints are separate from git and are designed for quick session-level recovery, not permanent history. Keep committing.
What is the difference between CLAUDE.md and auto memory?
CLAUDE.md is a markdown file of persistent instructions you write, loaded at the start of every session as a user message after the system prompt. Auto memory is notes Claude writes for itself based on your corrections and preferences. Use CLAUDE.md when you want to guide Claude's behaviour; auto memory lets Claude learn from your corrections without manual effort, and Claude does not save something every session. One is a brief you write, the other is a record it keeps. Both exist because each session begins with a fresh context window and carries nothing from the last one.
Why does Claude sometimes ignore an instruction in my CLAUDE.md?
Because CLAUDE.md is context, not enforced configuration. It is delivered as a user message after the system prompt, so Claude reads it and tries to follow it without that being a guarantee. Three things improve adherence. Keep it short — the guidance is a target of under 200 lines per file, because longer files consume more context and reduce adherence. Remove contradictions, because if two rules contradict each other Claude may pick one arbitrarily, and discovered memory files are concatenated into context rather than overriding each other, so a nested file adds to a parent instead of replacing it. And where something must hold regardless of what Claude decides, use the enforcement layer instead: settings rules are enforced by the client, while CLAUDE.md shapes behaviour without being a hard enforcement layer.
What happens when a long session runs out of context?
It compacts rather than stopping. The context window holds your conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills and system instructions, and Claude Code compacts automatically as you approach the limit, so a full context window does not end your session — older tool outputs are cleared first, then the conversation is summarised if needed. What survives depends on how it was loaded: project-root CLAUDE.md is re-read from disk and re-injected after compaction, while instructions given only in conversation may be lost. That is the practical reason to put persistent rules in CLAUDE.md, and if a path-scoped rule has to survive, to drop its paths frontmatter or move it into the project-root file. Splitting into imports does not help, because imported files load at launch anyway.

More Claude Code topics

All of Claude Code

Related guides

  • How it works · 11 min read

    Why the agent stopped before it finished

    You asked for five things and got one, with a confident summary and no error. An agent loop ends when the model writes a message containing no tool call — a judgement nothing checks against your task. The five ways a run ends early, each fingerprint, and the phrasing that fixes it.

  • How it works · 11 min read

    Where you edit your prompt decides what it costs

    The session was fast for twenty turns, then you added one line to the top of a file and the next answer crawled. A prompt cache is keyed on an exact prefix, so cost and latency depend on where you changed something, not how much. The ordering rule that falls out of it.

  • How it works · 9 min read

    What a Claude Code subagent can and cannot see

    The docs specify how to define a subagent and never state what it inherits. A subagent starts on an empty context window, the delegation prompt is the only thing that crosses, and only its final message comes back — so it re-reads files you already read, and that is the feature working.