Module 1 · Harnesses · Lesson 2
The Claude Agent SDK
How query() drives Claude Code's agent loop from your own TypeScript, and how custom tools, permissions, hooks, sessions and structured output work, with the Claude Code equivalent of each.
By the end of this lesson you can
- Explain what query() does, which messages it yields, and how a run ends (success, turn limit, budget limit)
- Implement a custom tool with tool() and createSdkMcpServer(), and predict its model-facing name
- Trace a tool call through the six-step permission evaluation order and predict whether it runs, is denied or reaches canUseTool
- Use PreToolUse and PostToolUse hooks to enforce a write boundary and keep an audit trail
- Map every SDK option used in this lesson to its Claude Code equivalent so you can prototype on a subscription