Example code

Claude Agent SDK examples

Every script and captured output quoted in the tutorial. Open a file to read it highlighted, or download everything.

Download all examples (zip)

Run a demo

pip install claude-agent-sdk pydantic
export ANTHROPIC_API_KEY=sk-ant-...
cd examples/python && python3 01_hello.py

On first run demo_util.py copies sample-project to examples/project, the working copy the demos change. Delete it to start fresh.

NameWhat it showsUsed inSize
outputs/The captured output of every run quoted in the tutorial33 files
python/Python demos: one SDK feature or pattern per script33 files
sample-project/The tiny project every demo runs against5 files
typescript/The TypeScript agent and its package manifest2 files