Task statement 3.1 · Claude Code
3.1 · Claude Code Operation
In Shelfwise, the course example, the three engineers run Claude Code on the service's own repository to add branches and to fix the stock-feed client. Operating it means knowing what a session loads, how to resume one, what runs without asking, and how to script it.
share
The tempting habits are to approve every prompt as it appears and to reach for --dangerously-skip-permissions the first time a script stalls. Approving by habit checks nothing, and skipping permissions on a laptop removes nearly every check, but the script only needed a chosen mode and a short allow list.
KnowledgeCore components and where they live
Claude Code's core components are files that a session discovers at launch, under the project's committed .claude/ or under ~/.claude/ for you in every project. Rules guide every session, while Skills and commands load only when invoked. An agent is a subagent definition that works in its own context window. Agent memory is what an agent writes for itself to read later. Filing a procedure as a rule is the usual mistake, because a rule costs context on every request while a Skill waits until needed.
Markdown in .claude/rules/, loaded at launch, or with paths frontmatter only when Claude touches a matching file (2.6).
.claude/skills/<name>/SKILL.md. Claude invokes one when its description fits the task, or you type /<name> (8.3).
Built-in commands control the session. A custom command, .claude/commands/<name>.md, runs as /<name>; commands are now merged into Skills.
.claude/agents/<name>.md with name, description and optional tools. Claude delegates by description, an @-mention forces one, and --agent runs the session as it.
A subagent's memory field: project keeps notes in .claude/agent-memory/<name>/, user in ~/.claude/agent-memory/<name>/, local in .claude/agent-memory-local/<name>/.
Auto memory is the main session's version, and it is easy to confuse with CLAUDE.md because both load at every session's start. You write CLAUDE.md, while Claude writes auto memory from your corrections, loading the first 200 lines or 25 KB of its MEMORY.md index each session. It stays on one machine, and /memory turns it on or off. The subagent memory field is the closest docs match for the guide's "Agent Memory" (1.3).
KnowledgeThe CLAUDE.md hierarchy, initialisation and settings.json
The CLAUDE.md hierarchy runs from a managed policy file through ~/.claude/CLAUDE.md to the project's CLAUDE.md and CLAUDE.local.md in the launch directory and every directory above it, concatenated from the top down (2.6 has the full rules). The guide's "repository initialization" is /init: Claude analyses the codebase and writes a starting CLAUDE.md with the build commands, test instructions and conventions it finds, or suggests improvements when one already exists. /memory lists every CLAUDE.md location, while /context shows which files actually loaded. settings.json is the enforced side of configuration, holding permission rules, hooks, env and permissions.defaultMode. One operational detail: "defaultMode": "auto" has no effect from a project's .claude/settings.json or .claude/settings.local.json, so a repository cannot switch its users into auto mode.
KnowledgeSession management and slash commands
Session management works on transcripts, local files of each conversation tied to the project directory. claude --continue reopens the most recent conversation in the current directory, claude --resume takes a session ID or name or opens a picker, and /resume switches from inside a session. Naming a session with claude -n or /rename lets you resume it by name. Sessions started with claude -p or the Agent SDK stay out of the picker and out of --continue, so you resume one by its session ID. A resumed session restores its history and model, but launch flags such as --add-dir must be passed again. When to clear or branch instead is session hygiene (2.5). Slash commands drive this from the prompt. Built-in ones such as /init, /compact, /permissions and /model control Claude Code itself. A custom slash command is a Markdown file you write, run as /<name> with any following text as its arguments.
KnowledgePermission modes and auto mode
A permission mode sets what runs without asking. Manual mode, config value default, asks before edits and most shell commands. acceptEdits approves file edits and commands such as mkdir in the working directory. plan reads and proposes, but blocks edits until you approve the plan. dontAsk denies whatever would prompt. bypassPermissions approves nearly everything, so it belongs in isolated containers. Auto mode, the guide's "auto-mode", hands the prompts to a classifier, a second model that reviews each action before it runs and blocks anything that goes beyond your request or looks driven by content Claude read. Reads and edits in the working directory skip it. It needs a supported Opus-, Sonnet- or Fable-family model, not a Haiku-family one. An organisation can remove it with permissions.disableAutoMode. Current versions start interactive sessions in it when available. In every mode, deny rules hold and a PreToolUse hook runs first (7.3). Shift+Tab cycles modes, and --permission-mode picks one at launch, as in the Agent SDK (8.1).
Interactive · what three actions do in four permission modes
Choose the mode a Shelfwise engineer's session runs in.
Manual (config value default): reads run, but Claude asks before each edit and before any shell command no allow rule covers. The push to main never reaches a prompt, because the push guard hook exits 2 first.
acceptEdits: edits in the working directory run, and so do common filesystem commands such as mkdir and mv. Other shell commands still ask, and the push guard still blocks the push.
auto: reads and working-directory edits run without the classifier. Other commands go to the classifier, which blocks anything beyond the request. Deny rules and the push guard still apply.
bypassPermissions: edits and commands run with no check, so this mode belongs in an isolated container. Hooks still run first, so the push guard still blocks the push.
KnowledgeHeadless mode and streaming
Headless mode is Claude Code without its interface: claude -p "<prompt>" runs one task and exits, loading the same CLAUDE.md, settings, hooks and MCP servers as an interactive session unless --bare skips them. Nobody is there to answer a permission prompt, so each prompt is denied, and a run that sets no mode starts in that account's built-in default. --output-format takes text, json or stream-json. json is one object with result and session_id, and stream-json is one JSON event per line as the run proceeds, ending with a result line that lists any permission_denials.
More precise than the guide. The docs call claude -p non-interactive or print mode, under "Run Claude Code programmatically"; "headless" survives in the page's address, and no feature is named "streaming mode" (as of 2026-10-05). Streaming is the stream-json format, written with --output-format and read with --input-format; the Agent SDK's long-lived equivalent is streaming input mode. Exam answer: "streaming mode" is a print-mode run that sends or reads stream-json events as they happen, not a separate way to start Claude Code.
SkillWorked example: a script that adds a branch
Adding a shop is a repeated chore, so one engineer wrapped it in scripts/add_branch.sh, which first ran Claude Code headless with no mode set:
claude -p "Add the York branch to config/branches.toml, then run the tests"
# exit 0; the reply says the edit needs approval; no file changed
The run started in print mode's built-in default, Manual mode on the engineers' accounts. With nobody to answer, each edit prompt was denied. The fix names the mode and the one allowed command, and streams events to check the outcome:
claude -p "Add the York branch to config/branches.toml, then run the tests" \ --permission-mode acceptEdits \ # edits in the repository run --allowedTools "Bash(python -m pytest *)" \ # the test command --output-format stream-json --verbose # one JSON event per line
The script fails if the result line's permission_denials is not empty. It leaves out --bare, because CLAUDE.md holds the test command, and the push guard still runs.
acceptEdits while you review the diff. You, but not for every command → auto mode. Nobody → claude -p with the mode and --allowedTools written into the command.- You write CLAUDE.md; Claude writes auto memory and a subagent's
memorydirectory. All are context, none is enforced. - Auto mode is a classifier, not a bypass: deny rules and hooks still apply.
stream-jsonis one JSON event per line, and the last line is the result.