This lesson combines 4 topics: Installation and your first session, CLAUDE.md and memory, Permission modes and settings, Slash commands, context management and reviewing changes.
Learning Objectives
- Install Claude Code, log in and run your first session in a repo
- Understand Claude Code's agent loop: gather context → take action → verify
- Know which tools Claude Code uses (reading, editing files, running commands, searching, web) and why that changes how you write prompts
- Write a good CLAUDE.md: short, specific, with build/test commands and reasons
- Distinguish user, project, local and managed CLAUDE.md; know
.claude/rules/and@import - Understand auto memory: what Claude records on its own, where it is stored, how to turn it on and off
- Know the 6 permission modes and when to use each
- Write
allow/ask/denyrules and understand the evaluation order deny → ask → allow - Know the 4 settings files and their precedence
- Use
/context,/compact,/clear,/rewind,/diff,/usage,/model,/effortfluently - Have a process for reviewing Claude's changes before committing
Part 1: Installation and your first session
1. Installation
According to the official documentation (as of 11/2026), the recommended method is the native installer, which auto-updates in the background:
# macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
Other methods:
| Method | Command | Notes |
|---|---|---|
| Homebrew | brew install --cask claude-code | Stable channel; does not auto-update, run brew upgrade claude-code |
| WinGet | winget install Anthropic.ClaudeCode | Does not auto-update |
| VS Code / Cursor | "Claude Code" extension | Inline diffs, plan review in the editor |
| JetBrains | "Claude Code" plugin | Requires installing the CLI separately |
| Desktop app | Code tab in the Claude app | Requires a paid plan |
| Web | claude.ai/code | Runs in the cloud, no install needed |
Verify the installation:
claude --version
Be careful with
curl ... | bashcommands: only run them when the URL is on the official domain. This is also a security habit you will see again on Day 7.
2. Logging in
The first time you run claude, the tool asks you to log in. There are two groups:
- Claude plans (Pro, Max, Team, Enterprise...): log in with your claude.ai account and use your plan's quota.
- Claude Console / API key: billed per token. If
ANTHROPIC_API_KEYis already set in your environment, Claude Code asks whether you want to use that key.
Claude Code can also run via Amazon Bedrock, Google Cloud and Microsoft Foundry for organizations that want to keep billing and data within their own cloud (see the docs).
3. Your first session
cd ~/code/acme-shop
claude
Some useful opening prompts when facing an unfamiliar repo:
Explain the overall architecture of this repo: the main directories, the request
flow from HTTP to the database, how to run the tests. Cite specific files for each point.
Find where shipping fees are calculated. List the related functions and existing tests.
Don't change anything yet.
Other ways to start:
| Command | Effect |
|---|---|
claude "question" | Open an interactive session with a first prompt |
claude -p "question" | Run non-interactively, print the result and exit (Day 3, Part 4) |
claude --continue | Continue the most recent conversation in this directory |
claude --resume | Pick an old session to continue (inside a session: /resume) |
claude --permission-mode plan | Start in plan mode (Part 3) |
4. How Claude Code Works
Claude Code is an agent: it does not just answer, it calls tools on its own to gather information, take action, then check the result, repeating until done.
Main tool groups:
| Group | Examples | Asks for permission by default? |
|---|---|---|
| Read, search | Read, Grep, Glob | No, within the working directory |
| Edit files | Edit, Write | Yes (in Manual mode) |
| Run commands | Bash | Yes, except for a built-in set of read-only commands |
| Web | WebFetch, WebSearch | Yes, except for some pre-approved documentation domains |
| Extensions | MCP tools, subagents, skills | Depends on configuration |
This changes how you write prompts compared to claude.ai:
- No need to paste code: name the file or describe it, and Claude reads it itself.
- Give a verification command: "run
npm test -- cart" so Claude can confirm on its own. - Limit the scope: Claude can edit many files; state clearly what it may change and what it must not touch.
Part 2: CLAUDE.md and memory
1. Why you need CLAUDE.md
Every Claude Code session starts with an empty context. Without CLAUDE.md, you have to repeat the same information every session: what the test command is, whether to use pnpm or npm, naming conventions, which directories must not be edited.
CLAUDE.md is a markdown file Claude Code loads into context at the start of every session. It is the "onboarding doc" for Claude.
2. Locations and scopes
According to the Memory docs (as of 11/2026):
| Type | Location | Used for | Who sees it |
|---|---|---|---|
| Managed policy | macOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux/WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.md | Organization-wide standards, deployed by IT | Everyone on the machines it is deployed to |
| User | ~/.claude/CLAUDE.md | Personal preferences for all projects | Only you |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | Project architecture, commands, conventions | The whole team (committed to git) |
| Local | ./CLAUDE.local.md | Personal notes for this project (sandbox URLs, test data) | Only you (add to .gitignore) |
How they are loaded:
- CLAUDE.md and CLAUDE.local.md in the working directory and every parent directory are loaded at startup, in order from the root down. The files are concatenated, not overriding each other.
- CLAUDE.md in a subdirectory is loaded on demand, when Claude reads or edits files in that directory.
- If a repo already has an
AGENTS.mdfor other coding agents, Claude Code can read that file (see the docs on AGENTS.md).
3. Writing a good CLAUDE.md
Example for acme-shop:
# acme-shop
E-commerce API: Node 22, TypeScript, Fastify, Prisma (PostgreSQL), Vitest.
## Commands
- Install: `pnpm install` (don't use npm: the lockfile is pnpm-lock.yaml)
- Test one module: `pnpm test -- src/cart`
- Full check before reporting done: `pnpm lint && pnpm typecheck && pnpm test`
- Migration: `pnpm prisma migrate dev --name <name>`; don't hand-edit files in prisma/migrations/
## Architecture
- src/routes: only parse the request and call a service; no business logic
- src/services: business logic, never imports from src/routes
- Money is stored as integers (VND), never float, because rounding errors have caused wrong invoices
## Conventions
- Log with `req.log` (pino) to get the request ID; don't use console.log
- User ID always comes from `req.session.userId`, never from body or query
- Business errors throw `AppError(code, message)`; error codes are listed in src/errors/codes.ts
## Don't
- Don't edit files in src/generated/ (generated from OpenAPI)
- Don't add new dependencies without asking
Principles drawn from the docs and experience:
| Principle | Why |
|---|---|
| Short — the docs recommend under 200 lines per file | Long files cost context in every session and reduce adherence |
| Specific, verifiable — "use 2 spaces" rather than "format nicely" | Vague instructions don't change behavior |
| Include the reason — "no float because of rounding errors" | Claude applies it correctly even in cases not listed |
| No contradictions — periodically review nested CLAUDE.md files | With two conflicting instructions, Claude may pick either one |
| Don't repeat what can be read from the code — obvious directory structure, README content | Wastes context |
| No secrets — no tokens, passwords, sensitive internal URLs | The project CLAUDE.md is committed and read by everyone and every tool |
Important: CLAUDE.md is context, not enforced configuration. Claude tries to follow it, but nothing guarantees it. Anything that must be enforced (blocking edits to
.env, blockingrm -rf) should use a permission rule or a hook (Part 3, Day 3).
4. Quick start with /init
Run /init in a repo: Claude analyzes the codebase and creates a starter CLAUDE.md with the build and test commands and conventions it finds. If a CLAUDE.md already exists, /init suggests improvements instead of overwriting it. Always read and edit the generated version: it is usually longer than needed and may guess conventions wrong.
5. Imports and .claude/rules/
Imports: CLAUDE.md can load other files using the @path/to/file syntax:
See the release process: @docs/release.md
API conventions: @docs/api-conventions.md
.claude/rules/: for large projects, split instructions into multiple files by topic (testing.md, api-design.md...). A rule can be scoped by path with paths: frontmatter so it is only loaded when Claude works with matching files. Personal rules for all projects go in ~/.claude/rules/.
Note: rules with paths: and CLAUDE.md files in subdirectories are loaded on demand, so they may be summarized away after compaction; the CLAUDE.md at the project root is reloaded from disk. Mandatory rules that must survive compaction belong in the root CLAUDE.md.
6. Auto memory
Besides CLAUDE.md (which you write), Claude Code also has auto memory (which Claude writes itself) while working:
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| Content | Instructions, rules | Things learned: your preferences, feedback you gave, project decisions, where to find information |
| Scope | Project, user, organization | Per repo, shared across worktrees, only on this machine |
| Loaded into | Every session | Every session (first 200 lines or 25KB of MEMORY.md) |
Details (as of 11/2026):
- Stored in
~/.claude/projects/<project>/memory/, withMEMORY.mdas the index plus topic files. - On by default for local sessions; toggle it with
/memory, or set"autoMemoryEnabled": falsein settings, or the environment variableCLAUDE_CODE_DISABLE_AUTO_MEMORY=1. - When you say "remember to always use pnpm", Claude saves it to auto memory. To make it a shared team rule, say "add this to CLAUDE.md" or edit the file yourself.
Auto memory is plain markdown files: review it periodically with /memory. A wrong memory ("the project uses MySQL" when it has moved to PostgreSQL) will silently affect every later session.
Part 3: Permission modes and settings
1. The six permission modes
According to Permission modes (as of 11/2026):
| Mode | Behavior | When to use |
|---|---|---|
default (shown as Manual) | Asks for permission the first time each tool is used (editing files, running commands) | Unfamiliar repos, sensitive work, while learning |
acceptEdits | Auto-accepts file edits and common filesystem commands (mkdir, touch, rm, mv, cp, sed...) for paths inside the working directory; other commands and network access still ask | Work with a clear plan, where you will review the diff afterwards |
plan | Only reads files and runs read-only commands to explore, does not edit source | Planning before making changes (Day 3) |
auto | Rarely asks; a background classifier checks whether actions (shell commands, network requests) match your request | Long tasks where you want fewer interruptions, with an eligible account and model |
dontAsk | Automatically denies everything that would otherwise ask; only runs what is allowed or needs no permission | CI, unattended runs with a strict allow-list |
bypassPermissions | Skips almost all permission prompts | Only in isolated environments (containers, disposable VMs) |
Switching modes:
- In a terminal session: Shift+Tab cycles through them. From
auto, the first press goes todefault, thendefault→acceptEdits→plan.bypassPermissionsonly appears if you enabled it at startup;dontAskis not in the cycle. - At startup:
claude --permission-mode plan(values:default,acceptEdits,plan,auto,dontAsk,bypassPermissions). - Persistent default:
permissions.defaultModein settings. Note:autoandbypassPermissionscannot be set from project or local settings, only from user settings, managed settings or a flag.
According to the docs, since Claude Code v2.1.283, interactive sessions in the terminal and VS Code start in auto by default when the account and model are eligible; while claude -p (since v2.1.302) starts in Manual if nothing sets the mode. Check the current mode in the status bar.
Protected paths: writes to .git, .claude, .vscode, .mcp.json, .bashrc, .zshrc, .npmrc... are never auto-approved, except in bypassPermissions. This is why bypassPermissions should only be used in throwaway environments: one wrong command could modify your git or shell configuration.
2. Permission rules
A rule has the form Tool or Tool(specifier), in three kinds:
- allow: use without asking
- ask: always ask
- deny: forbidden
Evaluation order: deny → ask → allow; the first matching rule decides, and specificity does not change the order. Consequence: deny: Bash(aws *) blocks even aws s3 ls despite allow: Bash(aws s3 ls). An allow cannot "punch a hole" in a deny.
Syntax examples (from the Permissions docs):
| Rule | Meaning |
|---|---|
Bash(npm run build) | Exactly the command npm run build |
Bash(npm run test *) | Any command starting with npm run test |
Bash(git log *) | Only git log ... commands |
Bash(git *) | Every git command, including git push --force. Be careful |
Read(./.env) | Reading the .env file in the current directory |
WebFetch(domain:example.com) | Fetching from example.com |
Bash | Every Bash command; as a deny rule, Claude no longer sees this tool |
Common wildcard traps:
- Put
*after the subcommand:Bash(git log *)is much safer thanBash(git *). - The space before
*matters:Bash(git diff *)matchesgit diff main, whileBash(git diff*)also matchesgit diff-index.
Permission rules are enforced by Claude Code, not by the model. Writing "don't read .env" in CLAUDE.md is just a note.
deny: Read(./.env)is a real barrier.
Scope of Read / Edit rules (per the docs, as of 11/2026):
- They apply to the built-in file read/edit tools (Read, Grep, Glob, Edit, Write) and to file commands Claude Code recognizes in Bash such as
cat,head,tail,sed,tee, plus the redirects> file,< file. - They do not apply to commands that read files without naming them (for example
grep -r pattern .) or to scripts that open files themselves (node -e "...",python script.py). To block at the operating-system level for every process, use sandboxing. - Paths use gitignore syntax:
Read(./secrets/**)for a whole directory. To forbid edits to an area, useEdit(...), for exampleEdit(./src/generated/**); rules of the formWrite(path)never match. - A
.claudeignorefile has no effect; convert its contents intoReaddeny rules.
3. The four settings files and their precedence
| Scope | File | Affects | Used for |
|---|---|---|---|
| User | ~/.claude/settings.json | You, all projects on the machine | Personal preferences, your own rules |
| Shared project | .claude/settings.json | Everyone on the project (committed to git) | Shared permissions, hooks, project env |
| Project local | .claude/settings.local.json | You, only this project (not committed) | Personal overrides; where "Yes, and don't ask again" choices are saved |
| Managed | managed-settings.json, MDM, configuration from the admin console | Everyone the organization deploys to | Security and compliance policies |
Precedence for the same key (highest to lowest): managed → command line (--settings) → project local → shared project → user.
Lists such as permissions.allow, however, are merged across files rather than overridden. And because deny is always evaluated first, a deny in any scope beats an allow in another scope.
Example .claude/settings.json for the acme-shop team:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(pnpm lint)",
"Bash(pnpm typecheck)",
"Bash(pnpm test *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}
Two notes from the docs:
- Settings files are strict JSON:
//comments or trailing commas are syntax errors. permissions.allowin a repo's.claude/settings.jsononly takes effect after you accept workspace trust for that directory. This is a safeguard when cloning an unfamiliar repo: a repo cannot grant permissions to itself.
Check which files were loaded: /status. Manage rules interactively: /permissions.
Part 4: Slash commands, context management and reviewing changes
1. Everyday commands
Excerpted from the Commands reference (as of 11/2026; type / to see the full list on your machine):
| Command | Effect |
|---|---|
/init | Create a starter CLAUDE.md for the project |
/memory | Open and edit CLAUDE.md files, toggle and view auto memory |
/context | View context usage by category, with optimization suggestions |
/compact [instructions] | Summarize the conversation to free up context, optionally with a focus |
/clear | Start a new conversation with an empty context |
/rewind (or Esc twice when the input is empty) | Go back to an earlier checkpoint: restore code, conversation, or summarize from a point |
/diff | View changes in the working tree, including edits Claude made |
/review | Review the current diff, a PR, branch or path (alias of /code-review) |
/security-review | Analyze changes on the current branch for security vulnerabilities |
/model | Switch models (left/right arrows adjust effort on supported models) |
/effort | Set effort: low to xhigh, max, or auto |
/usage (alias /cost) | View session cost, plan quota and statistics |
/permissions | Manage allow/ask/deny rules |
/plan [description] | Enter plan mode straight from a prompt |
/resume | Reopen an old session |
/hooks, /mcp, /skills | View hooks, MCP servers, skills configuration (Day 3) |
2. Context management
Claude Code's context contains: the system prompt, CLAUDE.md, auto memory, MCP tool names, skill descriptions, every file read, every command output, every message. It fills up faster than you think, especially when Claude reads large files or runs commands that print a lot of logs.
Strategies:
| Situation | What to do | Why |
|---|---|---|
| Switching to an unrelated task | /clear | Old context adds noise and costs tokens every turn |
| Long task, context nearly full, need to keep the thread | /compact keep the schema decisions and the still-failing tests | A focused summary beats letting auto-compact guess |
| Claude goes the wrong way 3 turns in a row | /rewind to before it went wrong, rewrite the prompt more clearly | A wrong direction left in context will pull Claude back to it |
| Need to explore many files just to answer one question | Delegate to a subagent (Day 3) | The files read stay in the subagent's context; only the summary comes back |
| Unclear why the context is full | /context | See what takes the most: files, MCP tools, memory |
Claude Code auto-compacts when it nears the limit. After compaction, the root CLAUDE.md and auto memory are reloaded from disk; instructions you only gave in the conversation survive only in the summary. Put important rules in CLAUDE.md, don't just say them in chat.
3. Checkpoints and rewind
Every prompt you send creates a checkpoint that saves file state before Claude edits. /rewind (or Esc twice when the input is empty) opens a menu with options: restore code and conversation, conversation only, code only, or summarize from a point.
Limitations to know (per the Checkpointing docs):
- Files changed only by Bash commands (for example
sed -i, migration scripts) are not tracked. - Edits made by most subagents are not restored.
- Changes you make yourself outside Claude Code are usually not recorded.
- Checkpoints do not replace git. Commit often to have reliable points to return to.
4. Reviewing changes before committing
Claude writes code fast; the real value lies in your careful review. Suggested process:
- See the big picture:
/difforgit diff --stat. Are the number of files and lines reasonable for the request? A request to fix one function with a diff touching 14 files is a sign to stop. - Read each hunk: watch for unrelated files, tests modified to pass, new
// TODOs, commented-out code, new dependencies inpackage.json. - Run the checks: lint, type check, tests. Don't just trust Claude's "all tests pass"; run them yourself or look at the real output.
- Ask Claude to explain: "Why change this line? Is there a way with fewer changes?"
- Second review from a different angle:
/reviewor/security-review, or a new session that doesn't carry the assumptions of the session that wrote the code. - Commit in logical units: one commit per meaningful change, with a message describing "why".
Red flags when reviewing code Claude wrote:
| Red flag | Possibly |
|---|---|
| Test expected values changed to make it pass | Hiding a bug instead of fixing it |
New empty try { ... } catch {} | Swallowing errors |
New as any, @ts-ignore, eslint-disable | Dodging the type check instead of fixing the types |
| New package nobody asked for | Unnecessary or hallucinated dependency |
| Function duplicating an existing helper | Claude didn't search for existing code |
Review Questions
-
Why do prompts in Claude Code usually not need pasted code like on claude.ai, but should include a verification command?
Show answer
Claude Code has the Read, Grep and Glob tools to read files in the repo itself, so you only need to name the file or describe it. It can also run commands, so with a specific test/lint/type check command, Claude checks the result itself and fixes things before reporting done. The gather → act → verify loop is only complete when the verify step has a measurable tool.
-
Distinguish
./CLAUDE.md,./CLAUDE.local.mdand~/.claude/CLAUDE.md. Where should "my staging environment URL" go?Show answer
./CLAUDE.mdholds the project's shared instructions, committed to git for the whole team../CLAUDE.local.mdholds personal notes for this project, added to.gitignore.~/.claude/CLAUDE.mdholds personal preferences that apply to all projects. A personal staging URL belongs inCLAUDE.local.md. If that URL is sensitive, consider not putting it in any file that Claude and other tools all read. -
A CLAUDE.md is 900 lines long and copies the entire README and directory structure. Name 3 problems and how to fix them.
Show answer
(1) It costs context in every session. (2) Adherence drops when the file is long; the docs recommend under 200 lines per file. (3) It repeats what Claude can read from the code itself, which easily goes stale and contradicts. Fix: keep the build/test commands, non-obvious conventions with their reasons, and a "don't" list; move parts relevant to only one area into
.claude/rules/withpaths:, or import selectively. -
Is writing "Never read the .env file" in CLAUDE.md enough to protect secrets? What else should you do?
Show answer
Not enough. CLAUDE.md is context; the model tries to follow it but nothing enforces it. You need
denypermission rules such asRead(./.env)andRead(./.env.*), enforced by Claude Code regardless of what the model decides; these rules cover both the file tools and commands likecat,headin Bash. But they cannot block scripts that open files themselves, so add sandboxing if you want blocking at the operating-system level, and ideally don't keep real secrets in the working directory at all. -
How does auto memory differ from CLAUDE.md? Why should you review auto memory periodically?
Show answer
CLAUDE.md is written by you, contains instructions, and can be shared via git. Auto memory is recorded by Claude while working (preferences, feedback, project decisions), stored locally in
~/.claude/projects/<project>/memory/, shared across worktrees of the same repo but not synced between machines. Review it because a wrong or stale memory will silently affect every later session; use/memoryto view and edit it. -
A team has
allow: Bash(git *)in.claude/settings.json. What is the risk and how should it be fixed?Show answer
Bash(git *)allows every git command without asking, includinggit push --force,git reset --hard,git clean -fdx. Narrow it by subcommand: allowBash(git status),Bash(git diff *),Bash(git log *); putgit pushinask; deny destructive commands if needed. The docs stress putting*after the subcommand. -
User settings have
allow: Bash(npm publish), project settings havedeny: Bash(npm publish *). What happens when Claude runsnpm publish --tag beta?Show answer
It is blocked. Rules are evaluated in the order deny → ask → allow regardless of which file they are in, and a deny in any scope beats an allow in another scope. Moreover, the allow
Bash(npm publish)only matches the exact command with no arguments, notnpm publish --tag beta. -
Why should
bypassPermissionsonly be used in a container or disposable VM?Show answer
This mode skips almost all permission prompts, including writes to protected paths such as
.git,.claude,.bashrc,.npmrc. One wrong command (from a model misunderstanding or a prompt injection) could delete data, modify shell configuration, or push code to a remote. In an isolated environment, the maximum damage is limited to that environment. -
When do you use
/clear, and when/compact?Show answer
/clearwhen switching to an unrelated task: the old context only adds noise and costs tokens./compactwhen you are still on the same long task and the context is nearly full: the summary keeps the thread of work. Add a focus, for example/compact keep the schema decisions and the still-failing tests, so the summary keeps exactly what is needed. -
After
/compact, Claude "forgets" the rule "don't edit src/generated" that you stated at the start of the session. Why, and how do you prevent it?
Show answer
Instructions given only in the conversation get folded into the summary and may lose detail. The CLAUDE.md at the project root is reloaded from disk after compaction. Important rules must live in CLAUDE.md; if enforcement is needed, add a permission deny for Edit on src/generated/** or a PreToolUse hook.
- Claude ran
sed -ion 20 files and you want to go back. Can/rewindrestore them?
Show answer
Not reliably. Checkpoints track edits made through Claude's file editing tools. Files changed only by Bash commands are not tracked, except files Claude had already edited with the Edit tool earlier in the session. The safe approach is git: commit or stash before letting Claude run bulk edit commands, then use git diff / git checkout to go back.
- List 4 red flags when reviewing a diff created by Claude.
Show answer
Test expected values changed to make it pass; empty catch {} swallowing errors; new as any, @ts-ignore, eslint-disable; new dependencies nobody asked for; helpers duplicating existing code; a diff touching many files unrelated to the request.
- Why can't the
.claude/settings.jsonof a freshly cloned repo grant allow permissions to Claude by itself?
Show answer
Claude Code only applies permissions.allow and additionalDirectories from project settings after you accept workspace trust for that directory. This is a safeguard: someone else's repo cannot grant itself permission to run arbitrary commands on your machine. Deny and ask rules apply immediately because they only narrow permissions.
Hands-on Exercises
Exercise 1: Install and explore an unfamiliar repo
Install Claude Code and clone a medium-sized open-source repo you have never read. In Manual mode, ask Claude 3 questions: the overall architecture, the flow of one specific request, how to run the tests. Ask it to cite files for each point.
Expected output: a 1-page note; mark which claims you verified yourself in the code and which claims were wrong.
Exercise 2: Write a CLAUDE.md for your project
Run /init on a project you are working on. Edit the generated version following the principles in Part 2: under 80 lines, with specific test commands, at least 3 conventions with reasons, and a "Don't" section.
Expected output: the edited CLAUDE.md; a list of what you removed from the /init version and why.
Exercise 3: Test the rule evaluation order
In a test repo, create .claude/settings.local.json with allow: ["Bash(git log *)"] and deny: ["Bash(git *)"]. Ask Claude to run git log --oneline -5.
Expected output: observe that the command is blocked; explain it using the deny → ask → allow order; fix the rules so git log runs while git push is still blocked.
Exercise 4: Block reading secrets
In a test repo, create a fake .env file with API_KEY=sk-ant-test-placeholder (do not use a real key). Add the deny rule Read(./.env), then ask Claude in turn: (a) "read .env and tell me the API key", (b) "run cat .env", (c) "write a one-line Node script that reads .env and prints it".
Expected output: a 3-row table recording which requests were blocked and which were not; an explanation based on the scope of the Read rule (file tools and recognized file commands are blocked, scripts that open files themselves are not); a proposal for the next layer of protection (sandboxing, not keeping real secrets in the working directory).
Exercise 5: Measure and clean up context
In a long session (reading many files, running tests many times), run /context and note which part takes the most. Try a focused /compact, then run /context again.
Expected output: two screenshots or notes of /context before/after; observations on which parts shrank.
Exercise 6: Rewind and review
Give Claude a small refactoring task in acceptEdits. When it is done, review with /diff; deliberately /rewind to before the edits, rewrite the prompt with tighter constraints, and compare the two diffs.
Expected output: two diffs; a table comparing the number of files, number of lines, and whether there were out-of-scope changes.
References
- Claude Code — Overview and installation
- Claude Code — Quickstart
- Claude Code — Memory (CLAUDE.md, auto memory)
- Claude Code — Permission modes
- Claude Code — Configure permissions
- Claude Code — Settings
- Claude Code — Commands
- Claude Code — Context window
- Claude Code — Checkpointing