Credentials. The agent needs provider API keys and, with Coder, can read files and run shell commands in its workspace; keep it in a project folder you can reset.
Who it is forAn engineer who wants a coding agent they fully control, with their choice of models.
The problemOff-the-shelf coding agents are hard to customise and tie you to one vendor.
The outcomeA chat-in-the-terminal coding agent built from composable capabilities you can swap or extend.
What you need first
- Python and uv
- An API key for the model provider you choose
- Optional extras: pydantic-ai-harness[coder], pydantic-ai[temporal] and a Temporal setup, pydantic-ai[openai-realtime]
- Optional: a Logfire account for tracing
Steps
- Install with
uv add pydantic-ai "pydantic-ai-harness[coder]" - Create an Agent with capabilities Coder(), and optionally WebSearch() and an Advisor on a second model, as in the README
- Call agent.to_cli_sync() and run the file to chat with it
- Or try it without code using the README's uvx command that runs the exported coder_agent with clai
- Replace Coder() with its building blocks such as FileSystem, Shell and RepoContext to customise it
Prompt for your agent
Using pydantic/pydantic-ai and pydantic-ai-harness[coder], create a terminal coding agent on <model> with Coder() and WebSearch(), restrict the shell to an allowlist, and run it on this repo to <task>.
Caveat. The README's example model names may not match what your provider offers; use a model string your account supports.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for pydantic/pydantic-ai and "Build your own terminal coding agent in a few lines"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer