TLDR00 / 09

The Claude Agent SDK is Claude Code packaged as a library, so you can build marketing agents that research, draft, and prepare work in your own code. This guide explains what it is, how it compares to the API and to managed agents, the building blocks that matter for marketing, five agents worth building first, and how to wire one up. It closes with guardrails, cost, and the honest limits, drawn from running the same pattern across a live marketing system.

01What is the Claude Agent SDK?

The Claude Agent SDK is a library that gives your own code the same agent loop, built-in tools, and context management that power Claude Code. You write a prompt and a short list of allowed tools, and the model reads files, searches the web, runs commands, and edits work on its own. It runs in Python and TypeScript.

Anthropic first shipped it as the Claude Code SDK and renamed it the Claude Agent SDK in 2025, as teams put it to work well beyond coding. Installing it takes one line: npm install @anthropic-ai/claude-agent-sdk for Node, or pip install claude-agent-sdk for Python 3.10 or later, and the docs walk through the first run (Agent SDK overview). The TypeScript package ships a native Claude Code binary, so you do not install Claude Code separately.

The agent runs inside your own process, on your files and your services, and you decide what it may touch. Out of the box it can use built-in tools like Read, Write, Edit, Bash, Glob, Grep, WebSearch, and WebFetch, so it starts working without you writing any tool-handling code.

The difference that matters for marketing is plain. A chatbot answers a prompt. An agent does the work. Ask the SDK to find your three closest competitors’ new pricing pages and summarise what changed, and it runs the search, fetches the pages, reads them, and returns the summary. You never write the glue in between, and the same job that took an analyst a morning now returns a draft in minutes.

02Why marketing teams should care now

Marketing teams should care because adoption stopped being the advantage. Generative AI reached 53% adoption in three years, faster than the PC or the internet, and AI agents now complete 66% of real computer tasks, up from 12% a year earlier, by Stanford’s 2026 AI Index (Stanford HAI, 2026). Using AI is now table stakes; the edge has moved to agents that own a workflow.

Marketers feel the shift. In HubSpot’s 2026 report, 61% call AI the biggest disruption to marketing in 20 years, and 80% already use it for content (HubSpot, 2026). Microsoft’s 2026 Work Trend Index frames it plainly: as agents take on execution, people gain room to direct the work and own the outcome (Microsoft, 2026). That is the operator model, and an agent is what makes it affordable.

Most marketing stacks are a pile of parts, tools that each do one thing and none of which connect. A marketing agent is the connective layer: it reads from one system, acts in another, and checks its own output against your rules before a person looks. One operator can run a weekly competitor brief, a repurposing pass, and a first-draft queue on a budget that is not growing.

0102030405060708090
R·01
53%generative AI adoption in three years, faster than the PC or the internet

The fastest technology uptake on record. Using AI is table stakes now.

GEN-AI ADOPTIONFASTER THAN PC OR INTERNET
R·02
66%of real computer tasks now completed by AI agents, up from 12%

Agents crossed from demo to useful in a year. They can own real work now.

AGENT TASK SUCCESSUP FROM 12%
R·03
61%of marketers call AI the biggest disruption to marketing in 20 years

Budgets are not growing while the mandate does. More headcount is rarely the answer on offer.

MARKETERS ON AIBIGGEST SHIFT IN 20 YEARS
SOURCE · STANFORD HAI 2026 · HUBSPOT 2026

Adoption is universal and agents now do real work. Now wire them into how you operate.

Stanford HAI and HubSpot, 2026. Adoption is universal and agents now do real work; few have rewired around them.

03Agent SDK vs the API, the CLI, and managed agents

Use the Agent SDK when you want Claude to run the tool loop inside your own application. Use the Anthropic API, the Client SDK, when you want to handle tools yourself. Use the Claude Code CLI for interactive and one-off work. Use Managed Agents when you want Anthropic to host the agent and its sandbox for you.

Option

What it is

Who runs the tool loop

Best for

Anthropic API (Client SDK)

Direct model access

You write it

Full control, custom loops

Claude Code CLI

The terminal app

Claude, interactively

Daily work, one-off tasks

Claude Agent SDK

Claude Code as a library

Claude, in your process

Production apps, automation

Managed Agents

A hosted agent API

Anthropic, in a sandbox

Production without running infrastructure

For marketing work the choice usually comes down to three questions. If the job runs on your own servers and touches your CMS and data, start with the Agent SDK. If you want a long-running production agent without operating any infrastructure, look at Managed Agents. If you are exploring an idea by hand, the CLI is the fastest path.

A common route is to prototype with the SDK, prove the workflow, then move long-running jobs to Managed Agents once they earn the move (Managed Agents overview). The two share the same model and tools, so the work translates across without a rewrite.

Anthropic API (Client SDK)
Claude Agent SDK
The tool loopYou write the loop that calls tools and feeds results back
The tool loopClaude runs the loop and calls tools on its ownFewer moving parts to maintain as the workflow grows.
Built-in toolsYou implement file, web, and shell access
Built-in toolsRead, Write, Bash, and WebSearch ship in the boxThe agent can research and draft on day one.
Context windowYou manage history and truncation by hand
Context windowContext management is handled for youLong campaigns stay coherent without manual bookkeeping.
fig.02 / what changes
The Client SDK leaves the loop to you; the Agent SDK runs it and brings the tools.

04The building blocks that matter for marketing

Six building blocks turn the Agent SDK into a marketing system: built-in tools, the Model Context Protocol, subagents, hooks, permissions, and sessions. Each maps to a job a marketing team already knows. Together they let one operator run work that used to need a small team.

  • Built-in tools. Read, Write, Edit, Bash, WebSearch, and WebFetch mean an agent can research a topic and draft against it without you writing any tool code.

  • Model Context Protocol (MCP). MCP servers connect the agent to your CMS, analytics, CRM, ad platforms, and databases (modelcontextprotocol.io), so it reads and acts across the stack instead of working blind.

  • Subagents. Define a researcher, a writer, and a fact-checker, each with its own instructions and tools, and the main agent delegates to them the way a lead delegates to a team.

  • Hooks. A PreToolUse or PostToolUse callback runs your own code to validate, log, or block an action before it ships. This is where a brand-voice rule becomes enforcement.

  • Permissions. Pre-approve safe tools and gate the rest. A research agent gets read-only access; a publishing agent needs sign-off before anything goes live.

  • Sessions. Context persists across exchanges, so you can resume a campaign mid-flight or fork it to test two angles from the same starting point.

One block sits under all of them: the context layer. The SDK loads your .claude files and CLAUDE.md, so your voice rules, ICP, and positioning travel with every run. This layer earns its place before any automation, because it is what keeps the output on brand.

6 BUILDING BLOCKS · 1 SYSTEM
01Built-in toolsRead, Write, Bash, WebSearch, and more. The agent researches and drafts out of the box.
02MCPConnect your martech: CMS, analytics, CRM, ad platforms, and databases through one interface.
03SubagentsSpecialist roles. A researcher, a writer, and a fact-checker the main agent delegates to.
04HooksBrand-safety callbacks that validate, log, or block an action before it ships.
05PermissionsDecide which tools an agent may touch. Research stays read-only; publishing needs approval.
06SessionsPersistent context. Resume a campaign mid-flight, or fork it to try two angles.
CONTEXT LAYERThe SDK loads your .claude files and CLAUDE.md, so voice, ICP, and positioning ride along on every run.
Each block maps to a marketing job. The context layer underneath keeps every run on brand.

05Five marketing agents worth building first

Five agents are worth building before anything ambitious: a competitor monitor, a content repurposer, an SEO brief writer, an ad-copy variator, and an inbox triage agent. Each owns one job, uses read-mostly tools, and ends in a draft. Start where the manual work is dullest and most repeatable, because that is where an agent pays back fastest.

  1. Competitor monitor. Watches rival pricing, launches, and messaging on a weekly cadence, and files a change brief.

  2. Content repurposer. Turns one long piece into a set of derivatives, a summary, a thread outline, and a newsletter draft.

  3. SEO brief writer. Researches a query, reads the ranking pages, and drafts a structured outline with sources attached.

  4. Ad-copy variator. Generates on-brand headline and description variants for testing, within your voice rules.

  5. Inbox triage agent. Reads inbound notes, tags them by intent, and drafts a first reply for a person to send.

How far you push each agent is a choice, and the maturity ladder below is the safe order. Begin at drafts, where the agent proposes and a person disposes. Add multi-step chains and a schedule once a guardrail is proven. Reserve multi-agent setups, where subagents split research, writing, and review, for workflows you already trust. Earn each rung before you climb to the next.

How far to push a marketing agent

fig.03 / agent autonomy
L1
Read-onlyResearches and summarises. No writes. The safest first agent to run.
L2
DraftsProduces drafts a person reviews and ships. Where most teams should start.
L3
Multi-stepChains research, draft, and self-check across tools through MCP.
L4
ScheduledRuns on a cadence: a weekly competitor scan, a daily brief.
L5
Multi-agentSubagents split research, writing, and review. One operator governs.
NoteStart at L2. Earn each rung with a working guardrail before you climb to the next.
Start at drafts. Climb a rung only after a working guardrail proves the last one.

06Build your first marketing agent

Start with one job an agent can own: a weekly competitor scan. In about fifteen lines you give it a prompt, the web tools, and an MCP server for your CMS. It searches, reads the pages, writes a brief, and saves a draft for you to approve. Here is the shape of that agent in TypeScript.

import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt:
    "Scan our 3 competitors' pricing pages, summarise what " +
    "changed this week, and save the brief to the CMS as a draft.",
  options: {
    allowedTools: ["WebSearch", "WebFetch", "Write"],
    mcpServers: {
      cms: { command: "npx", args: ["-y", "@your/cms-mcp"] },
    },
  },
})) {
  if ("result" in message) console.log(message.result);
}

Four moves do the work. The prompt states the job in plain language. allowedTools pre-approves what the agent may use. The mcpServers entry plugs it into your CMS. Then the agent loop runs until it has a result. Keep the first agent small: one job, read-mostly tools, and a draft as the output.

Iterating is the same loop you already use for content. Read the message stream to see which tools the agent called, tighten the prompt where it wandered, and add a hook when you need a hard rule. Anthropic ships example agents, an email assistant and a research agent, that follow this exact shape and make a good second read (example agents on GitHub). A content repurposer is the natural next build: same structure, a different prompt and a different MCP server.

A marketing agent, end to end

fig.04 / one run
01PromptGive the agent one job in plain language: scan competitors and draft a brief.
02Tools + MCPIt searches the web and reads your CMS through an MCP server.
03Agent loopClaude calls tools, reads results, and continues until the job is done.
04Draft for reviewThe output lands as a draft. A person approves before anything ships.
~15 lines of coderead-mostly toolshuman approval at the end
One job, read-mostly tools, and a human approval step at the end of every run.

07How I run my own marketing engines on this pattern

This article was produced by agents of exactly this shape. My marketing system runs as a set of engines, and each one is an agent that reads a shared context layer, calls tools to research and draft, checks its own output against rules, then hands a draft to me to approve. The Claude Agent SDK is that same loop, packaged for your team to build with.

Three content engines did the work here. A Create-Articles engine researched the sources and drafted this piece as structured, answer-first content. A Create-Images engine built the figures as typed components, holding to one visual register so the page reads as one design. A Create-Compiler engine then validated every field, every source, and every voice rule, and would have blocked publishing on a single failure. All three read one context layer, the voice rules, ICP, and positioning, so the output sounds like the brand and not like a generic model.

This is the operator model in practice. The human sets the strategy and the bar. The agents do the work. A validation step prices the evidence behind every claim, so a number without a source does not ship. Nothing here published itself. Each run ended at a draft I reviewed, which is the same gate I would put on any agent that touches a public channel.

The engines that produced this articleOne context layer · three content engines · a human at the end
−1ContextThe shared brain. Voice, ICP, positioning, and the rules every engine runs under.law layer
01Create-ArticlesResearches sources and drafts the piece as structured, answer-first content.built
02Create-ImagesBuilds the figures as typed components. One visual register per piece.built
03Create-CompilerValidates every field, source, and voice rule. Blocks publish on a failure.built
04PublishWrites a draft to the CMS. A human reviews and decides whether to ship.built
Each engine is one agent. One context layer underneath. A human at the approval step.draft, then decide
The real engines behind this piece. One context layer, three content engines, a human at the approval step.

08Guardrails: permissions, hooks, and a human in the loop

Guardrails are not optional for a brand. The Agent SDK gives you three. Permissions decide which tools an agent may use. Hooks run your own code before or after each action. A human approval step gates anything that goes live. Set all three before an agent touches a public channel.

  1. Permissions. Pre-approve safe tools with allowedTools and require approval for the rest. A read-only research agent never receives Write or Bash, so it cannot change or publish anything by accident.

  2. Hooks. A PreToolUse hook can block a publish that fails a brand-voice check. A PostToolUse hook can log every change to an audit file, so you have a record of what the agent did and when. Your rules become enforcement instead of hope.

  3. A human in the loop. End every run at a draft. The model proposes, a person disposes, and the brand keeps a clear owner for what ships.

These are the same controls that make agentic marketing safe to run at scale. For the wider view on oversight, hallucinations, and bias, the case for guardrails in agentic marketing sits alongside this guide.

09Cost, authentication, and getting started

Getting started takes three steps: install the SDK, set an API key from the Claude Console, and run a small agent (Quickstart). You pay per token through the API, so a read-only research agent costs little and a multi-agent system costs more. Match an agent’s ambition to the value it earns.

Install is npm install @anthropic-ai/claude-agent-sdk, then export ANTHROPIC_API_KEY from the Console. For enterprise setups, the SDK also runs on Amazon Bedrock, Google Vertex AI, and Microsoft Azure, so it fits the cloud you already buy. One rule to plan around: Anthropic does not allow consumer claude.ai logins to power products built on the SDK, so budget for API-key billing from the start.

On cost, the levers are simple. Read-mostly agents and tight prompts keep token use low. Long, chatty runs and large context windows cost more, so watch the message stream on early builds and trim what the agent does not need. Prototyping a single agent is cheap enough to test on a real workflow this week.

Some work does not need an agent. A single summary or a one-time rewrite is faster as an API call or a CLI prompt. If a workflow has no clear owner for the approval step, build that owner first. Agents multiply whatever process you point them at, so a shaky process returns a faster, shakier result.

Frequently Asked Questions
What is the Claude Agent SDK?
The Claude Agent SDK is a library that lets your own code run AI agents with the same tools, agent loop, and context management as Claude Code. It works in Python and TypeScript, and the agent can read files, search the web, run commands, and edit work on its own.
Is the Claude Agent SDK the same as the Claude Code SDK?
Yes. Anthropic first released it as the Claude Code SDK, then renamed it the Claude Agent SDK in 2025 as teams used it well beyond coding. The package is now @anthropic-ai/claude-agent-sdk in Node and claude-agent-sdk in Python.
What languages does the Claude Agent SDK support?
Two: Python, version 3.10 or later, and TypeScript or JavaScript on Node. The TypeScript package bundles a native Claude Code binary, so you do not install Claude Code separately to use it.
How is the Agent SDK different from the Anthropic API?
The Anthropic API, also called the Client SDK, gives you direct model access and leaves you to write the tool-handling loop. The Agent SDK runs that loop for you, so Claude calls tools, reads the results, and keeps going until the job is done.
Can the Claude Agent SDK connect to my marketing tools?
Yes, through the Model Context Protocol. MCP servers connect the agent to systems like your CMS, analytics, CRM, ad platforms, and databases, so it can read and act across your stack rather than work in isolation.
Do I need Claude Code installed to use the SDK?
No. The TypeScript package ships its own Claude Code binary as a dependency. You install the SDK, set an API key, and run your agent. The Python package connects to the same engine.
How do I authenticate, and can I use my claude.ai login?
Use an API key from the Claude Console. The SDK also supports Amazon Bedrock, Google Vertex AI, and Microsoft Azure. Anthropic does not permit consumer claude.ai logins to power products built on the SDK, so plan for API-key billing.
Is the Claude Agent SDK ready for production marketing work?
Yes, with guardrails. Run it in your own infrastructure, gate anything public behind a human approval step, and move long-running jobs to Managed Agents when you want Anthropic to host the agent and its sandbox.
Built by AI Marketing Operator · Published
Create-Articles v8.0.1 · Create-Images v4.5.0 · Create-Compiler v2.0.1
###