fb-ads-automation: Command for Claude Code

.claude/commands/fb-ads/optimize.md

optimize is a command for Claude Code from shashankrai1983/fb-ads-automation. It costs 0 tokens per session (439 once invoked), scanned A, original, MIT.

A command that analyses one Facebook advertising campaign, or all active campaigns, and prepares an optimisation report.

In plain words
What is it for?
Use it to inspect daily trends over the past 14 days, identify tired creatives or overused audiences, compare ad-set budgets, and receive recommended actions for confirmation.
Why use it?
It gathers recent performance, creative fatigue, audience saturation, budgets, and campaign settings so problems can be reviewed before making changes.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution.

This is shashankrai1983/fb-ads-automation's own configuration. It tells Claude Code how to work on fb-ads-automation itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything fb-ads-automation configures →

Reuse

Borrowing it

Nothing to install: this file belongs to shashankrai1983/fb-ads-automation. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/shashankrai1983/fb-ads-automation/main/.claude/commands/fb-ads/optimize.md
Clone the repo
git clone --depth 1 https://github.com/shashankrai1983/fb-ads-automation

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/shashankrai1983/fb-ads-automation/optimize.svg)](https://agentmods.dev/commands/shashankrai1983/fb-ads-automation/optimize)
Your own site
<a href="https://agentmods.dev/commands/shashankrai1983/fb-ads-automation/optimize"><img src="https://agentmods.dev/badge/commands/shashankrai1983/fb-ads-automation/optimize.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 439 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00439
Opus 5 $0.00000 $0.00219
Sonnet 5 $0.00000 $0.00088
Haiku 4.5 $0.00000 $0.00044

Measured 6d ago against content hash 60d4fc28754d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/fb-ads/optimize.md · 46 lines

What it actually says

Analyze and optimize a specific campaign (or all active campaigns if none specified).

For comprehensive multi-campaign optimization with creative suggestions, load the ads-optimizer agent instead: "Load optimizer agent"

Argument: $ARGUMENTS (campaign ID or "all")

Steps

  1. If a specific campaign ID is provided, use that. Otherwise, call list_campaigns with status_filter=ACTIVE and analyze all.

  2. For each campaign being optimized: a. Call get_campaign to get current config (budget, status, objective) b. Call get_campaign_insights with date_preset=last_14d and time_increment=1 for daily trends c. Call get_creative_fatigue_report with days=14 d. Call get_audience_saturation_check with days=14 e. Call list_ad_sets for the campaign to check per-adset budgets

  3. Read knowledge/playbook.md for current threshold values. Score each entity against the Red Flag Thresholds and Decision Frameworks.

  4. Present an optimization action table:

## Optimization Report — [Campaign Name]

### Current State
- Objective: X | Daily Budget: $Y | Status: Z
- 14d Spend: $X | CTR: X% | CPC: $X | Frequency: X

### Findings
[Detailed analysis of fatigue, saturation, cost trends]

### Action Table
| # | Action | Entity | Details | Impact | Risk |
|---|--------|--------|---------|--------|------|
| 1 | Pause ad | ad_123 | CTR dropped 40% | High | Low |
| 2 | Expand audience | adset_456 | Frequency at 4.2 | Med | Med |

### Execute?
Which actions should I execute? (specify numbers, "all", or "none")
  1. Wait for explicit user confirmation. Execute only approved actions.

  2. After executing, log changes to docs/optimization-log.md with date, actions taken, and rationale.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 46 lines · 0 tokens per session scan A 60d4fc28754d

Subscribe to this mod's changes

optimize is a command published in the GitHub repository shashankrai1983/fb-ads-automation (0 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 439 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.