If you have a Claude Code subscription, you already have everything you need to run a personal AI agent 24/7. No API key. No per-token billing. No third-party wrappers. Just the official Agent SDK running through the same CLI authentication you already use.
Most people don't know this. They assume building an AI agent means signing up for API access, estimating token costs, and watching a billing dashboard climb. That used to be true. It's not anymore.
What changed in January 2026
In January 2026, Anthropic revoked OAuth token access for third-party tools. Frameworks like OpenClaw, which had been piggybacking on Claude's web authentication to make API calls, lost their access overnight.
Anyone who had built an agent on those frameworks suddenly needed a separate Anthropic API key. That means per-token billing. Depending on usage, that's $50 to $200+ per month in raw API costs, on top of whatever you're already paying for Claude Code.
But Anthropic didn't just close a door. They opened a better one.
The Claude Code Agent SDK
The Agent SDK is Anthropic's official, supported way to build agents. It ships as part of the @anthropic-ai/claude-code npm package. It gives you the same agent loop, tool system, and context management that power Claude Code itself, packaged as an embeddable SDK you can import into any Node.js project.
The critical detail: it authenticates through your existing Claude Code CLI login. If you can run claude in your terminal, you can run an agent. No API key. No separate billing.
import { claude } from "@anthropic-ai/claude-code";
const response = await claude({
prompt: "Check my server logs for errors in the last hour",
options: {
allowedTools: ["Bash", "Read", "Write", "Edit", "WebSearch"],
maxTurns: 10,
},
});
console.log(response.text);
That's a working agent call. It reads your CLI credentials, spins up a full agent loop with tool access, runs until it finishes or hits the turn limit, and returns the result. No API key anywhere in the code.
What the Agent SDK gives you
This isn't a thin wrapper around a chat completion endpoint. It's the full Claude Code runtime, minus the interactive terminal UI. Here's what you get out of the box:
The agent loop
When you call claude(), it doesn't just send a prompt and return a response. It enters a loop. The model reads your prompt, decides what to do, calls a tool, reads the result, decides if it needs to do more, and keeps going until the task is done or it hits maxTurns.
This is what separates an agent from a chatbot. A chatbot generates text. An agent acts. It runs shell commands, reads files, searches the web, writes code, and chains those actions together to complete multi-step tasks.
// The agent loop, conceptually:
while (turnsRemaining > 0) {
const action = model.decide(prompt, toolResults);
if (action.type === "text") {
return action.text; // Done - return response
}
if (action.type === "tool_call") {
const result = await executeTool(action.tool, action.input);
toolResults.push(result);
turnsRemaining--;
}
}
Session resumption
Every claude() call can return a sessionId. Pass that ID back on the next call and the conversation continues with full context. The model remembers everything from the previous interaction -- what files it read, what commands it ran, what decisions it made.
// First call - start a new session
const first = await claude({
prompt: "Read my project structure and summarize it",
options: { allowedTools: ["Bash", "Read"] },
});
const sessionId = first.sessionId;
// Later call - resume the same session
const second = await claude({
prompt: "Now set up the database schema we discussed",
options: {
allowedTools: ["Bash", "Read", "Write", "Edit"],
resumeSessionId: sessionId,
},
});
Sessions are stored as JSONL files on disk. They survive process restarts, machine reboots, and crashes. Your agent can pick up exactly where it left off. This is what makes it possible to run a persistent agent that maintains context over days and weeks, not just within a single conversation.
MCP servers
The Model Context Protocol (MCP) is how you give your agent access to external services. Gmail, Google Calendar, Slack, databases, custom APIs -- anything with an MCP server becomes a tool the agent can call.
const response = await claude({
prompt: "Check my email for anything urgent and add follow-ups to my calendar",
options: {
allowedTools: ["Bash", "Read", "mcp__gmail__*", "mcp__google_calendar__*"],
mcpServers: {
gmail: {
command: "npx",
args: ["@anthropic-ai/mcp-gmail"],
},
google_calendar: {
command: "npx",
args: ["@anthropic-ai/mcp-google-calendar"],
},
},
},
});
The agent doesn't just read your email. It reads it, decides what's urgent, composes follow-up actions, and creates calendar events. All in one call. All through your existing subscription.
The cost comparison
This is the part that matters most. Let's put real numbers on it.
The Agent SDK runs through your Claude Code subscription's usage allocation. You're paying for Claude Code already. The agent uses the same pool. There's no separate meter, no surprise bills, no token-counting anxiety.
For most personal agent use cases -- checking email, managing tasks, running scripts, answering questions, light automation -- the standard Claude Code subscription handles it fine. You're using the same tokens you'd burn in interactive Claude Code sessions, just programmatically.
What you're actually building
An agent built on the SDK is a Node.js process that listens for input, runs the agent loop, and returns output. The input can come from anywhere: a Telegram bot, a web dashboard, a cron job, a webhook, a CLI prompt. The architecture looks like this:
The agent core is the same regardless of input source. A Telegram message and a cron job both call the same claude() function. The difference is just where the prompt comes from and where the response goes.
Add a memory layer (SQLite with full-text search works well) and your agent remembers past conversations, user preferences, project context, and decisions. Add a scheduler and it runs tasks autonomously on a cron schedule. Add voice transcription and it processes voice memos.
The point is: the Agent SDK handles the hard part (the AI reasoning and tool execution). You handle the glue (input/output routing, memory, scheduling). The glue is straightforward engineering. The hard part is free.
What this replaces
Before the Agent SDK, building something like this required:
- An API key with per-token billing and rate limits
- A framework like LangChain, AutoGPT, or OpenClaw to manage the agent loop
- Custom tool implementations for bash, file system, and web access
- Prompt engineering to make the model use tools correctly
- Session management built from scratch
- Error handling for API failures, rate limits, and malformed responses
The Agent SDK eliminates all of that. The agent loop is battle-tested (it's the same one that runs Claude Code). The tools are built in. Session management works out of the box. Error recovery is handled. And authentication is your existing CLI login.
You're not building an agent framework. You're building your agent, on top of one that already works.
The catch (and why it's not really a catch)
The Agent SDK uses your Claude Code subscription's usage. That means it shares the same rate limits and usage caps as your interactive Claude Code sessions. If you're running an agent that makes hundreds of calls per hour, you'll hit limits.
For a personal agent -- handling messages, running occasional tasks, checking email, managing your schedule -- this is a non-issue. You're not building a production SaaS. You're building a personal assistant that does maybe 20-50 agent calls a day. That fits comfortably within normal usage.
If you need high-volume, production-scale agent calls, you should be on the API anyway. But for 95% of personal agent use cases, the subscription is more than enough.
Getting started
The minimal setup:
- Have a Claude Code subscription and be logged in (
claudeworks in your terminal) - Install the SDK:
npm install @anthropic-ai/claude-code - Write a script that calls
claude()with a prompt and tools - Run it
That's a working agent. Four steps. From there, you layer on the parts that make it useful: a Telegram bot for mobile access, a memory system for context persistence, a scheduler for autonomous tasks, MCP servers for external service access.
// minimal-agent.ts
import { claude } from "@anthropic-ai/claude-code";
async function main() {
const result = await claude({
prompt: process.argv[2] || "What time is it?",
options: {
allowedTools: ["Bash", "Read", "WebSearch"],
maxTurns: 5,
},
});
console.log(result.text);
}
main();
$ npx tsx minimal-agent.ts "Find the largest files in my home directory"
That's a real agent. It will run du or find commands, sort the results, and give you a summary. It's using bash tools through the agent loop, reasoning about what commands to run, and chaining them together. All through your existing subscription.
What the AI Agent Blueprint covers
The minimal agent above is functional but bare. It has no memory, no persistent sessions, no way to reach it from your phone, and no scheduling. It forgets everything between runs.
The AI Agent Blueprint is a 30-page guide and complete boilerplate repo that takes you from that minimal script to a production-ready personal agent:
- Telegram integration -- message your agent from your phone, including voice and photos
- Web dashboard -- browser-based interface for longer sessions
- Dual-sector memory -- semantic (permanent) and episodic (decaying) memories with full-text search
- Session management -- conversations persist across restarts with automatic crash recovery
- Task scheduling -- cron-based autonomous tasks (daily briefings, monitoring, reports)
- Voice processing -- local speech-to-text with whisper-cpp
- MCP server setup -- Gmail, Google Calendar, and custom tool integration
- launchd service -- runs as a system service, starts on boot, restarts on crash
13 files. ~3,500 lines of TypeScript. Everything is documented, every design decision is explained, and it runs on your existing Claude Code subscription with zero additional API costs.
Build your own AI agent for $0 extra
30-page PDF guide + complete TypeScript boilerplate. Uses your existing Claude Code subscription. No API key needed.
Get the Blueprint - $47