How to Set Up Your AI Marketing Agent with Claude Code [2026]
Adspirer Team
This is the hands-on setup guide for building your AI marketing agent with Claude Code CLI. You’ll install the Adspirer plugin (one command), create your brand workspace (CLAUDE.md + STRATEGY.md + MEMORY.md), understand the 5 slash commands, configure sub-agents with persistent memory, and run your first cross-platform performance review. By the end, your agent will be running — with web research capabilities and compounding memory that no other AI advertising tool offers.
In Part 1, we covered why an AI marketing agent is different from an AI assistant — persistent brand knowledge, strategy memory, specialized skills, and the compounding knowledge effect. Now we build one with Claude Code.
If you’ve read the Codex setup guide, you’ll notice the same pattern here — install, authenticate, build brand workspace, run first workflow. But Claude Code brings a fundamentally different architecture. Where Codex runs agents autonomously on a schedule, Claude Code runs them interactively as sub-agents — specialized AI instances that spawn in their own context window, carry their own persistent memory, and can research the web before making recommendations.
That last point matters more than it sounds. When your agent can crawl competitor landing pages, research industry benchmarks, and pull market intelligence — all within the same workflow that analyzes your ad data — the quality of recommendations changes fundamentally. You’re not just analyzing numbers. You’re analyzing numbers in context.
The setup takes about 10 minutes. Most of that time is the brand workspace creation, where the agent scans your docs and pulls live data from your ad accounts. The plugin install itself is one command.
This is Part 2 of a 3-part series.
- Part 1: How to Build an AI Marketing Agent for Paid Media
- Part 2 (this post): Setting up your agent with Claude Code CLI
- Part 3: How to Run Facebook & Instagram Ads with Your Claude Code AI Agent
Prerequisites
Before you start, make sure you have:
- Claude Code CLI installed (installation guide)
- Node.js 18+ (for the MCP server runtime)
- An Adspirer account (free to start)
- At least one ad platform account: Google Ads, Meta Ads, LinkedIn Ads, or TikTok Ads
- A Claude Max, Team, or Enterprise subscription (Claude Code requires an Anthropic paid plan)
Don’t have Claude Code yet? Install it with npm i -g @anthropic-ai/claude-code. It runs locally on macOS and Linux (Windows via WSL). See the Claude Code documentation for details.
Step 1: Install the Adspirer Claude Code Plugin
The fastest way to get started is through Claude Code’s built-in plugin system. Type this directly into the Claude Code input:
/plugin install adspirer-ads-agentOr browse for it — type /plugin, switch to the Discover tab, and search for “Ads.” You’ll see adspirer-ads-agent from claude-plugins-official with 899+ installs.
This single command installs everything you need to manage ads from Claude Code:
| Component | Location | Purpose |
|---|---|---|
| MCP Server | Plugin config | Connects Claude Code to Adspirer’s 100+ advertising tools via OAuth |
| Sub-Agent | ~/.claude/agents/performance-marketing-agent.md | Defines the marketing agent’s behavior, brand awareness, and workflows |
| Skill | ~/.claude/skills/ad-campaign-management/SKILL.md | One comprehensive skill covering all 4 ad platforms |
| 5 Slash Commands | ~/.claude/commands/*.md | Quick-access commands for common advertising workflows |
After installing, run /reload-plugins to activate the plugin and load the MCP server.
Important: The /plugin and /reload-plugins commands are slash commands you type directly into Claude Code’s input bar — not terminal commands, and not prompts for the AI. If you ask the AI to run them, you’ll get a “nested session” error. Type them yourself in the input bar.
Step 2: Authenticate with Your Ad Accounts
After installing the plugin, you need to connect your Adspirer account. Open the MCP settings by typing:
/mcpFind plugin:adspirer-ads-agent:adspirer MCP Server in the list and select Authenticate. A browser window opens where you sign in to your Adspirer account (or create one free) and connect your ad platforms — Google Ads, Meta Ads, LinkedIn Ads, and/or TikTok Ads.
The connection uses OAuth 2.1 with PKCE. Your ad account credentials are never stored on your machine — Adspirer handles all platform authentication server-side. You can revoke access anytime from your Adspirer dashboard. See the security documentation for the full security model.
After authenticating, run /mcp again to verify. The Adspirer server should show as connected with your available tools listed.
Step 3: Create Your Brand Workspace
This is where the agent becomes yours. Navigate to your brand’s project folder and launch Claude Code:
cd ~/Clients/YourBrand # or wherever your brand docs liveclaudeThen invoke the setup command:
/adspirer:setupWhat Happens During Setup
The setup command runs a comprehensive bootstrap process that transforms Claude Code from a generic AI assistant into a brand-specific marketing agent. Here’s each phase of what happens behind the scenes:
Scans Your Local Files
The agent looks for brand documents in your folder — .md, .txt, .csv, .yaml, .json, .pdf files. Brand guidelines, media plans, competitor analyses, audience research — anything it finds gets absorbed into the brand context. Tip: Drop your brand docs into the folder before running setup. The more context you provide, the better the agent performs.
Connects to Your Ad Accounts
Calls Adspirer’s get_connections_status tool to verify which ad platforms are connected and pulls account-level metadata — account names, IDs, active campaign counts, and platform statuses.
Pulls Live Performance Data
Pulls the last 30 days of campaign performance across all connected platforms. This becomes the baseline the agent uses for future comparisons, anomaly detection, and KPI target-setting.
Creates CLAUDE.md
Builds the brand context file — your brand overview, target audiences, brand voice guidelines, connected platforms, budget guardrails, KPI targets, performance snapshot, and key findings. This is the file that makes the agent brand-aware. Unlike Codex’s AGENTS.md, Claude Code reads CLAUDE.md automatically at the start of every session — it’s baked into the platform, no extra configuration needed.
Creates STRATEGY.md
Initializes the strategy playbook for strategic directives that persist across sessions. Starts empty, but fills up as you analyze campaigns and confirm findings. Contains AVOID/PREFER/CONSTRAINT rules per platform — for example, “AVOID broad match keywords on brand campaigns” or “PREFER video creatives for Meta prospecting.” Directives are only saved after your explicit confirmation.
Initializes MEMORY.md
Sets up the persistent memory index. As you work with the agent across sessions, it automatically saves key decisions, campaign results, optimization outcomes, and your preferences. This is unique to Claude Code — the memory system means your agent gets smarter every time you use it.
What Your Workspace Looks Like After Setup
~/Clients/YourBrand/├── CLAUDE.md # Brand context — auto-read every session├── STRATEGY.md # Strategy directives — persist across sessions├── MEMORY.md # Decision log — auto-updated by the agent├── brand-guidelines.pdf # Your existing docs (if you added any)└── media-plan.xlsx # Your existing docsThe CLAUDE.md file is the agent’s brain. Here’s what a typical one contains after setup:
| Section | Content | Source |
|---|---|---|
| Brand Overview | What you sell, who you sell to, industry | Your docs + Adspirer |
| Brand Voice | Tone, language style, prohibited words | Your brand docs |
| Target Audiences | Audience segments with targeting parameters | Your docs + campaigns |
| Active Platforms | Connected platforms, campaign counts | Adspirer |
| Budget & Guardrails | Monthly budget, CPC caps, CPA targets | Your docs + campaigns |
| KPI Targets | Primary goals and target metrics | Your docs |
| Performance Snapshot | Last 30 days across all platforms | Adspirer |
| Key Findings | Top campaigns, wasted spend, opportunities | Adspirer analysis |
Every time you start a Claude Code session in this folder, CLAUDE.md is loaded automatically. The agent knows your brand without you re-explaining it — whether it’s Monday morning or three months from now.
Step 4: How Claude Code Sub-Agents Power Your Marketing Agent
This is the biggest architectural difference between Claude Code and every other AI tool for advertising. When you ask Claude Code to run a marketing workflow, it doesn’t just execute tools in your main conversation. It spawns a sub-agent — a separate AI instance running in its own isolated context window, with its own memory, its own tool permissions, and its own persistent knowledge.
Why Sub-Agents Matter for Advertising
Advertising workflows are verbose. A cross-platform performance review might pull data from 4 platforms, compare 20 campaigns against KPI targets, analyze keyword performance, check for creative fatigue, and produce a prioritized action list. In a single conversation context, all that data would flood your window and push out the conversation you were having before the review.
Sub-agents solve this cleanly. The marketing agent runs in isolation — it does the heavy lifting in its own context, then returns a structured summary to your main conversation. You keep your full conversation history intact while still getting comprehensive analysis. Think of it as a specialist team member who goes off, does the deep work, and comes back with a clear report.
How the Agent Loop Works
When you invoke a marketing workflow (like /adspirer:performance-review), Claude Code executes this sequence:
Spawns the Sub-Agent
Claude Code creates a new instance using the performance-marketing-agent.md agent definition. This instance gets its own context window — completely separate from your main conversation.
Preloads Context
The sub-agent reads CLAUDE.md (brand knowledge), STRATEGY.md (strategic directives), and MEMORY.md (past decisions and results) before doing anything else. It starts every workflow already knowing your brand.
Loads the Skill
The ad-campaign-management skill provides proven workflows — the correct tool sequence for each task type. This ensures the agent follows research → validate → create → verify patterns instead of guessing.
Executes the Workflow
The agent calls Adspirer tools to pull data, analyzes results against your KPI targets and strategy, and checks for anomalies, wasted spend, and opportunities.
Returns Results
A structured summary is sent back to your main conversation — metrics, findings, and recommended actions, all prioritized.
Updates Memory
Key findings and decisions are saved to MEMORY.md for future sessions. This is how the compounding knowledge effect works.
Web Research: Claude Code’s Unique Advantage
The sub-agent has access to all 100+ Adspirer MCP tools plus WebSearch and WebFetch — meaning it can research competitors, crawl landing pages, check industry benchmarks, and gather market intelligence as part of its analysis workflow. This is something Codex agents cannot do.
When you ask “research my competitors’ Meta Ads strategies and suggest new campaign angles,” the agent doesn’t just look at your data. It searches the web for competitive intelligence, visits competitor landing pages to understand their messaging, and combines that external context with your actual performance data to make informed recommendations.
Sub-agents vs agent teams: Sub-agents report results back to your main conversation. For even more advanced workflows, Claude Code also supports agent teams where multiple agents work in parallel and communicate with each other directly. For example, one agent could audit Google Ads while another audits Meta Ads simultaneously. Agent teams are experimental but powerful for multi-platform operations at scale.
Step 5: The 5 Slash Commands
Your agent has 5 slash commands — each triggers a proven workflow for a specific task type. You don’t need to memorize them; describe what you want naturally and Claude Code matches the right workflow automatically. But knowing the commands helps you work faster when you know exactly what you need.
For the complete command reference with all parameters and workflows, see the skill documentation.
Step 6: Safety Rules and Guardrails
When an AI agent manages ad spend, safety isn’t optional — it’s the foundation everything else is built on. Claude Code enforces safety at multiple levels through the skill workflow, the sub-agent definition, your strategy file, and Claude Code’s built-in permission system.
What’s Protected
| Rule | How It Works |
|---|---|
| Campaigns created PAUSED | All campaign creation defaults to PAUSED status. Nothing goes live without your explicit approval. |
| User confirmation for spend | The agent asks before creating campaigns or changing budgets. Claude Code’s permission system requires you to approve tool calls that affect spend. |
| Read-before-write | Connection check → research → validate → create → verify. The skill enforces this sequence — you can’t skip the research step and jump straight to creation. |
| Budget guardrails | Your CLAUDE.md contains budget caps and CPA targets. The agent checks these before recommending any spend changes. |
| Strategy compliance | Before making recommendations, the agent checks STRATEGY.md for AVOID/PREFER/CONSTRAINT rules. If a recommendation conflicts with your strategy, it flags the conflict explicitly. |
| No automatic retries | If campaign creation fails, the agent reports the error and stops. It doesn’t retry and risk creating duplicate campaigns. |
| Post-creation verification | After creating a campaign, the agent verifies ad groups, keywords, ads, and extensions are properly attached and configured. |
Claude Code’s Permission Modes
Claude Code adds another layer of safety through its built-in approval modes, which control how much autonomy the agent gets:
| Mode | File Access | Tool Calls | Best For |
|---|---|---|---|
| Default | Read only | Approval needed for each | First-time setup, reviewing the system |
| Auto | Read + edit in working dir | Auto-approved in scope | Campaign creation, keyword management |
| Full Access | Read anywhere + network | Auto-approved | Bulk operations across multiple accounts |
For advertising, Auto mode is the sweet spot. Read operations (pulling performance data, analyzing campaigns, checking search terms) run automatically without prompting you. Write operations (creating campaigns, generating ad copy files, changing budgets) prompt you for confirmation. This matches the safety model — the agent handles analysis autonomously but defers to you for every spending decision.
Bottom line: Interactive doesn’t mean uncontrolled. The agent analyzes, recommends, and surfaces insights — but you make the final spending decisions. No campaign goes live, no budget changes, and no targeting modifications happen without your explicit approval. See the capabilities and safety documentation for the full safety model.
Step 7: Your First Performance Review
Let’s run the most valuable workflow — a comprehensive cross-platform performance review that would take 30-60 minutes of dashboard clicking and spreadsheet building if done manually.
Run It
In Claude Code, type:
Or use the slash command directly:
/adspirer:performance-reviewWhat Happens Behind the Scenes
Claude Code spawns the performance marketing sub-agent, which executes this complete workflow:
Reads Brand Context
Loads CLAUDE.md (brand knowledge, KPI targets, budget guardrails), STRATEGY.md (active directives and constraints), and MEMORY.md (past decisions and historical findings).
Checks Connections
Calls get_connections_status to identify which platforms are active and pulls current account-level metadata.
Pulls Performance Data
Calls Adspirer tools in parallel for each connected platform — campaign metrics, ad group breakdowns, keyword performance, search term reports, and creative-level data.
Pulls Wasted Spend Data
Identifies keywords spending without converting, creatives with declining CTR, audiences with poor ROI, and calculates potential monthly savings.
Compares Against Targets
Cross-references actual metrics against your KPI targets from CLAUDE.md. Checks for strategy drift against STRATEGY.md directives — if you said “AVOID broad match keywords” but a campaign is running them, it flags the drift.
Returns Structured Report
Produces a prioritized scorecard — platform-by-platform metrics, anomalies flagged, wasted spend identified, strategy drift detected, and top 3 recommended actions with reasoning.
What You Get
The agent returns a structured performance report — no dashboard clicking, no CSV exports, no spreadsheet building. Every metric compared to your targets, every anomaly explained, every recommendation backed by data and checked against your strategic directives.
Where Claude Code Shines: Interactive Follow-Up
Here’s where the interactive model pays off. After the sub-agent returns its report, you can immediately drill deeper into anything it flagged. If the report shows declining ROAS on a Google Ads campaign, you don’t need to open a new tool or start a new workflow:
The agent continues the investigation without losing context. This iterative drill-down — report → flag → investigate → decide → act — is the natural workflow of experienced media buyers. Claude Code matches that rhythm in a way that scheduled Codex reports can’t, because those run, return results, and stop.
Claude Code vs Codex for Ad Management
Both tools work with the same Adspirer MCP server and the same 100+ advertising tools. But they serve different workflows and excel at different things. Here’s when to use each:
| Aspect | Claude Code | Codex |
|---|---|---|
| Interaction model | Interactive — you ask, it does, you dig deeper | Autonomous — define once, runs on schedule |
| Brand context | CLAUDE.md (auto-loaded every session) | AGENTS.md (loaded by TOML agent config) |
| Cross-session memory | MEMORY.md — persists decisions, results, preferences | Not available |
| Web research | WebSearch + WebFetch — crawls competitors, gathers market intel | Not available — ad platform data only |
| Agent architecture | Sub-agents (isolated context window, own memory) | TOML agent configs with .rules files |
| Skills | 1 comprehensive skill covering all platforms | 5 separate skills |
| Command syntax | /adspirer:* slash commands | $adspirer-* skill invocations |
| Install method | /plugin install adspirer-ads-agent | Bash install script |
| Safety enforcement | Skill + permission modes + strategy compliance | Skill + .rules files blocking direct API calls |
| Best for | Ad-hoc analysis, deep-dives, competitive research, interactive optimization | Daily automated checks, scheduled reports, anomaly alerting |
They’re complementary, not competing. Use Codex for automated daily performance checks that run every morning without you opening any tool. Use Claude Code for the deep analysis sessions where you need to explore data interactively, research competitors, and make strategic decisions. Many teams use both — Codex flags the anomalies, Claude Code investigates them.
Troubleshooting
What’s Next
Your agent is installed, authenticated, and running. The brand workspace is created with CLAUDE.md, STRATEGY.md, and MEMORY.md. You’ve got 5 slash commands, multi-layer safety guardrails, and a persistent memory system that compounds your knowledge over time.
In Part 3: How to Run Facebook & Instagram Ads with Your Claude Code AI Agent, we go deeper — building a Meta Ads specialist workflow with creative fatigue monitoring, audience optimization, campaign ideation powered by web research, and the compounding knowledge effect that makes your agent smarter with every session.
Ready to start? Sign up for Adspirer (free tier: 15 tool calls/month) and install the Claude Code plugin with /plugin install adspirer-ads-agent.
Related Articles
- How to Build an AI Marketing Agent for Paid Media — Part 1: The concept and why it matters
- How to Run Facebook & Instagram Ads with Your Claude Code AI Agent — Part 3: Channel-specific Meta Ads workflows
- Adspirer Is Now an Official Claude Code Plugin — Plugin marketplace announcement
- How to Set Up Your AI Marketing Agent with Codex — The Codex equivalent of this guide
- How to Run Facebook & Instagram Ads with Claude AI — Claude web app approach (without sub-agents)
- What Is MCP (Model Context Protocol)? — The protocol behind all of this
- PPC Automation with ChatGPT and Claude — Automating paid search workflows
More articles to read
Adspirer Is Now an Official Claude Code Plugin
Adspirer is now available in the Claude Code official plugin marketplace. Install with one command and manage Google, Meta, LinkedIn, and TikTok Ads from Claude.
Claude Cowork for Marketers: How to Manage Ads With Anthropic's AI Agent
How to use Claude Cowork for marketing and advertising. Connect your Google Ads and Meta Ads, analyze 30 days of campaigns in one prompt, and generate performance reports — all inside Claude's agentic workspace.