Session 11 Cheat Sheet — Claude Code & the Claude Agent SDK Anthropic's Claude Code and Claude Agent SDK enable developers to build agentic applications by combining a terminal-based agent loop with a programmable SDK. The SDK's query() function returns an async stream of typed messages, and safety is enforced through tool allowlists and permission modes rather than input trust. A typical architecture involves building a chat app skeleton with Claude Code in plan mode, then replacing an echo stub with a real agent loop behind a FastAPI /api/chat endpoint. A frameto help you reason through the assignment — concepts, diagrams, and the API map. It deliberately doesnotcontain the answers or filled-in activity code. Instead it gives you thequestions to ask yourselfand themethodto get there. The work — and the learning — is in building the app with Claude Code, reading the message stream, and writing your own conclusions.Source: 11 Claude Code/README.md markdown-only session —no notebook; you write your Q1–Q4 answers directly in the README . Guides: 01 Installing… , 02 Using… , 03 Claude Agent SDK.md . Deliverable: your own chat-app/ . | You want to… | Reach for | One-liner | |---|---|---| | Start Claude Code in a project | claude CLI | Launches the agent loop in the current directory | | Explore/scaffold before changing anything | plan mode Shift+Tab, or --permission-mode plan | Read-only recon; nothing executes until you approve | | Give the agent durable project memory | CLAUDE.md | Auto-loaded into context at the start of every session | | Trim / reset the context window | /compact , /clear | Manual context-budget control the Session 3 middleware, by hand | | Run the SDK agent loop | query prompt=…, options=… | Returns an async stream of typed messages until done | | Configure the agent | ClaudeAgentOptions … | allowed tools · permission mode · max turns · cwd · resume · mcp servers | | Constrain what the agent can do | allowed tools= "Read","Glob","Grep" | A read-only allowlist = the server-side safety story | | Read the loop's steps | the message stream | SystemMessage init → session id · AssistantMessage · ResultMessage.result | | Continue a conversation across messages | resume=session id | Map each browser conversation id → the SDK session id | | Add a custom tool | @tool + create sdk mcp server | Wire via mcp servers ; allowlist as mcp