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

Install the Adspirer plugin, create your brand workspace, configure sub-agents, and run your first ad performance check — all from the Claude Code CLI.

Published: 2026-04-01
Updated: 2026-07-15
Canonical: https://www.adspirer.com/blog/setup-ai-marketing-agent-claude-code

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](/blog/build-ai-marketing-agent-paid-media), 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](/blog/setup-ai-marketing-agent-codex), 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](/blog/build-ai-marketing-agent-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](/blog/meta-ads-claude-code-agent)

---

## Prerequisites

Before you start, make sure you have:
- **Claude Code CLI** installed ([installation guide](https://code.claude.com/docs/en/getting-started))
- **Node.js 18+** (for the MCP server runtime)
- An **Adspirer account** ([free to start](https://adspirer.ai/sign-up?utm_source=blog&utm_medium=content&utm_campaign=setup-ai-marketing-agent-claude-code))
- At least one ad platform account: **Google Ads, Meta Ads, Amazon Ads, ChatGPT 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](https://code.claude.com/docs/en/getting-started) 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-advertising-agent@adspirer-marketplace
```

Or browse for it — type `/plugin`, switch to the **Discover** tab, and search for "Ads." You'll see **adspirer-advertising-agent** from `adspirer-marketplace`.

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 400+ 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 six 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:

```
/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](https://adspirer.ai/sign-up?utm_source=blog&utm_medium=content&utm_campaign=setup-ai-marketing-agent-claude-code)) and connect your ad platforms — Google Ads, Meta Ads, Amazon Ads, ChatGPT 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](https://www.adspirer.com). See the [security documentation](https://www.adspirer.com/docs/knowledge-base/security) for the full security model. This is the same OAuth flow used when [connecting Claude to Google Ads](/blog/connect-claude-google-ads) through the Claude desktop app — Claude Code just adds the agent layer on top.

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:

```bash
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:

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.

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

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.

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.

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:

| 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 every connected platform, 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:

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.

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.

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.

The agent calls Adspirer tools to pull data, analyzes results against your KPI targets and strategy, and checks for anomalies, wasted spend, and opportunities.

A structured summary is sent back to your main conversation — metrics, findings, and recommended actions, all prioritized.

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 400+ 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](https://code.claude.com/docs/en/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.

Sub-agents and agent teams run inside your Claude Code session. If you want work to happen while you're away from the terminal, Adspirer now ships that server-side. [Ad Ops agents](https://www.adspirer.com/docs/agent-skills/ad-ops-agents) take a plain-English goal, work across all six connected platforms, and drop recommended changes into an approval queue you clear later (Plus and up). The [Watch Agent](https://www.adspirer.com/docs/knowledge-base/capabilities) scans your accounts every 15 minutes and emails findings with staged fixes. And [Community Plugins](https://www.adspirer.com/docs/agent-skills/community-plugins) — open-source, read-only, sandboxed extensions exposed through a `community_plugins` router — let your sub-agent pull in community-built analyses without writing a line of server code.

---

## 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`.

/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.

/adspirer:performance-review

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

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.

/adspirer:write-ad-copy

Or be specific about what you need:

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.

/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.

/adspirer:refresh-brand-context

For the complete command reference with all parameters and workflows, see the [skill documentation](https://www.adspirer.com/docs/agent-skills/skills).

---

## 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. |
| **Destructive tools hard-gated** | `delete_*` and `remove_*` tools won't execute without an explicit `confirm_delete: true` flag — and a "pause" request can never be silently routed to a delete. |
| **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](https://www.adspirer.com/docs/knowledge-base/capabilities) 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:

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:

Loads `CLAUDE.md` (brand knowledge, KPI targets, budget guardrails), `STRATEGY.md` (active directives and constraints), and `MEMORY.md` (past decisions and historical findings).

Calls `get_connections_status` to identify which platforms are active and pulls current account-level metadata.

Calls Adspirer tools in parallel for each connected platform — campaign metrics, ad group breakdowns, keyword performance, search term reports, and creative-level data.

Identifies keywords spending without converting, creatives with declining CTR, audiences with poor ROI, and calculates potential monthly savings.

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.

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:

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 400+ 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-advertising-agent@adspirer-marketplace` | 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

Make sure you're searching for "adspirer" or "Ads" in the Discover tab. If the plugin doesn't appear, try `/plugin install adspirer-advertising-agent@adspirer-marketplace` directly. You need Claude Code CLI version 1.0.0 or later. If it's still not found, see the [Claude Code setup documentation](https://www.adspirer.com/docs/ai-clients/claude-code).

Run `/mcp` to check the server status. If it shows as disconnected, try `/reload-plugins`, then re-open `/mcp` to verify. If it's still disconnected, re-authenticate from the `/mcp` menu.

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.

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.

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

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](https://www.adspirer.com/pricing) 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](/blog/meta-ads-claude-code-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](https://adspirer.ai/sign-up?utm_source=blog&utm_medium=content&utm_campaign=setup-ai-marketing-agent-claude-code) (free tier: 15 tool calls/month) and install the Claude Code plugin with `/plugin install adspirer-advertising-agent@adspirer-marketplace`.

[Get started free →](https://adspirer.ai/sign-up?utm_source=blog&utm_medium=content&utm_campaign=setup-ai-marketing-agent-claude-code)

---

## Related Articles

- [How to Build an AI Marketing Agent for Paid Media](/blog/build-ai-marketing-agent-paid-media) — Part 1: The concept and why it matters
- [How to Run Facebook & Instagram Ads with Your Claude Code AI Agent](/blog/meta-ads-claude-code-agent) — Part 3: Channel-specific Meta Ads workflows
- [Adspirer Is Now an Official Claude Code Plugin](/blog/adspirer-official-claude-plugin) — Plugin marketplace announcement
- [How to Set Up Your AI Marketing Agent with Codex](/blog/setup-ai-marketing-agent-codex) — The Codex equivalent of this guide
- [How to Run Facebook & Instagram Ads with Claude AI](/blog/connect-claude-meta-ads) — Claude web app approach (without sub-agents)
- [What Is MCP (Model Context Protocol)?](/blog/what-is-mcp-model-context-protocol) — The protocol behind all of this
- [PPC Automation with ChatGPT and Claude](/blog/ppc-automation-chatgpt-claude) — Automating paid search workflows
- [How to Connect Claude to Google Ads (2026 Guide)](/blog/connect-claude-google-ads) — The Claude desktop app setup
