The recipes that turn Claude Code from a general assistant into a specialized media buying machine.
EXCLUSIVE ACCESS — NOT PUBLIC
Skills & SOPs
Part 5 of 7
Skills & SOPs
The recipes that turn Claude Code from a general assistant into a specialized media buying machine.
⏱ ~8 min read
🎯 Intermediate Level
Section 01
What Is a Skill File?
A Skill is a text file (with a .SKILL.md extension) that contains step-by-step instructions for Claude Code to follow. Think of it like a detailed recipe: it has ingredients (prerequisites), steps (instructions), and what the final dish should look like (expected output).
Without Skills, Claude Code is smart but generic — like having a talented chef who doesn't know YOUR recipes. It can cook, sure. But it doesn't know that your brand always uses a 3-day learning phase before scaling, or that your ROAS threshold is 2.5x instead of the industry average 2x, or that your CEO wants the daily report at 8am in a specific format.
Skills make Claude Code YOUR specialist. They encode your specific processes, thresholds, preferences, and workflows so the AI operates exactly the way you want it to — every single time.
Anatomy of a Skill File
Every Skill file follows the same structure. Here are the 8 building blocks:
01
Frontmatter (---name/description---)
The Skill's ID card. This is how Claude Code identifies and catalogs the Skill. The name becomes the command you type (like /check-performance), and the description helps Claude decide when this Skill is relevant.
02
Purpose
A clear, one-paragraph explanation of what this Skill accomplishes. This is not for Claude — it's for YOU and your team, so anyone reading the file knows what it does at a glance.
03
When to Use
What triggers this Skill. It can be explicit commands (like typing /optimize-budgets) or natural language ("which campaigns should I scale?"). Claude reads this section to decide if the current request matches this Skill.
04
Prerequisites
What needs to be set up before the Skill can run. This includes API tokens (Meta access token, Shopify keys), plugins (Playwright MCP server), and any data sources that need to be connected.
05
Self-Learning Protocol
How to adapt when things change. This is the section that tells Claude what to do if an API call fails — typically: open the official docs via Playwright, read the updated reference, adapt the call, and retry. This is what makes Skills future-proof.
06
Instructions
The actual step-by-step process. This is the longest section — it walks through every action in order: fetch this data, parse these fields, apply this logic, present the results. The more specific you are here, the better Claude performs.
07
Environment Variables
What tokens and IDs the Skill needs to function. Things like META_ACCESS_TOKEN, AD_ACCOUNT_ID, PIXEL_ID, or SHOPIFY_STORE_URL. These are stored in your .env file, never hardcoded.
08
Example Usage
Sample commands showing how to invoke the Skill. This helps both Claude and future team members understand the expected input format. Example: /optimize-budgets last 7 days, ROAS threshold 2.5x
anatomy-of-a-skill.md
Interactive
---name:check-performance description:Pull Meta campaign metrics and flag anomaliesThe ID card
---
# Check PerformanceThe title
## PurposeWhat it does
## When to UseWhat triggers it
## Self-Learning ProtocolHow it adapts
## InstructionsThe actual steps
## Environment VariablesTokens & IDs
## Example UsageSample commands
Section 02
Real Example: The Budget Optimizer Skill
Let's look at a real Skill file — the Meta Budget Optimizer. This is one of the most frequently used Skills in the framework, and it demonstrates every concept we just covered.
The Basics
Here's what the frontmatter and purpose look like:
meta-budget-optimizer.SKILL.md
---
name:meta-budget-optimizer
description:Analyze ROAS/CPA across campaigns and recommend budget changes
---
# Meta Budget Optimizer
## Purpose
Pull performance data from Meta Ads Insights API, analyze
ROAS/CPA/CPM across campaigns, and recommend or apply
budget reallocations based on data.
When It Triggers
The Skill activates when you say things like:
"Optimize my budgets"
"Which campaigns should I scale?"
"Analyze campaign performance"
"Reallocate my spend based on ROAS"
Claude reads the "When to Use" section and matches your natural language to the right Skill automatically. You don't need to memorize exact commands.
The Instructions Walkthrough
Here's what the Skill actually does, step by step:
Step 1
Fetch Campaign Insights from Meta API
Makes an API call to GET /act_{id}/insights to pull the last 7 days of data. Fields: campaign name, spend, ROAS, CPA, CPM, CTR, frequency, and impressions.
Step 2
Parse Key Metrics
Extracts and organizes ROAS, CPA, CPM, CTR, and frequency for each campaign. Calculates averages and identifies outliers (campaigns performing significantly above or below the mean).
Step 3
Categorize Each Campaign
Every campaign gets sorted into one of four buckets based on ROAS performance. This is the core decision logic — see the table below.
Step 4
Calculate Recommended Budgets
Based on the category, the Skill calculates a specific dollar amount to increase, decrease, or reallocate. It doesn't just say "spend more" — it says "increase from 500 EGP/day to 650 EGP/day (+30%)."
Step 5
Present the Report
Generates a clean, formatted summary showing: total spend, average ROAS, each campaign's category, and the specific recommended changes with projected impact.
Step 6
Apply Changes Only If You Confirm
The Skill shows you the plan and asks "Should I apply these changes?" It will NOT touch your budgets until you explicitly say yes. You are always in control.
The Categorization Table
This is the decision matrix the Skill uses to categorize campaigns:
ROAS
Category
Action
> 3x
Scale
+20-30% budget increase
2-3x
Maintain
Keep current budget
1-2x
Reduce
-20-30% budget decrease
< 1x
Pause
Stop spending entirely
💡 Key Insight
Notice Step 6 — the Skill never makes changes without your confirmation. You're always in control. The AI does the heavy lifting (data pulling, analysis, categorization, recommendations), but you make the final call. This is the core principle of the entire framework: AI assists, you decide.
Section 03
Technical SOPs: Step-by-Step Processes
An SOP (Standard Operating Procedure) is a documented process for a specific task. In our context, a Technical SOP is the exact sequence of steps to accomplish ONE thing — like creating a campaign, checking performance, or setting up an ad set.
If Skills are recipes, Technical SOPs are the individual cooking techniques inside those recipes — how to julienne onions, how to make a roux, how to temper chocolate. Each one is a complete, self-contained process that produces a specific result.
Example: "Create a Campaign" SOP
Here's what a Technical SOP looks like in practice. This one handles the full process of creating a Meta campaign from scratch:
01
Gather Inputs
Collect the essentials from the user: campaign name, objective (conversions, traffic, awareness), daily budget, and targeting parameters (age, gender, interests, lookalike audiences).
02
Create the Campaign
Make an API call to POST /act_{ad_account_id}/campaigns with the campaign name, objective, special ad categories, and buying type. The campaign is created in PAUSED status — never active.
03
Create the Ad Set
Make an API call to create an ad set under the new campaign. This includes: targeting spec, budget, bid strategy, optimization goal, placement (automatic or manual), and schedule.
04
Create the Ad
Make an API call to attach the creative (image/video, headline, primary text, CTA button) to the ad set. The ad is linked to the page and pixel for tracking.
05
Report Back
Return the campaign ID, ad set ID, and ad ID to the user, plus a direct link to Ads Manager so they can review everything visually before activating.
06
Everything Stays Paused
Nothing goes live automatically. Every entity is created in PAUSED status. The user reviews, adjusts if needed, and manually activates when ready. Safety first.
The 5 Ready-Made Technical SOPs
The framework provides 5 Technical SOPs that cover the full campaign lifecycle. Each one is a standalone process you can trigger with a command:
/create-campaign
Campaign Creator
Build a complete campaign structure from scratch — campaign, ad set, and ad — all via the Meta API. Handles objective selection, budget configuration, and creates everything in PAUSED status.
/setup-adset
Ad Set Builder
Create additional ad sets under an existing campaign. Configure targeting, placements, budget, schedule, and optimization events. Perfect for A/B testing different audiences.
/create-ad
Ad Builder
Attach creatives to ad sets. Handles image/video ads, carousel formats, and dynamic creative. Links the ad to your page and pixel automatically.
/check-performance
Performance Checker
Pull real-time metrics from the Insights API. Returns ROAS, CPA, CPM, CTR, frequency, and spend at campaign, ad set, or ad level. Flags anomalies automatically.
/scale-campaign
Campaign Scaler
Increase budgets on winning campaigns using a safe, incremental approach (15-20% at a time). Monitors for learning phase resets and adjusts accordingly.
Section 04
Strategy SOPs: Chained Decision-Making
A Strategy SOP is a SEQUENCE of technical steps that handles a complete scenario. It's not just "do step A" — it's "do step A, analyze the result, decide between path B or C based on the data, then execute."
Technical SOPs are like individual LEGO bricks. Strategy SOPs are the instruction booklets that tell you how to combine those bricks into a finished structure. They chain multiple technical steps together with decision logic in between.
Example: Morning Optimization Routine
This Strategy SOP runs every morning and handles your daily campaign health check. It chains together multiple Technical SOPs with conditional logic:
01
Run /check-performance for Last 24 Hours
Pull yesterday's data across all active campaigns. Get the fresh numbers: ROAS, CPA, frequency, spend, and conversion counts.
02
IF any campaign ROAS < 1x for 3+ days → Recommend Pausing
Check the trend, not just yesterday. If a campaign has been losing money for 3 consecutive days, it's not a bad day — it's a bad campaign. Flag it for pause.
03
IF any campaign ROAS > 3x and budget is capped → Recommend Scaling +20%
If a campaign is crushing it but hitting its daily budget limit before the day ends, it's leaving money on the table. Recommend a 20% budget increase.
04
IF frequency > 3 on any cold audience → Recommend Creative Refresh
High frequency on cold audiences means people are seeing the same ad too many times. The creative is getting stale. Time to swap in fresh visuals and copy.
05
Run /optimize-budgets to Reallocate
Based on all the findings, run the budget optimizer to shift spend from underperformers to winners. Present the reallocation plan for approval.
06
Generate Daily Summary Report
Create a clean summary: what changed overnight, which campaigns need attention, what actions are recommended, and what the projected impact is if you approve.
Example: New Product Launch
This Strategy SOP handles the complete process of launching ads for a new product — from creative generation to results analysis:
01
Generate Creative Variations (Creative Agent)
Use the Creative Agent to produce multiple ad variations: different headlines, primary text, CTAs, and visual styles. Start with 5-10 variations for testing.
02
Build Campaign Structure with 3 Test Ad Sets (Campaign Launcher)
Create one campaign with 3 ad sets targeting different audiences: broad, interest-based, and lookalike. Distribute creatives across ad sets for structured testing.
03
Set Up Monitoring with Specific Alerts (Performance Monitor)
Configure alerts: notify if CPA exceeds 2x target, if frequency hits 3 on any ad set, or if spend pacing is off by more than 20%. Daily automated checks.
04
After 7 Days: Analyze Results, Kill Losers, Scale Winners
After the learning phase, review the data. Pause ad sets with ROAS below threshold. Scale winners with a 20% budget bump. Reallocate spend from losers to winners.
05
Generate Launch Performance Report
Create a comprehensive launch report: total spend, revenue generated, best-performing creative, best audience, CPA trend over time, and recommendations for the next phase.
💡 The Difference
Technical SOPs = individual recipes. "How to make a roux." "How to sear a steak." Each one does one thing well.
Strategy SOPs = full meal plans. "Prepare a 3-course dinner: start with the soup (uses the roux), then the main (uses the searing technique), then the dessert." They chain individual techniques into a complete workflow.
You need both. Technical SOPs are the building blocks. Strategy SOPs are the blueprints.
Section 05
Creating Your Own SOPs & Skills
The framework comes with ready-made Skills and SOPs, but the real power is creating your own. Here's the step-by-step process for turning any repetitive task into an automated Skill.
Step 1
Pick Your Most Repetitive Daily Task
What do you do every single day (or week) that takes more than 10 minutes? Common picks: checking campaign performance, generating reports, adjusting budgets, reviewing ad creative performance, or updating product feeds.
Step 2
Write Down EVERY Step (Be Specific)
Don't write "check campaigns." Write: "Open Ads Manager, navigate to Campaigns tab, filter by Active status, sort by ROAS descending, look at the top 10 campaigns, check if any have ROAS below 1.5x." The more specific, the better the Skill.
Step 3
Add Decision Points
Where do you make choices? Write them as IF/THEN rules: "IF ROAS is below 1x for 3 days, THEN recommend pausing." "IF CTR drops below 1%, THEN flag for creative refresh." These conditionals are what make your Skill intelligent.
Step 4
Add Data Sources
Where does the data come from? Be explicit: "Pull from Meta Insights API using GET /act_{id}/insights" not just "check the data." "Query Shopify Admin API for inventory levels" not just "look at stock." Claude needs to know where to go.
Step 5
Define Thresholds
What does "good" and "bad" look like for YOUR business? A 2x ROAS might be amazing for one brand and terrible for another. Define your specific numbers: "Scale threshold: ROAS > 2.5x. Pause threshold: ROAS < 0.8x. Alert if CPA > 150 EGP."
Step 6
Save as a .SKILL.md File
Use the template structure from Section 1: frontmatter with name and description, Purpose, When to Use, Prerequisites, Self-Learning Protocol, Instructions, Environment Variables, and Example Usage. Save it in your project's skills directory.
Step 7
Test It
Ask Claude Code to follow the Skill's instructions. Watch what it does. Does it pull the right data? Does it apply the correct logic? Does the output match what you'd have done manually? Take notes on what's off.
Step 8
Iterate
The first version won't be perfect. That's expected. Run it 3-4 times, identify where it misses or gets confused, refine the instructions, add edge cases you forgot, and re-test. Each iteration gets better.
💬 Real Talk
Your first SOP will be imperfect. That's normal. Run it 3-4 times, see where it misses, refine the instructions. By version 3, it'll be running smoothly. By version 5, it'll be better than you doing it manually — because it never forgets a step, never gets distracted, and never says "I'll do it later."
Section 06
The Self-Learning Protocol: Why Skills Never Go Stale
This is the feature that separates Skills from simple automation scripts — and it's the reason the entire framework is future-proof.
The Problem with Normal Automation
Meta changes their API regularly. New parameters get added, old endpoints get deprecated, field names change, response formats shift. It happens every few months when Meta releases a new API version.
With normal automation (scripts, Zapier, custom code), here's what happens when Meta makes a change:
Normal Automation
The Script Breaks
Your script sends the old API call. Meta returns an error. The script crashes. Your daily reports stop working, your budget optimizer goes offline, your alerts stop firing. You don't notice until something goes wrong with your campaigns.
Normal Automation
You Need a Developer to Fix It
Someone has to read Meta's changelog, figure out what changed, update the code, test it, and deploy. This takes hours or days — and during that time, your campaigns are running blind.
How the Self-Learning Protocol Works
Skills with the Self-Learning Protocol handle API changes completely differently. Here's the flow:
Step 1
Claude Detects the Failure
The API call returns an error (400 Bad Request, deprecated endpoint, unknown parameter). Instead of crashing, Claude recognizes this as a "something changed" signal.
Step 2
Activates Playwright to Read the Docs
Claude opens a browser via Playwright, navigates to Meta's official API documentation (developers.facebook.com), and looks up the endpoint that failed. It reads the current reference page like a developer would.
Step 3
Reads and Understands the Change
Claude parses the documentation, identifies what changed (new parameter format, renamed field, different required values), and understands the new correct way to make the call.
Step 4
Adapts and Retries
Updates the API call with the correct, current parameters and retries. The call succeeds. Your workflow continues without interruption.
Step 5
Saves What It Learned
Stores the new information in its memory (CLAUDE.md) so future runs start with the correct parameters. The same mistake never happens twice. The Skill evolved.
self-learning-protocol.log
Interactive
[1] Calling Meta API: POST /v21.0/act_123/campaigns...
[2] ERROR 400: 'special_ad_categories' format changed in v22.0
[3] Activating Self-Learning Protocol...
[4] Opening developers.facebook.com via Playwright...
[5] Navigating to Campaign API reference...
[6] Found: special_ad_categories now requires array format []
[7] Updating API call with corrected parameters...
[8] Retrying: POST /v22.0/act_123/campaigns...
[9] SUCCESS: Campaign created (ID: 120210456789012345)
[10] Saving learning to CLAUDE.md for future calls
✅ This Is Why We Use Playwright
Playwright isn't just for testing websites — it's the mechanism that makes your entire system self-healing. It gives Claude the ability to open a browser, navigate to documentation, and read what changed. When Meta ships a breaking change tomorrow, your Skills will figure it out on their own.
This is the single biggest advantage over traditional automation. No developer needed. No downtime. No broken workflows. The Skills adapt and keep running.
You Know the Building Blocks
In Part 6, we'll deep-dive into each of the 6 AI Agents — with full interactive demos showing exactly what they do and how they work together.