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 provide reusable context and output formats, but model behavior remains probabilistic. Keep decision policy and write controls in deterministic, tested services; validate every material output.

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
Compatibility & Failure Protocol
What to do when a dependency changes: stop writes, preserve diagnostics, consult the pinned official reference and changelog, create a reviewed code/config change, run contract tests and evals in a test account, then canary with approval and rollback. Never mutate a schema or retry a production write from model output.
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
Which secret references and non-secret IDs the server-side executor needs. Use tenant-scoped, least-privilege credentials from a managed secret store in production; never expose them to the prompt, browser, logs, or client. A permission-restricted ignored .env is for local development only.
08
Example Usage
Sample commands showing how to invoke the Skill and reference a versioned account policy. Example: /optimize-budgets period=last-7-days policy=account-123-v4. Keep thresholds and execution authority outside the prompt.
anatomy-of-a-skill.md
Interactive
--- name: check-performance
description: Pull Meta campaign metrics and flag anomalies
The ID card
---
# Check Performance The title
## Purpose What it does
## When to Use What triggers it
## Compatibility & Failure Protocol How it fails closed
## Instructions The actual steps
## Environment Variables Tokens & IDs
## Example Usage Sample 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 draft typed
budget change-sets; the Skill cannot apply them.

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
Evaluate Each Campaign in Context
Summarize reported performance with contribution margin, incrementality, attribution and conversion lag, sample size, objective, delivery, and account history. The table below is a fictional display example, not decision logic.
Step 4
Calculate Recommended Budgets
Draft an account-specific canary range using contribution margin, incrementality, lag, sample size, objective, cash flow, and history. Show assumptions and uncertainty; no percentage or amount is universally safe.
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
Issue a Structured Change Request
The Skill cannot authorize a write. It outputs entity IDs, before/after values, evidence, attribution window, cap, expiry, stop condition, and rollback. A separate service verifies a signed approval for that exact diff plus tenant scope, current state, spend limit, and idempotency.

The Categorization Table

This fictional table illustrates formatting only. It is not a reusable decision matrix: thresholds depend on contribution margin, incrementality, attribution lag, sample size, objective, cash flow, and account history.

ROAS Category Illustrative proposal
> 3x Scale Investigate; consider a capped canary
2-3x Maintain Review against account-specific guardrails
1-2x Reduce Investigate causes and contribution margin
< 1x Pause Propose a reversible hold if evidence supports it
💡 Key Insight

A prompt that says “ask first” is not a security boundary. The skill proposes; a deterministic, tenant-scoped executor enforces PAUSED state, account and entity allowlists, spend caps, idempotency, exact approvals, audit logs, monitoring, and rollback.

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
Submit a typed request to a controlled executor. The service validates the pinned official contract, tenant/account allowlist, objective, special-ad-category requirements, spend cap, idempotency key, and exact approval, and it hard-codes PAUSED for every created entity.
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
The Service Enforces PAUSED
Do not rely on skill text. The executor rejects ACTIVE creation, out-of-scope accounts, unapproved spend, stale approvals, duplicates, and partial retries. Activation is a separate privileged action with a new exact approval and an audit record.

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
Propose account-specific budget canaries using contribution margin, incrementality, lag, sample size, and platform diagnostics. No percentage is universally safe; a service enforces the approved cap, stop condition, idempotency, and rollback.
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
Evaluate Account-Specific Stop Conditions
ROAS and three days alone cannot label a campaign “bad.” Check contribution margin, attribution and conversion lag, sample size, incrementality, objective, and recent changes; then propose a reversible hold if the account's approved policy supports it.
03
Evaluate Account-Specific Canary Criteria
A high reported ROAS does not prove incremental capacity. Only propose a capped canary after margin, lag, attribution, sample size, delivery, and account-history checks; require a holdout, exact approval, stop condition, and rollback.
04
Evaluate Frequency Against the Account Baseline
Frequency alone does not prove fatigue and “3” is not universal. Compare audience, objective, placement, reach, response, creative, time window, and account history; then propose a reversible creative test if corroborated.
05
Run /optimize-budgets to Reallocate
Based on the evidence, draft a reallocation change-set with entity IDs, before/after values, uncertainty, cap, expiry, stop condition, and rollback. A separate service validates exact approval and deterministic controls before any write.
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
At the Predefined Readiness Gate: Evaluate, Canary, or Stop
A fixed seven-day rule is not a learning guarantee. Evaluate minimum conversions, uncertainty, lag, incrementality, contribution margin, and operational capacity. Propose one capped reversible change; the owner approves the exact diff and rollback.
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.” Specify authorized source, tenant/account, period, attribution setting, freshness, required fields, minimum sample, and the versioned account policy. Explicitness improves repeatability but does not replace validation.
Step 3
Add Decision Points
Separate observation, investigation, proposal, approval, and execution. Decision criteria must be account-specific and include margin, incrementality, lag, sample size, objective, and history. Keep deterministic enforcement—PAUSED, caps, allowlists, idempotency, approvals, audit, rollback—outside the Skill.
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
Define versioned, account-specific review criteria using contribution margin, incrementality, attribution lag, sample size, objective, cash flow, and history—not ROAS alone. Separate alert criteria from action policy, and enforce caps, PAUSED state, approvals, idempotency, and rollback in code.
Step 6
Save as a .SKILL.md File
Use the template structure from Section 1, including a Compatibility & Failure Protocol and explicit output schema. Treat the file as instructions, not enforcement; wire every write through the deterministic policy service.
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 Controlled Compatibility Protocol

Skills and API integrations can go stale. Safety comes from detecting drift, stopping writes, and shipping reviewed, tested, reversible changes—not from letting a model repair production calls.

The Problem with Normal Automation

Meta changes its API regularly. Pin a supported version in reviewed code; as of this lesson's August 2026 review, the examples target Graph API v26.0. Verify support and breaking changes in Meta's official v26.0 changelog before implementation.

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 Controlled Compatibility Works

Use a pinned official API version and a fail-closed release flow:

Step 1
Stop Writes and Preserve Evidence
On a contract, permission, validation, or unknown error, the executor stops. Record the request ID, pinned version, redacted payload, response, and tenant context. Do not retry a non-idempotent write.
Step 2
Review Pinned Official Sources
A maintainer checks the official reference and changelog for the pinned version. Browser output is untrusted evidence; it cannot authorize a schema, credential, or behavior change.
Step 3
Create a Reviewed Change
Update version-controlled code, typed schemas, or configuration. Require human review and keep the previous known-good build and contract available for rollback.
Step 4
Run Evals and Contract Tests
Test fixtures, permissions, duplicates, partial failures, spend limits, PAUSED enforcement, idempotency, approval expiry, audit logging, and rollback in a test account. The model does not mutate the production schema.
Step 5
Canary, Observe, and Roll Back
Release a small approved canary with tenant-scoped credentials and deterministic controls. Monitor predefined signals and roll back automatically on a breached guardrail. Reviewed code/config—not model memory—is the source of truth.
controlled-compatibility.log
Interactive
[1] Calling pinned Meta API v26.0 through controlled executor...
[2] ERROR: response failed the pinned contract
[3] WRITE BLOCKED: incident + redacted evidence recorded
[4] Maintainer reviews pinned official reference + changelog
[5] Version-controlled contract change opened for review
[6] Offline eval fixtures and test-account contract tests running
[7] PAUSED, cap, idempotency, approval, and rollback checks passed
[8] Canary release awaits named approver
[9] No automatic production retry performed
[10] Reviewed code/config remains the source of truth
✅ Maintenance Is a Release Process

Playwright can help a maintainer inspect official documentation, but it does not make a system self-healing. Retrieved content may be stale, malicious, or misunderstood; writes remain stopped until reviewed code passes evals and contract tests.

Expect engineering review and possible downtime for the affected write path. Use test accounts, canaries, observability, and rollback to restore service safely.

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.

Built by @itsmazinzaki — AVAMARTECH

Framework v1.0 — April 2026