A Claude Code agent for ad reporting

A reporting agent only needs to read data and write files, so the safe build is a read-only Claude Code subagent that a single scheduled command runs every morning.

By Grace Kong·Updated ·6 min read

Get a daily ad report from your agent

TL;DR

  • Save the agent as .claude/agents/ad-reporter.md. Only name and description are required, and its tools line keeps it to file tools, so it never edits a campaign.

  • Each run flags pacing more than 15% off budget, moves over 30% against the prior 7-day average (with at least 10 results), and Meta's Learning limited and Creative fatigue statuses. On Mondays it writes the weekly report.

  • Schedule it four ways: a cloud task runs with your machine off at a 1-hour minimum interval, /loop tasks expire after 30 days, a Desktop task needs your machine on, and claude -p runs from cron or GitHub Actions.

  • claude -p --output-format json returns the report and total_cost_usd, a client-side estimate of what each run cost, so you can log it daily.

  • For Meta data, grant the official Ads MCP ads_read without ads_management so the agent can report but never change budgets.

The agent file

A subagent is a Markdown file with frontmatter; the body is its standing instructions.

---
name: ad-reporter
description: Writes the daily and weekly paid media report from Meta,
  TikTok and Google data. Use for "how did ads do", pacing checks,
  anomaly alerts and the Monday report. Read-only; never edits campaigns.
tools: Read, Write, Glob, Bash
model: sonnet
---

You are the ad reporting agent. You read data and write reports. You
never create, pause, edit or launch anything, even if asked.

INPUTS
- targets.md: goal event, target CPA or ROAS, monthly budget per channel,
  attribution setting, time zone.
- Data, in this order of preference:
  1. Connected read-only MCP tools (Meta Ads MCP with ads_read only,
     TikTok for Business MCP, Hypesonic MCP for campaigns it launched).
  2. Latest exports in data/YYYY-MM-DD/ (Meta, TikTok, Google CSVs).
  If neither exists for today, write "NO DATA" and stop.

DAILY (every run)
1. Pacing: month-to-date spend vs budget x (days elapsed / days in month)
   per channel. Flag more than [15]% over or under.
2. Anomalies vs the prior 7-day average: spend, CPM, CTR, cost per
   result. Flag moves over [30]% with at least [10] results.
3. Status flags: ad sets in "Learning limited", ads showing "Creative
   fatigue" or "Creative limited".
4. Write reports/daily/YYYY-MM-DD.md: 5 lines max, flags first.

WEEKLY (when today is Monday)
5. Write reports/weekly/YYYY-MM-DD.md: spend, results and blended cost
   per new customer; channel scoreboard vs last week and 4-week average;
   top and bottom 3 ads (10+ results); 3 recommendations with amounts.

RULES
- Show the math for every computed number.
- Platform-reported conversions overlap; never sum them as "total sales".
- Unknown stays unknown. No estimates for missing data.

The tools line lists only file tools, and a subagent with a tools list gets nothing else. To let it read live data, add the read tools of your connected servers by their full names, for example mcp__meta-ads__ads_get_ad_entities if you named Meta's server meta-ads, and add the same names to --allowedTools in the script below. Leave out every tool that creates or changes campaigns. The pacing math in step 1 is ours. The status flags in step 3 are Meta's own: "Learning limited" when an ad set is unlikely to get about 50 events in a week (Meta), and "Creative fatigue" when cost per result reaches twice your past ads (Meta).

Run it once from a script

claude -p is the entry point every scheduler calls.

#!/bin/sh
# run_report.sh: run the agent once, save the result and the cost
cd ~/ads-reporting
claude -p "Use the ad-reporter agent to run today's report." \
  --allowedTools "Read,Write,Glob,Bash(python3 *)" \
  --output-format json > logs/$(date +%F).json
jq -r '.result' logs/$(date +%F).json
jq -r '.total_cost_usd' logs/$(date +%F).json

Exit code 0 means the run finished; the JSON holds the report text in result and an estimated cost in total_cost_usd (Claude Code docs).

Four ways to schedule it

Pick by where your data lives: local exports need your machine, connectors work from the cloud.

OptionRuns onNeeds your machine on?NotesSource
/loop in a sessionYour machineYes, and the session openMinimum interval 1 minute; recurring tasks expire after 30 daysClaude Code docs
Desktop scheduled taskYour machineYes, no open session neededHas your local files and MCP configClaude Code docs
Cloud scheduled taskAnthropic's cloudNoMinimum interval 1 hour; works from a fresh clone, no local files; connectors set per taskClaude Code docs
GitHub Actions or cron + claude -pYour CI or serverNo (CI) or yes (local cron)Use --output-format json to log cost; total_cost_usd is a client-side estimateClaude Code docs

Claude Code details that matter for reporting

Most reporting agents break on permissions or sign-in, not on the report.

Claude Code factWhy it matters hereSource
Subagents live in .claude/agents/ (project) or ~/.claude/agents/ (all projects); only name and description are requiredCommit the project version so the team shares one reporterClaude Code docs
Each subagent has its own context window and does not see your conversation historyEverything it needs goes in the file and targets.mdClaude Code docs
The tools field limits what it can use; disallowedTools removes toolsLeave out Edit and anything that writes to ad accountsClaude Code docs
claude -p runs non-interactively; --allowedTools pre-approves tools; --output-format json returns the result and costThis is the scheduled entry pointClaude Code docs
--bare skips auto-discovered MCP servers unless you pass --mcp-config, and never reads OAuth credentialsSign in to MCP servers in an interactive session first, or use exportsClaude Code docs

Connect the data

Read-only access first; a reporting agent never needs write scopes.

  • Meta: the official Ads MCP at https://mcp.facebook.com/ads; grant ads_read without ads_management to keep it to reporting (Meta for Developers). Business admins can also set rules that deny agent actions per ad account (Meta).
  • TikTok: the TikTok for Business MCP, with a layered URL that loads about 40 core tools (TikTok).
  • Google Ads: the official open-source Google Ads MCP reads reports with GAQL and cannot change campaigns (GitHub).
  • Hypesonic: claude mcp add --transport http hypesonic https://www.hypesonic.com/mcp, sign in with /mcp. For campaigns your agent launched through Hypesonic (Meta, TikTok, Pinterest, Reddit, LinkedIn, streaming TV, billboards), it pulls spend and results from each channel. Campaigns built elsewhere still come from the platform MCPs above or from exports.
  • No connectors: drop scheduled exports into data/YYYY-MM-DD/. Meta emails scheduled reports weekly (Meta) and TikTok sends scheduled exports to up to 5 recipients (TikTok).

Common mistakes

Unattended agents fail quietly; build in loud failures.

  • Write scopes "just in case". A reporting agent with ads_management can change budgets if a prompt goes wrong.
  • OAuth in a headless run. Sign in interactively first; a scheduled run cannot click through a login.
  • Silent empty days. The "NO DATA" rule makes a missing export visible.
  • Summing platform conversions. They overlap; report them side by side.
  • No cost log. Save the JSON so you can see what each run cost.

Questions

Can Claude Code send me a daily ad report automatically?

Yes. Define a reporting subagent, then run it on a schedule with a Claude Code cloud or Desktop scheduled task, /loop in an open session, or claude -p from cron or GitHub Actions.

What is a Claude Code subagent?

A Markdown file in .claude/agents/ or ~/.claude/agents/ with a name, a description and optional tools and model, followed by its instructions. It runs in its own context window.

Does a scheduled Claude Code task run when my computer is off?

Cloud scheduled tasks do, with a minimum interval of 1 hour and no access to local files. Desktop tasks and /loop need your machine on.

How do I stop the reporting agent from changing my campaigns?

Give it read-only data access (for Meta, ads_read without ads_management), limit its tools in the agent file, and state in its instructions that it never edits anything.

How much does each run cost?

claude -p with --output-format json reports total_cost_usd for the run, a client-side estimate you can log per day.

Sources

  1. 1Claude Code docs, subagents
  2. 2Claude Code docs, run programmatically
  3. 3Claude Code docs, scheduled tasks
  4. 4Meta, learning limited
  5. 5Meta, creative fatigue recommendations
  6. 6Meta for Developers, ads MCP server get started
  7. 7Meta for Developers, ads MCP server rules
  8. 8TikTok Ads Help, TikTok for Business MCP server
  9. 9GitHub, googleads/google-ads-mcp
  10. 10Meta, scheduled reports
  11. 11TikTok Ads Help, scheduled reports

Get a daily ad report from your agent

Keep reading