Running Claude Code on each surface: sessions, the CLAUDE.md hierarchy and which file wins, settings.json, permission modes, headless and streaming runs, and the built-in commands.
Study it
Operating Claude Code: sessions, CLAUDE.md precedence, settings, permission modes and headless runs
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
In one Claude Code session, Claude first changed src/server.ts with its Edit tool and then ran these commands through Bash:npx prettier --write src/server.ts
sed -i 's/port: 8080/port: 9090/' config/app.yamlClaude never opened config/app.yaml with its file tools. You run /rewind and restore the code to the checkpoint before the Edit. What state are the two files in?
ABoth files are back to their earlier state, because /rewind restores every file the session changed
BNeither file is restored, because checkpoints ignore any file that a Bash command touched
COnly config/app.yaml is restored, because Bash changes are tracked and file-tool edits are not
Dsrc/server.ts is restored, while config/app.yaml keeps port 9090 until you revert it with Git
Show the answer and why
ABoth files are back to their earlier state, because /rewind restores every file the session changed
Incorrect
Checkpoints track files edited with Claude's file tools; a file only Bash changed is not tracked.
BNeither file is restored, because checkpoints ignore any file that a Bash command touched
Incorrect
Once a file was edited with a file tool, /rewind also undoes later Bash changes to it.
COnly config/app.yaml is restored, because Bash changes are tracked and file-tool edits are not
Incorrect
It is the other way round: file-tool edits create the tracking, and a Bash-only file stays as it is.
Dsrc/server.ts is restored, while config/app.yaml keeps port 9090 until you revert it with Git
Correct
Tracking starts with a file-tool edit; a file that only Bash changed needs version control to revert.
Once Claude has edited a file with its file editing tools, /rewind also undoes changes that Bash commands make to that file afterward. A file that only Bash commands changed isn't tracked and stays as it is; revert it with version control such as Git.
Your team works in a disposable dev container and wants Claude Code to run without permission prompts there. A developer commits this to the repository's .claude/settings.json:{
"permissions": {
"defaultMode": "bypassPermissions"
}
}Sessions still start in Manual mode and prompt as before. What should the team do?
AMove the same setting into .claude/settings.local.json so that it applies to each developer's sessions
BSet defaultMode to "auto" in the same file, so that a background classifier reviews calls instead of prompting
CStart each session in the container with --permission-mode bypassPermissions on the command line instead
DAdd a deny rule for Bash(rm *) so that Claude Code trusts the project enough to honor bypassPermissions
Show the answer and why
AMove the same setting into .claude/settings.local.json so that it applies to each developer's sessions
Incorrect
bypassPermissions set in settings.local.json doesn't take effect either.
BSet defaultMode to "auto" in the same file, so that a background classifier reviews calls instead of prompting
Incorrect
"auto" set in .claude/settings.json doesn't take effect either; Claude Code then uses the built-in default.
CStart each session in the container with --permission-mode bypassPermissions on the command line instead
Correct
bypassPermissions in .claude/settings.json doesn't take effect, so the session starts in Manual; the flag sets the mode.
DAdd a deny rule for Bash(rm *) so that Claude Code trusts the project enough to honor bypassPermissions
Incorrect
Deny rules block commands in every mode; they do not unlock a mode the project file can't set.
A defaultMode of bypassPermissions in .claude/settings.json or .claude/settings.local.json doesn't take effect, and the session starts in Manual mode. Start the session with the --permission-mode flag in the isolated container instead.
An hour into a Claude Code session, you want to try a different design for a caching layer. You want to continue in this terminal with all the context gathered so far, and you want to be able to return to the conversation exactly as it stands now. Which built-in command fits?
A/branch, which creates a branch of the conversation at this point and switches you into it
B/clear, which starts a new conversation and labels the current one in the /resume picker
C/compact, which summarizes the conversation so far so that the new design fits in context
D/fork, which copies the conversation into a new background session while you keep working here
Show the answer and why
A/branch, which creates a branch of the conversation at this point and switches you into it
Correct
/branch keeps the original conversation, which you can return to with /resume.
B/clear, which starts a new conversation and labels the current one in the /resume picker
Incorrect
/clear starts with empty context, so the gathered context is not carried into the new direction.
C/compact, which summarizes the conversation so far so that the new design fits in context
Incorrect
/compact replaces history with a summary in the same conversation, so the current state is not kept to return to.
D/fork, which copies the conversation into a new background session while you keep working here
Incorrect
The copy runs as a background session; you stay in the original, not in the new direction.
/branch creates a branch of the current conversation at this point and switches you into it, preserving the original, which you can return to with /resume. /fork copies the conversation into a new background session, /clear starts an empty conversation, and /compact summarizes in place.
You are iterating on code you review closely, and you want Claude Code to make file edits and run common filesystem commands such as mkdir and mv without asking each time, while other commands still ask. Which permission mode fits?
Aplan
Bdefault
CbypassPermissions
DacceptEdits
Show the answer and why
Aplan
Incorrect
Plan mode is for exploring before changing anything, not for approving edits.
Bdefault
Incorrect
Manual mode, the default, runs only file reads and actions that need no approval without asking; file edits still prompt.
CbypassPermissions
Incorrect
That mode approves everything and is meant for isolated containers and VMs only.
DacceptEdits
Correct
acceptEdits approves reads, file edits and common filesystem commands such as mkdir, touch, mv and cp.
acceptEdits auto-approves reads, file edits and common filesystem commands (mkdir, touch, mv, cp and similar) and suits iterating on code you are reviewing. Other actions still go through the normal permission prompts.
Before you commit, you want to review in Claude Code every change in your working tree, including the edits Claude has made so far in the session. Which built-in command does this?
A/diff
B/context
C/recap
D/export
Show the answer and why
A/diff
Correct
/diff reviews the changes in your working tree, including Claude's edits so far.
B/context
Incorrect
/context visualizes context usage, not file changes.
C/recap
Incorrect
/recap generates a one-line summary of the session.
D/export
Incorrect
/export saves the conversation as plain text, not a review of file changes.
/diff lets you review the changes in your working tree, including the edits Claude has made so far. /context shows context usage, /recap summarizes the session and /export writes out the conversation.