What you’ll learn
- How the Claude Agent SDK works and when to use it
- Core primitives: agents, tools, MCP servers, skills, and permissions
- How to build a task automation agent on Replit using Integrations
- How to publish your agent on a schedule with Scheduled Deployments
Prerequisites
- A Replit account (Core or Teams plan recommended for Deployments)
- An Anthropic API key
- A Todoist account (or another service you want to automate)
How the Claude Agent SDK works
An agent is a loop: you send a prompt, the agent picks tools to execute, observes the results, and repeats until the task is complete. You provide the prompt. The SDK handles the loop. But the SDK goes further. It lets you build multi-agent architectures where an orchestrator agent delegates tasks to specialized sub-agents, each with their own tools and context windows.Core primitives
| Primitive | What it does |
|---|---|
| Query loop | The foundation: prompt, pick tools, execute, observe, repeat |
| Agents | Specialized configurations with their own tools and instructions |
| Tools | Actions agents can take—run commands, call APIs, edit files |
| MCP servers | External processes that expose collections of tools (context-heavy, loaded upfront) |
| Skills | Markdown instruction files that teach agents how to do things (context-efficient, loaded on demand) |
| Permissions | Granular controls over what each agent can access and execute |
Skills vs. MCP servers
These are the two main ways to extend your agents: Skills are markdown files with instructions your agent follows. Only a brief description loads until invoked, keeping the context window lean. Use skills for:- Workflows and conventions (“how to deploy,” “code review checklist”)
- Reference materials (API patterns, style guides)
- Reusable prompts triggered by name
- Connecting to external services (Notion, Linear, databases)
- Actions that need API access (create tasks, query data)
- Tools that do things, not just instruct
Skills define how your agent should work. MCP servers define what your agent can access. Both work for coding agents (like Replit Agent) and agents you build with the SDK.
When to use the SDK vs. the API
| Use case | Choose |
|---|---|
| Automating multi-step tasks | Claude Agent SDK |
| Multi-agent workflows | Claude Agent SDK |
| Simple chat apps | Anthropic API |
| Single-turn tasks | Anthropic API |
Build a Todoist organizer agent
This walkthrough uses a Replit template that scaffolds a Claude Agent SDK project with the right structure—agents, tools, MCP servers, skills, and permissions directories already in place.Step 1: Remix the template
Open the template
Open the Claude Agent SDK template on Replit and select Remix to create your own copy.
Review the project structure
Once the environment loads, open the file sidebar. Toggle Show Hidden Files if needed to see the full structure:
.agents/skills/— Skills that teach Replit Agent how to build Claude Agent SDK appssrc/agents/— Agent definitionssrc/mcpServers/— MCP server configurationssrc/permissions/— Permission definitionssrc/skills/— Skills for your agents (markdown files)src/tools/— Custom tool definitions
Step 2: Connect Todoist via Replit Integrations
Before prompting Agent, connect the service your agent needs to interact with.- Go to replit.com/integrations in your Replit account.
- Find Todoist and connect your account.
- Authorize Replit to access your Todoist data.
Replit Integrations handle OAuth and authentication for you. Your agent can access the Todoist API without managing tokens directly. This is simpler than configuring a separate MCP server that requires its own OAuth flow.
Step 3: Prompt Agent to build your agent
Switch Replit Agent into Plan Mode for best results—it reviews the plan before building, giving you a chance to verify the approach.The final two paragraphs of this prompt were added after debugging. Being specific about how to authenticate (Replit Integrations, not MCP OAuth) and what the end state should look like (inbox completely cleared) saves iteration time.
Step 4: Review the plan and build
When Agent presents its plan, verify it includes:- Custom tools for the Todoist API (not the Todoist MCP server)
- An organizer agent that fetches tasks, labels, and projects
- Proper permissions scoped to the tools your agent needs
- An entry point that triggers the workflow
Step 5: Add your Anthropic API key
The Claude Agent SDK requires an Anthropic API key to call Claude.- Open the Secrets pane in your Replit Workspace.
- Add a secret named
ANTHROPIC_API_KEYwith your API key value.
If you’ve saved your Anthropic API key in your Replit Account Vault, it’s automatically available across all your projects.
Step 6: Test and debug
Run the agent and verify it processes your Todoist inbox correctly. Common issues to watch for:- “Inbox is empty” when it’s not — The API response format for detecting inbox tasks may need adjustment. Check that the agent filters tasks by the inbox project, not a different property.
- Tasks get labels but don’t move to projects — Be explicit in your prompt that the agent should fetch available projects and assign each task to one.
- Authentication errors — Verify the Todoist integration is connected in Replit Integrations and that your agent code uses it (not a separate OAuth flow).
Publish your agent
Once your agent works correctly, publish it to run automatically.Choose Scheduled Deployment
Select Scheduled Deployment for time-based automation. Enter your desired schedule (e.g., “Every day at 5pm PST”).
Verify configuration
Confirm the run command points to your main entry point file and that your
ANTHROPIC_API_KEY secret is included in the deployment secrets.Extend your agent
Once the basics work, you can build more sophisticated agents on Replit:- Add persistent memory — Use Replit Database to store state between runs
- Store files — Use App Storage for file-based data
- Connect more services — Add more Integrations (Slack, Linear, GitHub, Notion) for multi-service workflows
- Use skills — Add markdown skill files to give your agents specialized knowledge and instructions
Next steps
- Explore the Claude Agent SDK documentation for the full API reference
- Learn about Agents & Automations for building chatbots and event-driven workflows on Replit
- Read about Scheduled Deployments and Reserved VM Deployments for deployment options
- Check out the Claude Agent SDK template to start building