> Quick Definition, Claude Code SEO loops: A scheduled Claude Code prompt that runs against your site's rank tracker, content inventory, backlink graph, and competitor pages on a fixed cadence, daily, weekly, or on event, and writes its findings to a file or pings a Slack channel. It is the difference between "I ran an SEO audit once" and "an SEO audit runs itself every morning at 6 a.m."
The claude-seo plugin on GitHub has 14,200+ stars. That is a lot of people who downloaded a Claude Code SEO tooling layer. Yet a SERP audit for "claude code seo" returns GitHub READMEs, a StudioHawk manual-use walkthrough, and a LinkedIn post proposing ten loops, no published /loop workflow schedules Claude Code to do SEO on a clock. The Claude Code SEO community has the tool. The pattern is missing. This article is the pattern: a step-by-step /loop setup for Claude Code SEO specifically, with four named loops, real CLAUDE.md and .loop files, cron schedules, token budgets, and error handling.
If you read the hub article on Claude Code Loop Engineering for Modern GTM you already know the ESG Framework (Enable → Schedule → Govern) and the 5 GTM Loop Archetypes. Every loop in this article is a Monitor or Optimize archetype applied to Claude Code SEO. The discipline transfers; the configurations do not. The goal is cost-bounded automation you can ship without learning to code, four loops, four cron entries, one shared persona file.
TL;DR
- The SEO Loop Quartet (Rank Tracker / Freshness Audit / Backlink Monitor / Competitor Diff) is the original framework in this article. Four named loops, four cadences, four alert thresholds, that is the entire SEO loop stack for a small site.
- A daily rank tracking loop costs under $2/month in tokens and replaces a $99/month SaaS rank tracker for sites under 500 tracked keywords. The economics flip above 5,000 keywords, where dedicated crawlers win on cost per check.
- Claude Code /loop is not a Screaming Frog or Ahrefs replacement, it is a scheduler and reasoner that sits on top of their exports. The loop reads the CSV the crawler produces and decides what to do about it.
- Error handling is the part nobody publishes, API drops, ranking data shifts, and stale cache files each need a different retry and suppress strategy. The Error Handling section below is the part the SERP omits.
Why Claude Code SEO needs scheduled AI
SEO has always been a "run an audit, get a PDF, file it, repeat next quarter" discipline. Screaming Frog crawls on demand. Ahrefs alerts you when something breaks. Neither one writes the fix, schedules the rewrite, or revisits the page after the fix ships. The gap between "audit once" and "always optimized" is where rankings quietly bleed.
A scheduled Claude Code prompt closes that gap. The loop runs at 6 a.m., reads yesterday's rank CSV, finds the three pages that dropped, drafts the rewrite briefs, and posts them to your content queue before you open Slack. That is a different workflow than "I will get to it Friday."
The directional data point: SEO teams that move from quarterly audits to daily monitoring report a 20, 40% reduction in time-to-detect ranking drops, per Metaflow's internal SEO operations review. The number is directional, your mileage depends on crawl frequency and how aggressively your competitors publish, but the direction is consistent. Faster detection means cheaper recovery.
Setting up your Claude Code SEO CLAUDE.md
The CLAUDE.md file is the persona and tooling layer every Claude Code SEO loop in this article shares. Without it, each loop re-derives the SEO context from scratch and burns tokens re-reading your site map. With it, every Claude Code SEO loop starts from "you are the SEO agent for site X, here are the data sources, here is the alert format."
Persona for Claude Code SEO
The persona block tells Claude Code who it is for the duration of the loop. Claude Code SEO is a domain where tone and judgment matter, a generic "helpful assistant" persona will produce generic SEO advice. A named Claude Code SEO persona with a defined site and toolset produces specific, on-brand output.
# CLAUDE.md (excerpt)
You are the SEO agent for metaflow.life.
Your job: monitor, audit, and recommend, never ship a change without approval.
Your data sources live in data/seo/, rank CSVs, crawl exports, backlink JSON.
Your alert channel is #seo-alerts on Slack.
Your output format is a markdown brief saved to data/seo/briefs/YYYY-MM-DD-*.md.
Rules:
- Never modify a published page directly. Always draft a brief.
- Cite the source URL for every claim about rankings or backlinks.
- If a data file is older than 48 hours, flag it as stale and skip the run.Tools
The tools block lists the MCP servers and CLI commands the loop is allowed to use. For SEO, the typical stack is a rank tracker CSV export, a crawl export from Screaming Frog or Ahrefs, a backlink JSON from Ahrefs or Semrush, and a fetcher for competitor pages. Claude Code does not need a custom MCP for any of these, it reads the files.
Data sources
The data sources block tells the loop where to find each file and what to do if the file is missing. This is the part that prevents silent failures. If the rank CSV is missing, the loop should not invent rankings, it should post an alert and exit.
Loop #1: Rank tracking monitor
(your first Claude Code SEO loop)
The Rank Tracker loop is the first Claude Code SEO loop most teams ship. It is a Monitor archetype, read-only, daily cadence, alert-only output. The loop reads yesterday's rank CSV, compares it to the day-before, and posts a Slack alert for any keyword that moved more than three positions in either direction.
The .loop file is small:
# .loops/seo-rank-monitor.md
Every day at 06:00:
1. Read data/seo/ranks-YYYY-MM-DD.csv (yesterday's export).
2. Read data/seo/ranks-YYYY-MM-DD-1.csv (the day before).
3. For each keyword, compute the position delta.
4. If |delta| >= 3, append a row to the alert buffer.
5. Post the alert buffer to #seo-alerts. If empty, post "no movement".
6. Save the analysis to data/seo/briefs/YYYY-MM-DD-rank-delta.md.The cron schedule that drives it:
# crontab
0 6 * * * cd /path/to/repo && claude code /loop .loops/seo-rank-monitor.mdThe token cost is small because the loop reads two CSVs and writes one short markdown file. A 500-keyword rank file produces about 8,000 input tokens and 1,500 output tokens per run. At Claude's per-token price, that is under $0.05 per run, or about $1.50/month for a daily loop. The same data on a SaaS rank tracker costs $99/month. Below 500 keywords the loop wins on cost; above 5,000 keywords the SaaS wins because the loop's token cost scales linearly with file size and the SaaS does not.
Loop #2: Content freshness audit
The Freshness Audit loop is a weekly Optimize archetype. It reads your content inventory, scores each page on staleness, and produces a ranked rewrite queue. The loop does not rewrite pages, it produces briefs for a human or a separate Generate loop to pick up.
The staleness score is a simple weighted sum: days since last update, drop in organic traffic over the last 90 days, drop in target keyword position, and presence of broken outbound links. The loop computes the score, sorts the inventory, and writes the top 20 pages to a rewrite queue markdown file.
# .loops/seo-freshness-audit.md
Every Monday at 09:00:
1. Read data/seo/content-inventory.csv (slug, last_updated, traffic_90d, position, broken_links).
2. For each row, compute staleness = days_since_update * 0.4 + traffic_drop_pct * 0.3 + position_drop * 0.2 + broken_links * 10.
3. Sort descending, take top 20.
4. For each top-20 page, draft a rewrite brief: target keyword, current vs. target word count, missing H2s, broken links to fix.
5. Save all briefs to data/seo/briefs/YYYY-MM-DD-freshness-*.md.
6. Post the top-5 queue to #seo-alerts with links to the briefs.The weekly cadence matters. A daily freshness loop produces noise, most pages do not change enough in 24 hours to justify a rewrite brief. A monthly cadence is too slow, a page that lost 30% of its traffic in week one should not wait three more weeks to surface. Weekly is the cadence that matches how content actually decays.
Loop #3: Backlink monitor
The Backlink Monitor loop is a daily Monitor archetype that reads your backlink export (Ahrefs or Semrush JSON) and reports new and lost links. The interesting output is not the raw delta, it is the classification. A new link from a relevant domain is an opportunity to nurture; a lost link from a high-authority domain is an opportunity to reclaim.
The loop classifies each new and lost link into one of four buckets: relevant-new, irrelevant-new, lost-reclaimable, lost-gone. The classification prompt is the part that does the work, a generic "list new and lost backlinks" prompt produces a list nobody acts on. A classification prompt produces a queue.
# .loops/seo-backlink-monitor.md
Every day at 07:00:
1. Read data/seo/backlinks-YYYY-MM-DD.json (today's export).
2. Diff against data/seo/backlinks-YYYY-MM-DD-1.json (yesterday).
3. For each new link: classify as relevant-new or irrelevant-new based on the linking page's title and the target page's topic.
4. For each lost link: classify as lost-reclaimable (the page still exists, the link was removed) or lost-gone (the page 404s).
5. Save the classified report to data/seo/briefs/YYYY-MM-DD-backlinks.md.
6. Post lost-reclaimable links to #seo-alerts with the original linking URL and an outreach draft.The token cost is moderate because backlink JSON files are large, a site with 5,000 backlinks produces a 50,000-token input file. The loop's job is to filter, not to reason extensively, so the output is small. Expect about $0.10 per run, or $3/month for a daily loop.
Loop #4: Competitor content change detection
The Competitor Diff loop is the loop nobody on the SERP has published. It fetches your top three competitors' key pages on a weekly cadence, diffs them against last week's snapshot, and reports what changed. New H2s, new internal links, removed sections, changed title tags, each is a signal that a competitor is testing something.
The loop uses a simple fetch-and-diff pattern. Claude Code fetches the page (or reads a snapshot you fetched with a separate cron), strips the HTML to text, and compares the text to last week's version. The output is a structured change log per competitor per page.
# .loops/seo-competitor-diff.md
Every Friday at 10:00:
1. For each competitor in data/seo/competitors.yaml:
a. Fetch each tracked URL.
b. Strip to text, save to data/seo/competitor-snapshots/{slug}-YYYY-MM-DD.txt.
c. Diff against last week's snapshot.
d. Classify changes: new-H2, removed-H2, title-change, new-internal-link, new-section.
2. Aggregate all changes into a single weekly report.
3. Save to data/seo/briefs/YYYY-MM-DD-competitor-diff.md.
4. Post the top-3 most material changes to #seo-alerts.The token cost is small, three competitors, ten pages each, weekly run, produces about 15,000 input tokens and 2,000 output tokens. Under $0.10 per run, $0.40/month. The value is in the signal: a competitor that adds a new H2 to their pillar page is testing a new sub-topic, and you should know about it before they rank for it.
Layering in the claude-seo plugin
The claude-seo plugin is a 14,200-star Claude Code tooling layer that adds SEO-specific commands, fetch-and-parse, schema validation, SERP fetch, content brief scaffolding. It is not a loop. It is a set of tools your loops can call.
The integration pattern is to install the plugin per its README and then reference its commands in your .loop files. The loop owns the schedule and the judgment; the plugin owns the fetching and parsing. This separation matters because it keeps your loop logic portable, if you swap the plugin for a different tooling layer next year, the loop files do not change.
A typical call site inside a loop file: Use the claude-seo fetch-serp command to pull the top 10 results for the target keyword, then read the resulting JSON. The loop does not re-implement fetching; it composes the plugin's command into its workflow. For a deeper tour of the broader Claude Code marketing skills ecosystem, see Metaflow's Claude Marketing Skills Ultimate Guide.
Token budget & cost calibration
The four Claude Code SEO loops above have very different token profiles, and the only way to ship them safely is to know the monthly cost before you turn the cron on. The table below is a worked example for a mid-size SaaS site with 500 tracked keywords, 200 content pages, 5,000 backlinks, and three competitors on ten pages each. The numbers assume Claude's current per-token price and a single daily or weekly run per loop; multiply accordingly if you run more frequently or against a larger inventory. The point of the table is not the exact dollar figure, it is that the figure is computable before you ship, which is the part of Claude Code SEO loop engineering that most teams skip and then regret when the API bill arrives.
| Loop | Cadence | Input tokens | Output tokens | Cost per run | Monthly cost |
|---|---|---|---|---|---|
| Rank Tracker | Daily | 8,000 | 1,500 | $0.05 | $1.50 |
| Freshness Audit | Weekly | 12,000 | 4,000 | $0.10 | $0.40 |
| Backlink Monitor | Daily | 50,000 | 2,000 | $0.10 | $3.00 |
| Competitor Diff | Weekly | 15,000 | 2,000 | $0.08 | $0.32 |
| Total | — | — | — | — | $5.22/month |
The reading of this table is what matters: the Rank Tracker and Backlink Monitor dominate the monthly cost because they run daily, and the Backlink Monitor's input token count is the single largest line item. If you need to cut cost, the lever is the Backlink Monitor's cadence, moving it from daily to every-other-day cuts the line item in half and loses almost no signal, because backlinks do not change fast enough to justify a daily check for most sites. The Rank Tracker's daily cadence, by contrast, is non-negotiable, rank movement is fast and a daily check is the whole point of the loop.
The total is under $6/month for a four-loop Claude Code SEO stack. The equivalent SaaS stack, a rank tracker, a content audit tool, a backlink monitor, and a competitor watcher, runs $200, $500/month. The Claude Code SEO loop stack wins on cost below the scale where SaaS pricing tiers flatten. Above 5,000 keywords or 50,000 backlinks, the loop's token cost crosses over and the SaaS wins on cost per check. The crossover is real and you should compute it for your site before you commit to Claude Code SEO loops over a SaaS subscription.
The second table below maps each Claude Code SEO loop to its archetype, alert threshold, and the failure mode that matters most for that loop. This is the cheat sheet you keep next to your cron tab.
| Claude Code SEO loop | Archetype | Alert threshold | Failure mode to guard against |
|---|---|---|---|
| Rank Tracker | Monitor | 3-position delta | Single-day data glitch |
| Freshness Audit | Optimize | Top-20 staleness score | Stale content inventory |
| Backlink Monitor | Monitor | New/lost link classified | Missing backlink export |
| Competitor Diff | Monitor | Material change classified | Fetch timeout on competitor page |
The cheat sheet is the thing you tape next to your monitor. Every alert that fires should map to one row on this table, and every row should have a documented failure mode. If an alert fires that does not map, either your threshold is wrong or you have a loop you forgot to document, both are governance failures, not loop failures.
Error handling: API drops and ranking shifts
The SERP omits error handling because error handling does not rank. It is also the part that determines whether your loop runs for a month or quietly dies on day three. Three failure modes matter for SEO loops.
API drops. Your rank tracker export fails, your backlink provider rate-limits you, or your fetcher times out. The loop should detect the missing or empty file, post an alert, and exit without writing a brief. The wrong behavior is to invent rankings or backfill from a stale cache, that produces confident wrong output.
Ranking data shifts. A keyword drops 20 positions overnight. Most of the time this is a data issue, the rank tracker fetched from a different location or a different device class. The loop should not alert on a single-day 20-position drop. It should alert on a three-day moving average drop of more than five positions. This single rule cuts alert noise by about 70% in practice.
Stale cache. A data file is older than 48 hours. The loop should flag the file as stale in the alert and skip the run. The wrong behavior is to run the loop against a stale file and produce a brief that references last week's data as if it were today's.
The pattern across all three is the same: detect, alert, exit. Loops that try to be resilient and keep running through bad data produce confident wrong output, and confident wrong output is worse than no output.
Where This Goes Next
The SEO Loop Quartet (Rank Tracker / Freshness Audit / Backlink Monitor / Competitor Diff) is the asset you carry out of this article. Four named loops, four cadences, four alert thresholds, and one shared CLAUDE.md persona, that is the entire SEO loop stack for a small to mid-size site. The same pattern extends to a Generate archetype loop that picks up the freshness audit's rewrite queue and drafts the new content, but that is a separate article for a separate archetype.
The discipline that compounds is the ESG Framework applied to SEO: Enable the persona and data sources once, Schedule the four loops at their natural cadences, and Govern them with alert thresholds and stale-file checks. Once those four loops run for a month without incident, the second site you add is half the work, the third is a quarter, and by the fifth you are staffing SEO with a loop instead of a person.
Metaflow is built for this motion. The platform ships marketing agents that hold your site's positioning, competitors, and connected accounts as durable context, and pause for approval before anything ships, which is the same boundary the ESG Framework enforces on raw Claude Code. If you want to skip the CLI plumbing and start from a loop that already knows your stack, that is the layer Metaflow adds on top. For the broader Claude Code marketing skills ecosystem, see the Claude Marketing Skills Ultimate Guide; for agency deployment patterns, see Best Claude Code Workflows for Marketing Agencies.
Frequently Asked Questions
Can Claude Code do SEO? Yes. Claude Code reads the same exports your SEO tools produce, rank CSVs, crawl exports, backlink JSON, and reasons over them on a schedule. The SEO Loop Quartet in this article is a four-loop stack that covers rank tracking, content freshness, backlinks, and competitor changes for under $6/month in tokens. It does not replace Screaming Frog or Ahrefs; it sits on top of their exports and decides what to do about them.
How do I use Claude Code for SEO? Start with a CLAUDE.md persona that names your site, lists your data sources, and defines your alert format. Then ship the Rank Tracker loop first, it is read-only, daily, and the safest first loop. Add the Freshness, Backlink, and Competitor Diff loops over the following weeks. Metaflow's marketing agents ship with the persona pre-configured if you want to skip the CLI plumbing.
How is Claude Code loop SEO different from Screaming Frog or Ahrefs scheduled crawls? Screaming Frog and Ahrefs crawl and export. A Claude Code loop reads those exports, classifies the findings, drafts the rewrite briefs, and posts the alerts. The loop is a scheduler and reasoner on top of the crawler, not a replacement for it. The economics flip around 5,000 keywords, below that, the loop wins on cost; above that, the SaaS wins on cost per check.
Can Claude Code track keyword rankings automatically? Yes. The Rank Tracker loop reads yesterday's rank CSV, computes the delta against the day before, and posts a Slack alert for any keyword that moved more than three positions. The loop does not fetch rankings itself, it reads the export your rank tracker produces, but it automates the analysis and alerting that a human would otherwise do every morning.
Sources
- GitHub, claude-seo plugin, 14,200-star Claude Code SEO tooling layer
- Claude Code official docs on scheduled tasks,
/loopcommand reference - Addy Osmani, Loop Engineering, origin of the loop engineering concept
- Metaflow, Claude Code Loop Engineering for Modern GTM, hub article for this cluster
- Metaflow, Claude Marketing Skills Ultimate Guide, broader Claude Code marketing skills ecosystem
- Metaflow, Claude Skills for SEO, companion SEO skills article
- Metaflow, Best Claude Code Workflows for Marketing Agencies, agency deployment patterns
- Metaflow, Claude Code Loop for Google Ads, sibling spoke in the cluster
- Metaflow, Claude Code Loop for LinkedIn, sibling spoke in the cluster





