Tutorials · Claude Agent SDK · examples / python / 01_hello.pyExample code

Example code · python

01_hello.py

The simplest possible agent. One query(), read-only tools, print every message.

Raw fileDownload all examples (zip)See its output →

Used in Part 1 §4 · Your first agent

"""01: The simplest possible agent. One query(), read-only tools, print every message."""

import asyncio

from claude_agent_sdk import ClaudeAgentOptions, query
from demo_util import PROJECT, show


async def main():
    options = ClaudeAgentOptions(
        cwd=PROJECT,
        allowed_tools=["Read", "Glob", "Grep"],
        max_turns=5,
    )
    async for message in query(
        prompt="What does this project do? Answer in two sentences.",
        options=options,
    ):
        show(message)


asyncio.run(main())

23 lines · Back to the folder