Setup
This guide assumes you are working with an existing Trigger.dev project.
Follow our quickstart to get set up if you don’t have a project yet.
1
Install the Claude Agent SDK
npm
2
Configure trigger.config.ts
Add the SDK to the
external array so it’s not bundled:trigger.config.ts
Adding packages to
external prevents them from being bundled, which is necessary for the Claude
Agent SDK. See the build configuration docs for more details.3
Set your API key
Add your Anthropic API key to your environment variables. The SDK reads it automatically.You can set this in the Trigger.dev dashboard under Environment Variables, or in your
.env file for local development.4
Create your first agent task
This example creates a task where Claude generates code in an empty workspace. The agent will create files based on your prompt:
trigger/claude-agent.ts
5
Run the dev server
6
Test your agent
Go to the Trigger.dev dashboard, find your
code-generator task, and trigger it with a test payload:How it works
Thequery() function runs Claude in an agentic loop where it can:
- Read files - Explore codebases with
Read,Grep, andGlobtools - Edit files - Modify code with
EditandWritetools - Run commands - Execute shell commands with
Bashtool (if enabled) - Think step by step - Use extended thinking for complex problems
maxTurns.
Permission modes
| Mode | What it does |
|---|---|
"default" | Asks for approval on potentially dangerous operations |
"acceptEdits" | Auto-approves file operations, asks for bash/network |
"bypassPermissions" | Skips all safety checks (not recommended) |
Available tools
GitHub repo
View the Claude Agent SDK + Trigger.dev example
A complete example with two agent patterns: basic safe code generation and advanced with bash
execution.
Example projects using the Claude Agent SDK
Claude changelog generator
Generate changelogs from git commits using custom MCP tools.
Claude GitHub wiki agent
Analyze repositories and answer questions with real-time streaming.
Learn more
- Claude Agent SDK docs – Official Anthropic documentation
- Trigger.dev Realtime – Stream agent progress to your frontend
- Waitpoints – Add human-in-the-loop approval steps

