All articles
Tutorial 17 min read

How to Set Up Your AI Marketing Agent with Claude Code [2026]

A

Adspirer Team

Share Y
How to Set Up Your AI Marketing Agent with Claude Code [2026]
Summary

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.

Info

This is Part 2 of a 3-part series.


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)
Tip

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-agent

Or 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:

ComponentLocationPurpose
MCP ServerPlugin configConnects Claude Code to Adspirer’s 100+ advertising tools via OAuth
Sub-Agent~/.claude/agents/performance-marketing-agent.mdDefines the marketing agent’s behavior, brand awareness, and workflows
Skill~/.claude/skills/ad-campaign-management/SKILL.mdOne comprehensive skill covering all 4 ad platforms
5 Slash Commands~/.claude/commands/*.mdQuick-access commands for common advertising workflows

After installing, run /reload-plugins to activate the plugin and load the MCP server.

Warning

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.

Prefer manual MCP setup?

If you want to skip the plugin and add just the MCP server:

Terminal window
claude mcp add --transport http adspirer https://mcp.adspirer.com/mcp

This gives you the 100+ advertising tools but not the sub-agent, skill, or slash commands. You can optionally clone and install those separately:

Terminal window
git clone https://github.com/amekala/ads-mcp.git /tmp/ads-mcp
mkdir -p ~/.claude/agents ~/.claude/skills ~/.claude/commands
cp /tmp/ads-mcp/plugins/claude-code/adspirer/agents/performance-marketing-agent.md ~/.claude/agents/
cp -r /tmp/ads-mcp/plugins/claude-code/adspirer/skills/ad-campaign-management ~/.claude/skills/
cp /tmp/ads-mcp/plugins/claude-code/adspirer/commands/*.md ~/.claude/commands/

See the full Claude Code setup documentation for details on each component.


Step 2: Authenticate with Your Ad Accounts

After installing the plugin, you need to connect your Adspirer account. Open the MCP settings by typing:

/mcp

Find 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:

Terminal window
cd ~/Clients/YourBrand # or wherever your brand docs live
claude

Then invoke the setup command:

/adspirer:setup

What 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 docs

The CLAUDE.md file is the agent’s brain. Here’s what a typical one contains after setup:

SectionContentSource
Brand OverviewWhat you sell, who you sell to, industryYour docs + Adspirer
Brand VoiceTone, language style, prohibited wordsYour brand docs
Target AudiencesAudience segments with targeting parametersYour docs + campaigns
Active PlatformsConnected platforms, campaign countsAdspirer
Budget & GuardrailsMonthly budget, CPC caps, CPA targetsYour docs + campaigns
KPI TargetsPrimary goals and target metricsYour docs
Performance SnapshotLast 30 days across all platformsAdspirer
Key FindingsTop campaigns, wasted spend, opportunitiesAdspirer 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.

Info

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.

Command: /adspirer:setup

Bootstraps or refreshes your brand workspace. Run this when you first connect, when you add new ad platforms, or when you drop new brand docs into your project folder. Creates CLAUDE.md, STRATEGY.md, and initializes MEMORY.md.

First Setup

/adspirer:setup

Command: /adspirer:performance-review

Runs a cross-platform performance scorecard. Pulls metrics from all connected platforms, compares against your KPI targets in CLAUDE.md, checks STRATEGY.md for drift, and identifies top performers, underperformers, and anomalies.

Weekly Review

/adspirer:performance-review

Or describe what you want naturally — the agent matches the right workflow:

Custom Review

Run a performance review for the last 14 days. Focus on Meta Ads creative fatigue and Google Ads keyword performance. Compare against my KPI targets and flag any strategy drift.

Command: /adspirer:write-ad-copy

Generates brand-voice ad copy using your CLAUDE.md brand guidelines and real performance data from your account. The agent knows what headlines and descriptions have worked in your account, what your brand voice sounds like, and what character limits each platform requires.

Write Ad Copy

/adspirer:write-ad-copy

Or be specific about what you need:

Specific Copy Request

Write Google Search ad copy for my new product launch. Use my brand voice from CLAUDE.md. Generate 15 headlines and 4 descriptions that fit character limits. Reference my top-performing existing ads for tone and structure.

Command: /adspirer:wasted-spend

Finds money leaks across your accounts. Identifies keywords spending without converting, creatives with declining performance, audiences with poor ROI, and totals up potential monthly savings with specific recommendations for each finding.

Wasted Spend Audit

/adspirer:wasted-spend

Command: /adspirer:refresh-brand-context

Re-scans your project folder for new brand documents and pulls the latest performance data from all connected platforms. Updates CLAUDE.md with current metrics and any new brand context. Run this after connecting new platforms, adding new brand docs, or when you want to refresh the performance baseline.

Refresh After Changes

/adspirer:refresh-brand-context

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

RuleHow It Works
Campaigns created PAUSEDAll campaign creation defaults to PAUSED status. Nothing goes live without your explicit approval.
User confirmation for spendThe agent asks before creating campaigns or changing budgets. Claude Code’s permission system requires you to approve tool calls that affect spend.
Read-before-writeConnection check → research → validate → create → verify. The skill enforces this sequence — you can’t skip the research step and jump straight to creation.
Budget guardrailsYour CLAUDE.md contains budget caps and CPA targets. The agent checks these before recommending any spend changes.
Strategy complianceBefore 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 retriesIf campaign creation fails, the agent reports the error and stops. It doesn’t retry and risk creating duplicate campaigns.
Post-creation verificationAfter 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:

ModeFile AccessTool CallsBest For
DefaultRead onlyApproval needed for eachFirst-time setup, reviewing the system
AutoRead + edit in working dirAuto-approved in scopeCampaign creation, keyword management
Full AccessRead anywhere + networkAuto-approvedBulk 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.

Info

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:

First Performance Review

Run a performance review across all my connected ad platforms for the last 30 days. Compare each campaign to my KPI targets. Flag any campaigns with CPA above target, declining ROAS, or creative fatigue. Give me a prioritized summary with the top 3 actions I should take today.

Or use the slash command directly:

/adspirer:performance-review

What 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:

Drill Down

That Search campaign’s ROAS dropped from 3.2x to 1.8x — pull the keyword-level data for the last 14 days. Which keywords are dragging down the average? Check the search terms report for irrelevant queries that should be added as negatives.

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:

AspectClaude CodeCodex
Interaction modelInteractive — you ask, it does, you dig deeperAutonomous — define once, runs on schedule
Brand contextCLAUDE.md (auto-loaded every session)AGENTS.md (loaded by TOML agent config)
Cross-session memoryMEMORY.md — persists decisions, results, preferencesNot available
Web researchWebSearch + WebFetch — crawls competitors, gathers market intelNot available — ad platform data only
Agent architectureSub-agents (isolated context window, own memory)TOML agent configs with .rules files
Skills1 comprehensive skill covering all platforms5 separate skills
Command syntax/adspirer:* slash commands$adspirer-* skill invocations
Install method/plugin install adspirer-ads-agentBash install script
Safety enforcementSkill + permission modes + strategy complianceSkill + .rules files blocking direct API calls
Best forAd-hoc analysis, deep-dives, competitive research, interactive optimizationDaily automated checks, scheduled reports, anomaly alerting
Tip

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

Plugin not found in /plugin

Make sure you’re searching for “adspirer” or “Ads” in the Discover tab. If the plugin doesn’t appear, try /plugin install adspirer-ads-agent directly. You need Claude Code CLI version 1.0.0 or later. If still not found, use the manual MCP setup.

MCP server not connecting

Run /mcp to check the server status. If it shows as disconnected, try /reload-plugins. For manual setup: claude mcp add --transport http adspirer https://mcp.adspirer.com/mcp. Verify with /mcp again.

Authentication failed or expired

Open /mcp, find the Adspirer server, and select Authenticate to re-authenticate. A browser window opens for OAuth. If it doesn’t open automatically, check your terminal for a URL to copy.

'Nested session' error when running /plugin

You typed /plugin or /adspirer:setup inside a response to the AI, not in the input bar. Slash commands must be typed directly into Claude Code’s input bar — they’re user commands, not AI prompts.

'No ad platforms connected' error

Connect your ad platforms at adspirer.com. The agent needs at least one connected platform (Google Ads, Meta Ads, LinkedIn Ads, or TikTok Ads) to work. After connecting, run /adspirer:refresh-brand-context to update the workspace.

Rate limit hit

Check your Adspirer tier. Free: 15 tool calls/month. Plus: 150. Pro: 600. Max: 3,000. A performance review uses 4-8 calls depending on how many platforms are connected. For regular use, the Plus plan at $49/month covers weekly reviews and occasional campaign creation.


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.

Info

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.

Get started free →


Claude AI Agents MCP Automation

More articles to read