FREE MIT SKILL · CLAUDE CODE

How to Run an Autonomous Claude Code SEO Fix Loop Overnight

Letting an AI agent edit your website unchecked breaks canonicals, sitemaps, and page layouts. This free MIT skill wraps Claude Code in a deterministic 0 to 100 SEO and AI-search verifier with an automatic git keep-or-revert latch.

BY THE SEO AGENT TEAMUPDATED 2026-12-066 MIN READ
QUICK ANSWER

How do you safely run Claude Code to fix technical SEO and AI search issues overnight?

Put Claude Code on a separate git branch behind a deterministic scorer and build gate. In each round, Claude makes one surgical edit, rebuilds your site, and re-scores all 10 technical SEO and AI-search pillars. The harness commits the edit only if every hard check passes and the score rises; any broken build, sitemap mismatch, or flat edit is reverted automatically before the next round starts.

67.55 -> 99.81VERIFIED SCORE JUMP+32.26 points across 16 live pages on onepagertemplate.com
33 ROUNDS29 KEPT · 4 REVERTED36.5 minutes unattended with zero manual edits
47 -> 0MISSING IMAGE ALTSPlus llms.txt, 8 AI crawlers, JSON-LD, and AEO blocks
COPY-PASTE PROMPT

Paste this into Claude Code inside your site folder

Run the free MIT seo-overnight-loop skill from https://github.com/jeremy665/AI-SEO-Agent/tree/main/skills/seo-overnight-loop on a fresh git branch named seo-overnight-loop.

Site origin: https://yoursite.com
Build command: npm run build
Verify command: npm run check
Built output folder: ./dist

Rules:
1. Score the unmodified baseline first with loop_scorer.py and save baseline.json.
2. Run up to 35 single-hypothesis rounds with run_loop.py.
3. Make ONE surgical edit per round (one sitewide file such as robots.txt, llms.txt, layout head, or JSON-LD helper, or one individual page at a time).
4. KEEP (git commit) only when build + verify pass every hard guardrail and the deterministic score strictly rises.
5. REVERT (git checkout + clean) automatically on any failed check, broken JSON-LD, sitemap mismatch, em dash, or zero-gain edit, saving the diff to reverted-diffs/.
6. Never push or deploy automatically. Write report.md and summary.json so I can review every kept commit and reverted catch in the morning.

Replace https://yoursite.com and your build/check commands before running. Always run on a fresh branch, never directly on main.

INSTALL IN CLAUDE CODE
/plugin marketplace add jeremy665/AI-SEO-Agent
/plugin install seo-aeo-audit@the-seo-agent
RUN VERIFIER & LOOP
git checkout -b seo-overnight-loop
python3 skills/seo-overnight-loop/scripts/run_loop.py \
  --repo . --dist ./dist --origin https://yoursite.com \
  --build-cmd "npm run build" --verify-cmd "npm run check" \
  --out ./seo-loop-run --rounds 35
OPEN-SOURCE MIT SKILL

Zero external dependencies, zero API keys, Python 3 standard library only. Includes loop_scorer.py, run_loop.py, SKILL.md, and passing isolated unit tests.

Open GitHub repo
VERIFIED RUN RESULTS

Before and after on onepagertemplate.com

We ran the exact MIT skill unmodified against our owned 16-page static site onepagertemplate.com on branch seo-overnight-loop (commit 4a5696b to 877b19c). Every round rebuilt the full site, ran the site integrity gate (npm run check), and re-scored all 10 pillars locally and live.

Pillar (max 10.00)BeforeAfterChange
AI Crawler Rules (robots.txt)6.0010.00+4.00
AI Discovery (llms.txt & links)0.0010.00+10.00
Titles, Metas & Freshness Tags8.0010.00+2.00
Canonicals & Sitemap Hygiene10.0010.000.00
Headings & Image Alt Text8.2510.00+1.75
Structured Data (JSON-LD)4.3810.00+5.62
AEO Quotable Answer & Tables4.0610.00+5.94
Content Depth & Clean Copy9.169.81+0.65
Contextual Internal Link Mesh7.7010.00+2.30
Crawl & Build Gate Integrity10.0010.000.00
REAL REGRESSION CAUGHT & REVERTED (ROUND 8 · REVERTED (-3.78))

Claude added related template preview cards to /contact without registering preview image entries in sitemap.xml.

Our build gate failed immediately with: "sitemap.xml: https://onepagertemplate.com/contact/ shows template previews but has no image:image entry". The harness saved round-008.diff, reset git HEAD, and passed the exact error into later rounds. By Round 12, Claude self-corrected by adding inline contextual links without preview cards and passed cleanly.

STEP 01 · THE CORE MECHANISM

Why naive AI SEO agents break sites (and how keep-or-revert fixes it)

Most tutorials tell you to open Claude Code, paste a giant SEO checklist, and tell it to optimize your whole repo in one shot. When you do that on a real website, the model edits twelve files at once, drops a canonical tag, introduces broken JSON-LD syntax, or breaks your sitemap rules. You wake up to a messy diff that takes longer to untangle than doing the fixes yourself.

The fix is to borrow the keep-or-revert pattern from automated research loops. Instead of trusting the model to grade its own work, you separate the editor (Claude Code) from the judge (a deterministic Python scorer plus your site build and test suite).

In each round, Claude receives the current 10-pillar score, the top remaining gaps, and the last six round outcomes including any revert errors. It makes one small, targeted change. The harness rebuilds your site, crawls the built HTML over an ephemeral loopback server, checks every hard guardrail, and accepts the git commit only when every invariant passes and the score strictly goes up.

STEP 02 · TWO-MINUTE SETUP

Install the MIT skill and record your baseline score

Everything in skills/seo-overnight-loop runs on the Python 3 standard library. You do not need paid SEO API keys, browser extensions, or cloud accounts. Install the marketplace plugin inside Claude Code, or clone jeremy665/AI-SEO-Agent directly beside your repository.

Before running a single edit, create a dedicated git branch and run loop_scorer.py against your built output folder (or a local dev server with --url http://127.0.0.1:4321 --allow-local). On our 16-page test site onepagertemplate.com, both the local static build and the live production URL scored an identical 67.55 out of 100.00.

  • AI Discovery started at 0.00 / 10 because /llms.txt, /llms-full.txt, and HTML alternate discovery links were missing (HTTP 404).
  • AI Crawlers started at 6.00 / 10 because robots.txt lacked explicit allow directives for GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, Claude-User, PerplexityBot, and Google-Extended.
  • Headings and Accessibility sat at 8.25 / 10 because 47 of 121 template preview images had empty alt="" attributes.
  • Structured Data (4.38 / 10) and AEO Answer Blocks (4.06 / 10) lacked top-level Organization JSON-LD, SpeakableSpecification, ItemList hub markup, quotable direct-answer blocks, and structured comparison tables on key pages.
  • Internal Linking (7.70 / 10) and Content Depth (9.16 / 10) flagged /contact as a thin 278-word page with only 2 contextual links inside <main>.
STEP 03 · REAL 33-ROUND TRACE

What actually happened across 33 unattended rounds

We launched run_loop.py with a cap of 35 rounds, a 99.80 early-stop target, and one strict rule: one surgical change per round. The entire unattended run took 36.5 minutes and stopped cleanly after Round 33 when the verified score hit 99.81 out of 100.00.

Rounds 1 through 7 tackled sitewide leverage first: /llms.txt (+4.00), explicit 8-bot rules in robots.txt (+4.00), HTML <link rel="alternate"> headers (+3.00), /llms-full.txt (+3.00), top-level Organization and SpeakableSpecification JSON-LD (+4.12), author and modified-time freshness meta tags (+2.00), and wiring data-aeo-answer into the shared page layout (+1.25).

Then the real test hit in Rounds 8 and 10. When Claude tried adding related template cards onto /contact and /about to boost internal links, the strict site check immediately failed because those pages began rendering preview thumbnails without matching <image:image> entries in sitemap.xml. Both commits were automatically reverted (-3.78 and -4.12 drops prevented).

Because the harness feeds recent revert messages straight into the next prompt, Claude adapted on its own in Round 12. Its logged hypothesis literally noted "(no related cards)" and switched to clean inline contextual links, structured key-fact blocks, and visible FAQs across /terms, /privacy, /about, and /contact.

Later in Rounds 17 and 31, the verifier caught two zero-gain edits on /one-pager-layouts where Claude added links to URLs already linked elsewhere in <main>. Because distinct body link count did not improve (delta +0.00), both commits were reverted automatically. In Round 33, Claude added three genuinely distinct contextual links and crossed 99.81.

REAL EXCERPT FROM ROUNDS.JSONL (ROUNDS 8 TO 12)
Round  8 | REVERT | 88.92 -> 85.14 (-3.78) | sitemap.xml missing image:image on /contact/
Round  9 | KEEP   | 88.92 -> 90.42 (+1.50) | Add ItemList JSON-LD on collection pages (c6286fa)
Round 10 | REVERT | 90.42 -> 86.30 (-4.12) | sitemap.xml missing image:image on /about/
Round 11 | KEEP   | 90.42 -> 91.98 (+1.56) | Replace 42 empty Related.astro card alts (fa49269)
Round 12 | KEEP   | 91.98 -> 92.83 (+0.85) | Add AEO answer, dl & FAQs to /terms (no related cards)
STEP 04 · HONEST LIMITS & MORNING REVIEW

Token usage, morning review, and what this loop does not replace

Running 33 autonomous Claude Code rounds is not free in compute or tokens. Across all 33 verbatim stream logs, Claude read 6.94 million cached input tokens, created 845,842 cache tokens, and wrote 66,942 output tokens (roughly US$4.75 in list-rate API equivalent, or covered inside a paid Claude Code subscription). Setting --max-turns 10 and --max-consecutive-reverts 8 keeps a stuck loop from burning usage indefinitely.

Never auto-deploy an overnight branch. In the morning, open report.md, scan git log --oneline main..HEAD, spot-check your live preview in a real browser, and inspect reverted-diffs/ to understand the edge cases your verifier protected. On our run, after checking every unit test and reviewing all 29 kept commits, we deployed to live production and confirmed the live URL scored the exact same 99.81 out of 100.00.

Finally, keep expectations grounded. A technical SEO and AEO loop fixes crawlability, structured data, image accessibility, internal linking, and answer formatting on pages you already have. It does not do live search-volume keyword research, publish 30 source-checked articles a month, or build authority on its own. Treat it as your clean technical foundation, then layer consistent publishing on top.

COMMON QUESTIONS

Questions about this setup.

Missing something? Ask us directly.

Does seo-overnight-loop work on Next.js, Astro, Hugo, or plain HTML sites?

Yes. Pass --dist ./out (or ./dist or ./public) for any static build, or point loop_scorer.py at a local dev/staging server using --url http://127.0.0.1:3000 --allow-local --origin https://yoursite.com.

Can Claude Code break my live production site while I sleep?

No, as long as you keep the defaults intact. run_loop.py refuses to run on main or master, never runs git push, never deploys, and reverts any working-tree change that fails your build command, verify command, or hard SEO guardrails.

Why did the loop stop at 99.81 instead of 100.00 on onepagertemplate.com?

The early-stop threshold was set to 99.80. Nine of the ten pillars reached 10.00, while content_depth finished at 9.81 because two utility pages (/about and /terms) still carried one list instead of two inside main. Stopping once real fixes are done prevents useless churn.

Do I need any paid SEO API keys to run loop_scorer.py?

No. Both loop_scorer.py and run_loop.py use only the Python 3 standard library and inspect your built HTML, robots.txt, llms.txt, XML sitemap, JSON-LD blocks, and internal link graph directly.

How is this different from The SEO Agent web app?

This free MIT skill runs local technical SEO and AEO code fixes inside your repository on demand. The SEO Agent automates the ongoing content side: keyword research from live search data, 30 source-checked articles per month, technical monitoring, and native publishing to WordPress, Shopify, Webflow, Wix, Ghost, Framer, or webhooks.

BEYOND ONE-OFF TECHNICAL FIXES

Want the daily SEO content engine running automatically too?

Use the free MIT skill above to clean up your technical SEO and AI-search foundation. When you are ready for live-data keyword research, 30 source-checked articles a month, and native CMS publishing without babysitting scripts, start with The SEO Agent.

US$1 for 3 days and your first 3 articles, then US$99/month flat. Cancel anytime in the app.