Building an AI Agent That Reads Files and Runs Commands: What the Agent SDK Hands You

hero

"I want a program that finds and fixes bugs in our code — do I have to build file reading and command execution myself?" That's where many newcomers stall. Anthropic's Agent SDK is a library that hands you those parts already built.

What it does for you

The docs describe it as using Claude Code as a library: the same tools, agent loop, and context management, programmable in Python and TypeScript. The key point is that built-in tools for reading files, running commands, and editing code mean your agent starts working without you implementing tool execution.

async for message in query(
    prompt="Find and fix the bug in auth.py",
    options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]),
):
    print(message)

Built-in tools include Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch, and AskUserQuestion. A trap for beginners: if you only want to summarize TODOs, allow just ["Read", "Glob", "Grep"] — adding Edit or Bash lets the agent touch files you didn't mean to.

Install snag and when to skip

The Python package needs 3.10+; a No matching distribution found error usually means your interpreter is older. Check with python3 --version. Use the API key method — the docs state claude.ai login isn't allowed for third-party agents without approval.

Skip the SDK when your task is a single text summary or classification with no tools or loops — a plain API call is lighter. Verify the official docs.

Decision to start with: does my task involve reading files or running commands? If yes, allow only the tools you need and run the quickstart.


🐦 Faster updates on X: @baegseungh7061
📚 More in this series: Code Practical
💌 Subscribe: Follow on X or grab the RSS

댓글