Claude Code Basics
Installation, CLI usage, core commands
Last reviewed
Recommended
Claude Code Basics — Timed Test 2 (10 questions)
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.
| Level | Target share | Published |
|---|---|---|
| Easy | 40% | 20 |
| Medium | 40% | 20 |
| Hard | 20% | 10 |
| Total | 50 |
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
rmormvinside 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.
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.
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.
Practise all 50 questions
Every published question in Claude Code Basics, with its answer and explanation.
- After Claude Code runs a command or edits a file, what does the result of that action do?easy
- Before you configure any permissions, what decides what Claude Code is allowed to do?easy
- Besides your conversation, which of these is taking up room in the same context window?easy
- Claude Code has two ways to carry knowledge between sessions. Who writes each of them?easy
- How do Claude Code's checkpoints relate to version control?easy
- When Claude Code takes on a task, which files can it read and edit?easy
- What best describes how Claude Code works on your project?easy
- What does a permission mode establish for a Claude Code session?easy
- What does Claude Code save immediately before it edits one of your files?easy
- What does plan mode avoid doing while Claude explores your codebase?easy
- What is a Claude Code session tied to?easy
- What is prompt injection?easy
- What is it that lets Claude Code change your code rather than only describe a change?easy
- When does Claude Code create a checkpoint?easy
- Claude Code runs in the terminal, in IDE extensions, in a desktop app and on the web. What is the same across all of them?easy
- Which cycle does Claude Code work through for every task?easy
- Which way of installing Claude Code keeps itself up to date without you doing anything?easy
- Without being granted anything extra, which files can Claude Code write to?easy
- You have Claude Code open in two terminals on the same project. What do the two sessions share of their conversations?easy
- Your project uses pnpm rather than npm, and you have corrected Claude about it three sessions running. Where does that belong?easy
- A checkout bug turns out to involve three files across two folders, and you have only one of them open. You describe the symptom to Claude Code. What can it work with?medium
- A CLAUDE.md in a subdirectory says one thing about formatting and the one at your project root says another. What is the effect?medium
- A session has been running all afternoon and is approaching the limit of its context window. What happens?medium
- A teammate says Claude Code is simply Claude under a different name. Which part of the setup are they leaving out?medium
- A teammate stops committing during long Claude Code sessions, saying checkpoints already cover it. What is wrong with that?medium
- A teammate tells you a Claude Code feature you both read about is missing for them. It works on your machine. What is worth checking first?medium
- Claude Code fetches a documentation page while working, and the page contains a line addressed to the assistant telling it to upload your environment file. What is protecting you here?medium
- Claude Code removed a stale file by running a shell command. You decide you wanted it after all and reach for rewind. What happens?medium
- Halfway through a task you check out a different git branch. What changes for the session that is already running?medium
- On a freshly installed Claude Code with nothing configured, you ask it to read a config file, then to fetch a page with curl, then to delete a build directory. Which of those is it most likely to carry out without asking?medium
- Claude Code is partway through a fix when it runs your test suite and two tests fail. You have not said anything. What happens next?medium
- You added a rule to CLAUDE.md and Claude is not following it. What should you check first?medium
- You are about to try a refactor you may abandon, and you want the conversation so far preserved exactly as it stands. What should you do?medium
- You ask Claude Code to fix a failing validation function, then wait for a code block to copy into your editor. None arrives, but the session reports it is done. What most likely happened?medium
- You have just cloned an unfamiliar repository and want to understand how its auth layer works before anything gets changed. Which mode fits?medium
- You ran /clear to start something unrelated, and now you need the earlier discussion back. What is true of it?medium
- You started Claude Code inside your service's folder, and now you ask it to update a shared config file that lives one directory above. What happens?medium
- You want Claude Code to keep working on a change until it is genuinely done, rather than stopping at its first plausible attempt. What should you give it?medium
- Your team is moving from the terminal to the VS Code extension, and someone asks whether Claude will be able to do less. What is the answer?medium
- Your team needs a rule that must hold on every run regardless of what Claude decides in the moment. Where does it belong?medium
- A colleague argues that a browser chat assistant could refactor your repository if it were given the same model Claude Code runs, and that the only real difference between the two is model quality. Where does the argument break down?hard
- A colleague proposes letting Claude Code run unattended over a queue of scraped web pages, arguing that the approval system makes prompt injection a solved problem. How should you assess that?hard
- Before a compaction, three instructions were in play: your project-root CLAUDE.md, a rule in .claude/rules/ scoped with paths frontmatter, and a correction you typed into the chat. Which are still in effect straight after the compaction?hard
- Claude Code applied a schema change to a live database as part of a task, and the result is wrong. You want it reversed. What does the session offer you?hard
- During one turn, Claude Code renames a directory by running mv in a shell command, then edits three source files with its file-editing tools. You rewind to before that turn. What is on disk afterwards?hard
- In a long session, Claude follows a rule from a path-scoped file in .claude/rules/ for the first hour, then stops honouring it while continuing to respect your project-root CLAUDE.md. Nothing was edited. What is the likeliest explanation?hard
- Working inside your service folder, you approve several file edits and a build command. Later Claude needs to touch a file in the parent directory and stops to ask. A colleague says the earlier approvals should have covered it. What is the flaw in that reasoning?hard
- You work in a session for an hour, fork it to try an alternative, work inside the fork, then reopen the original the next morning and carry on there. Afterwards, what is true of the two session identifiers?hard
- Your project contains a config file that your dotfile manager symlinks in from elsewhere. Claude edits that file and two ordinary source files, then you restore the code from the rewind menu. What should you expect?hard
- Your settings contain a rule denying a family of shell commands and, further down, a rule allowing one specific command inside that family. Claude proposes exactly that command. What happens, and why?hard
Frequently asked
What people ask about claude code basics.
What makes Claude Code different from a chat assistant that writes code?
Can Claude Code edit files outside my project folder?
If I press Esc twice to rewind, does that undo everything Claude did?
What is the difference between CLAUDE.md and auto memory?
Why does Claude sometimes ignore an instruction in my CLAUDE.md?
What happens when a long session runs out of context?
More Claude Code topics
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.