Lesson 3.1
Claude Code Essentials for Developers
The parts of Claude Code a developer must know: project memory, permission modes, slash commands, hooks, MCP configuration and headless use in scripts and CI.
Claude Code is Anthropic's agentic coding tool that runs in your terminal, reads and edits your codebase, runs commands and drives git. This domain is small on the exam, but it checks that you know how Claude Code is configured and controlled rather than how to chat with it. The Agent SDK (lesson 1-3) exposes this same harness as a library, so the concepts transfer directly.
Installing and starting
Install with the native installer or npm install -g @anthropic-ai/claude-code, then run claude inside a project directory. Authentication uses your Console account or an API key; in CI you set ANTHROPIC_API_KEY. The claude command opens an interactive session; claude -p "prompt" runs one non-interactive turn and exits, which is the basis of scripting.
Project memory: CLAUDE.md
CLAUDE.md is a Markdown file Claude Code loads automatically at the start of every session. Put in it what a new team member would need: build and test commands, architectural conventions, style rules, and things to avoid. Run /init to generate a starting version. Files are layered:
| Location | Scope |
|---|---|
~/.claude/CLAUDE.md | All your projects (personal) |
./CLAUDE.md or ./.claude/CLAUDE.md | This repository, committed and shared |
./CLAUDE.local.md | This repository, personal and git-ignored |
Subdirectory CLAUDE.md | Loaded when Claude works in that directory |
Keep it concise. Every line is sent as context on every request, so a bloated file costs tokens and dilutes the instructions that matter. Use @path/to/file imports for detail that only some tasks need.
Settings and permissions
Configuration lives in settings.json at user (~/.claude/), project (.claude/settings.json, shared) and local (.claude/settings.local.json) levels, with enterprise managed policies overriding all of them. The most important setting is permissions. Claude Code asks before running tools that can change your system, and you control this with:
- Allow and deny rules, for example
Bash(npm test)orEdit(src/**), so routine commands run without prompts while dangerous ones are blocked outright. - Permission modes:
defaultprompts for sensitive actions;acceptEditsauto-approves file edits;planlets Claude read and propose without changing anything;bypassPermissionsskips prompts and is meant only for isolated containers.
Switch modes during a session with Shift+Tab or start with --permission-mode plan.
Slash commands and skills
Built-in commands include /init, /clear (reset context), /compact (summarise the conversation to free context), /model, /permissions, /mcp and /help. You add your own by dropping Markdown files in .claude/commands/; a file named review.md becomes /review, and $ARGUMENTS in the file receives whatever follows the command. Skills in .claude/skills/<name>/SKILL.md are richer, with frontmatter describing when Claude should use them automatically.
Hooks
Hooks are shell commands that run deterministically at lifecycle events, independent of what the model decides. Common events are PreToolUse, PostToolUse, UserPromptSubmit, Notification and Stop. A PreToolUse hook that exits with code 2 blocks the tool call and feeds its stderr back to Claude as the reason. Typical uses: run a formatter after every edit, block edits to protected paths, or log every Bash command for audit.
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "npx prettier --write \"$FILE\"" }]
}]
}
}
Connecting MCP servers
Claude Code is an MCP client. Add servers with the CLI:
claude mcp add --transport stdio github -- npx -y @modelcontextprotocol/server-github
claude mcp add --transport http docs https://mcp.example.com/mcp
Servers can be scoped to the user, the project (stored in a committed .mcp.json) or local. Their tools appear as mcp__<server>__<tool> and can be referenced in permission rules. Claude Code can also act as an MCP server itself with claude mcp serve, exposing its tools to other clients.
Subagents
Subagents are specialised assistants defined in .claude/agents/*.md with their own system prompt, tool allow-list and optionally a different model. Claude delegates to them for focused tasks such as code review or test writing, and each runs in a fresh context so the main conversation stays uncluttered.
Headless mode and CI
claude -p turns Claude Code into a scriptable command. Useful flags:
claude -p "Summarise the failing tests" --output-format json
claude -p "Fix lint errors" --allowedTools "Edit,Bash(npm run lint)" --max-turns 5
cat error.log | claude -p "Explain the root cause"
--output-format stream-json emits events as they happen, which is what the Agent SDK consumes under the hood. In CI, pin the permission surface tightly with --allowedTools, set --max-turns, and store the API key as a pipeline secret. The official GitHub Action wraps this for pull-request review and issue triage.
Exam focus
CLAUDE.mdis auto-loaded project memory; layers are user, project (shared), local (git-ignored) and subdirectory.- Permission modes are
default,acceptEdits,planandbypassPermissions; allow/deny rules such asBash(npm test)refine them. - Custom slash commands are Markdown files in
.claude/commands/;$ARGUMENTSreceives the user's input. - Hooks are deterministic shell commands on events like
PreToolUse; exit code 2 blocks the action. claude mcp addregisters MCP servers at user, project (.mcp.json) or local scope; tools appear asmcp__server__tool.claude -pwith--output-format,--allowedToolsand--max-turnsis the headless interface for scripts and CI.
Check yourself
5 questions
1.A repository contains a CLAUDE.md file at its root. What is its purpose in Claude Code?
2.A CI script runs: claude -p "Summarise the risks in this diff" < pr.diff > summary.txt What does the -p flag do?
3.After an hour-long refactoring session Claude Code's responses degrade and the context indicator shows the window is nearly full. Which built-in command helps while preserving the gist of the work so far?
4.A team wants Claude Code to run npm test without asking, but never to run rm -rf or git push, and they want this applied for every developer who clones the repo. Where should this be configured?
5.How does a developer make an MCP server available to Claude Code?
