AI coding agents

How to run a technical SEO audit with Claude Code (without trusting it blindly)

To run a technical SEO audit with Claude Code, crawl the site with a script you control, start Claude Code in plan mode so it cannot edit files, and have it turn the crawl data into findings that each cite the URL, the raw evidence, and the source file responsible. Then approve fixes on a git branch, review the diff, re-crawl to confirm, and check indexing in Search Console, which the agent cannot see.

What can Claude Code actually check in a technical SEO audit?

An AI coding agent is good at two things an audit needs: reading every file in a project without getting bored, and tracing a symptom on a URL back to the template, config, or redirect rule that causes it. It is bad at a third thing: knowing facts it has no data for. Ask it whether a page is indexed and it will guess. So before you start, be clear about which layer of the site each check lives in, and what the agent can reach.

LayerWhat it tells youCan Claude Code see it?
Source files (templates, config, redirects file)Why a problem exists and where to fix itYes, directly
Served HTML and headers (what a crawler gets)Status codes, redirects, robots rules, canonicals, titlesYes, if you give it a crawl to read
Rendered page (after JavaScript runs)Content and links that only exist after scriptsOnly with a headless browser; otherwise no
Google's view (Search Console)Whether URLs are indexed, which canonical Google choseNo. You check this yourself

Layers from Google's JavaScript SEO basics: Google crawls, renders, then indexes, and uses the rendered HTML to index the page.

The workflow below keeps each layer honest. A script you control produces the served-HTML data. The agent reads that data plus your source and proposes findings. You confirm the last layer in Search Console. Most guides that rank for this search skip the first step and let the agent fetch pages ad hoc, which makes its findings hard to reproduce and easy to invent.

Step 1: Make the audit pass read-only

An audit should change nothing. Claude Code has a mode built for this. Its permission modes documentation says plan mode lets Claude read files and run read-only shell commands to explore, but it does not edit your source until you approve a plan. Start a session in it from your project folder:

git switch -c seo-audit
claude --permission-mode plan

You can also press Shift+Tab inside a session to cycle into plan mode, or prefix a single prompt with /plan. Working on a branch means every later fix lands as a reviewable diff, not a surprise on main.

Add project permission rules

Plan mode covers editing. Permission rules cover everything else. Put this in .claude/settings.json so it applies to anyone who audits this repo:

{
  "permissions": {
    "allow": [
      "Bash(python3 crawl.py *)",
      "Bash(python3 triage.py)"
    ],
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./secrets/**)",
      "Bash(git push *)"
    ]
  }
}

Two details from the permissions documentation matter here. Rules are evaluated deny first, then ask, then allow, and the first match wins, so a deny always beats a broader allow. And a Read deny rule only stops the Read tool. It does not stop a shell command such as grep -r that opens files without naming them, so keep real secrets out of the project folder rather than relying on a rule. The docs also warn that Bash rules which try to limit command arguments, such as allowing curl only for one domain, are fragile. Do not try to fence the network that way. That is another reason to run the crawl yourself.

Step 2: Crawl the site with a script you control

Give the agent data, not a browser and a hunch. This script uses only the Python standard library. It starts at one URL, follows links on the same host, honors robots.txt, follows redirects by hand so it can count hops, and writes one CSV row per URL with the page that first linked to it. That last column is what turns "a 404 exists" into "this page links to it".

#!/usr/bin/env python3
"""Small same-site crawler for audits. Standard library only.
Usage: python3 crawl.py https://example.com/ [max_pages]
Writes crawl.csv: one row per URL, with the page that first linked to it."""
import csv, sys, time, urllib.error, urllib.request, urllib.robotparser
from html.parser import HTMLParser
from urllib.parse import urljoin, urldefrag, urlparse

START = sys.argv[1]
LIMIT = int(sys.argv[2]) if len(sys.argv) > 2 else 500
HOST = urlparse(START).netloc
UA = "site-audit-script/1.0"

class Page(HTMLParser):
    def __init__(self):
        super().__init__()
        self.links, self.title, self.robots, self.canonical = [], "", "", ""
        self._in_title = False
    def handle_starttag(self, tag, attrs):
        a = dict(attrs)
        if tag == "a" and a.get("href"):
            self.links.append(a["href"])
        elif tag == "title":
            self._in_title = True
        elif tag == "meta" and (a.get("name") or "").lower() == "robots":
            self.robots = a.get("content") or ""
        elif tag == "link" and "canonical" in (a.get("rel") or "").lower().split():
            self.canonical = a.get("href") or ""
    def handle_endtag(self, tag):
        if tag == "title":
            self._in_title = False
    def handle_data(self, data):
        if self._in_title:
            self.title += data.strip()

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, *args):
        return None  # return 3xx responses as errors so hops can be counted

opener = urllib.request.build_opener(NoRedirect)

def fetch(url):
    """Follow redirects by hand. Returns status, hops, final URL, headers, body."""
    hops = 0
    while True:
        req = urllib.request.Request(url, headers={"User-Agent": UA})
        try:
            r = opener.open(req, timeout=15)
            return r.status, hops, url, r.headers, r.read(2_000_000)
        except urllib.error.HTTPError as e:
            if e.code in (301, 302, 303, 307, 308) and hops < 10:
                url, hops = urljoin(url, e.headers.get("Location", "")), hops + 1
                continue
            return e.code, hops, url, e.headers, b""
        except (urllib.error.URLError, TimeoutError) as e:
            return f"error: {e}", hops, url, {}, b""

robots = urllib.robotparser.RobotFileParser(urljoin(START, "/robots.txt"))
try:
    robots.read()
except Exception:
    robots = None

queue, seen, rows = [(START, "")], {START}, []
while queue and len(rows) < LIMIT:
    url, ref = queue.pop(0)
    if robots and not robots.can_fetch(UA, url):
        rows.append([url, "blocked by robots.txt", 0, url, "", "", "", "", ref])
        continue
    status, hops, final, headers, body = fetch(url)
    p = Page()
    if "html" in (headers.get("Content-Type", "") if headers else ""):
        p.feed(body.decode("utf-8", "replace"))
    rows.append([url, status, hops, final, p.title, p.robots,
                 headers.get("X-Robots-Tag", "") if headers else "",
                 p.canonical, ref])
    if urlparse(final).netloc != HOST:
        continue  # redirected off-site: record it, do not crawl it
    for href in p.links:
        link = urldefrag(urljoin(final, href))[0]
        if urlparse(link).netloc == HOST and link not in seen:
            seen.add(link)
            queue.append((link, url))
    time.sleep(0.5)  # be polite, even to your own server

with open("crawl.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["url", "status", "hops", "final_url", "title", "meta_robots",
                "x_robots_tag", "canonical", "first_linked_from"])
    w.writerows(rows)
print(f"{len(rows)} URLs written to crawl.csv")

Save it as crawl.py in the project root and run it against a local build or the live site:

python3 -m http.server 8765 --directory dist &
python3 crawl.py http://localhost:8765/ 500

Both scripts in this article were run against a static build seeded with a broken link, a slashless URL that redirects, a noindex page, a robots.txt disallow, and a duplicate title. The crawl caught all five. Crawling a local build first is faster and catches template mistakes before they ship. Crawl the live URL afterward, because hosts add redirects and headers (an X-Robots-Tag on a preview domain, for example) that never appear in your files.

Know what this crawl misses

It does not run JavaScript. Google's JavaScript SEO basics say Google can only discover links that are <a> elements with an href attribute, and that an app shell's initial HTML may contain none of the real content. If your site renders content client side and the crawl finds only the home page, that is itself a finding. Confirm the rendered version with the URL Inspection tool instead of trusting either the script or the agent.

Step 3: Triage the crawl before the agent reads it

A few hundred CSV rows is noise. This second script prints only the rows that need a human or the agent to look: non-200 status codes (including robots blocks), any redirect hops, any noindex in the meta tag or the header, and titles used on more than one page.

#!/usr/bin/env python3
"""Read crawl.csv and print only the rows that need a look."""
import csv
from collections import Counter

rows = list(csv.DictReader(open("crawl.csv")))
for r in rows:
    flags = []
    if r["status"] != "200":
        flags.append("status " + r["status"])
    if r["hops"] != "0":
        flags.append(r["hops"] + " redirect hop(s) to " + r["final_url"])
    if "noindex" in (r["meta_robots"] + r["x_robots_tag"]).lower():
        flags.append("noindex")
    if flags:
        print(r["url"], "|", ", ".join(flags), "| linked from", r["first_linked_from"] or "start")

titles = Counter(r["title"] for r in rows if r["title"] and r["hops"] == "0")
for title, n in titles.items():
    if n > 1:
        print(f"duplicate title on {n} pages: {title}")

On our test build the output looked like this:

http://localhost:8765/privacy/ | status blocked by robots.txt | linked from http://localhost:8765/
http://localhost:8765/test.html | noindex | linked from http://localhost:8765/
http://localhost:8765/missing-page/ | status 404 | linked from http://localhost:8765/test.html
http://localhost:8765/blog | 1 redirect hop(s) to http://localhost:8765/blog/ | linked from http://localhost:8765/test.html
duplicate title on 2 pages: Blog | Example

Titles are only counted on URLs that did not redirect, so a slashless URL and its target are not reported as duplicates of each other. Every line here is deterministic. Run it twice and you get the same output, which is the property you want under anything an AI will reason about.

How do you stop Claude Code from inventing SEO findings?

Require evidence for every finding and tell the agent what to do when it has none. In the plan mode session, paste a prompt like this:

Read crawl.csv and the output of `python3 triage.py`.
For every issue, give me a finding with four parts:
1. The URL.
2. Evidence: the exact crawl.csv row or command output, copied, not paraphrased.
3. The source file and line in this repo that produces it.
4. The smallest fix, and what else that file affects.
Group findings as Blockers (status errors, noindex, robots blocks),
Search appearance (duplicate titles, canonicals, redirects), then Other.
If you cannot point to evidence for something, do not report it.
List anything you could not check under "Not checked".

The evidence rule does most of the work. A real finding comes with a row you can open in crawl.csv. An invented one ("your site may have thin content issues") has nothing to paste, so it either disappears or lands under Not checked, which is where it belongs. The source file column is where the agent earns its keep: a duplicate title on 40 article pages is usually one line in one layout file, and a slashless link that redirects is usually one hard-coded href in a nav partial.

Spot-check the three most serious findings yourself before approving anything. Open the URL, view the source, and confirm the evidence matches. If one finding is wrong, distrust the batch and ask the agent to re-derive it from the CSV.

Watch the JavaScript traps

Two Google rules catch agents that only read source. A noindex in the original HTML cannot be reliably removed by JavaScript later, because Google may skip rendering once it sees noindex. And Google advises against using JavaScript to change the canonical URL to anything other than the one in the original HTML. If the agent proposes fixing either in client-side code, the fix belongs in the server-rendered template instead.

How do you review and apply the fixes safely?

When the plan looks right, approve it and choose to approve edits manually, so each change still needs your yes. Then give it a narrow follow-up:

Save the findings to audit.md exactly as planned.
Then fix only the Blockers group. One commit per finding,
message starting with the finding's URL. Do not touch
anything outside the files named in the findings.

Fix one group at a time, in the same order the findings were grouped. Blockers first, because a perfect title on a page that returns 404 is worth nothing. Before you merge, read the diff and re-run the crawl:

git diff main --stat
python3 crawl.py http://localhost:8765/ 500 && python3 triage.py

A fix is done when its line is gone from the triage output and no new line has appeared. If a new line appears, the fix broke something else, often a redirect rule that now catches more URLs than intended. Keep the old crawl.csv as crawl-before.csv and you can diff the two files to see exactly what moved.

If you would rather not maintain these scripts, CrawlKind packages the same loop as a Claude Code kit: a crawl, a findings report with evidence for each item, and proposed fixes you approve before anything changes. The sample audit shows the report format, and the setup guide covers running it.

What still has to be checked in Search Console?

Anything about Google's own state. The agent and the crawl can prove what your server sends. Only Search Console can show what Google did with it. After the fixes deploy:

  1. Run the URL Inspection tool on each URL that had a blocker. Use the live test to confirm Google now gets a 200 and no noindex.
  2. Check that the canonical Google selected matches the one you declared. If it does not, look for duplicate URLs your crawl found, such as both slash and slashless versions returning 200.
  3. For JavaScript-rendered pages, compare the rendered HTML in URL Inspection against what you expect. Google's guide to fixing JavaScript search problems recommends this tool or the Rich Results Test to check that the rendered HTML has all the content you expect.
  4. Request indexing for fixed key pages, then give it time. Search Console reports update on Google's schedule, not yours, and a fix rarely shows up the same day.

Feed what you find back into the session as text. Pasting "URL Inspection says Google chose /blog as canonical, not /blog/" gives the agent a fact to trace instead of a guess to make. For the order to work through the rest of a site, the small site audit checklist ranks every check by impact, and the requirements page lists what you need installed.

Sources

Frequently asked questions

Can Claude Code do a full SEO audit by itself?

It can do the technical part well when you give it crawl data and your source code: status codes, redirects, robots rules, canonicals, titles, and where each one comes from in the project. It cannot see indexing status, the canonical Google chose, or real user performance data. Those come from Search Console and PageSpeed Insights.

Do I need Screaming Frog or Semrush to audit with Claude Code?

No. For a small or medium site, a standard library Python crawl like the one in this article covers status codes, redirect hops, noindex, canonicals and duplicate titles. Paid crawlers add JavaScript rendering at scale, scheduling and reporting, which matter more on large sites or for client deliverables.

Should I crawl the local build or the live site?

Both, in that order. The local build catches template and link mistakes before they ship and is fast to re-run after each fix. The live site catches what the host adds, such as redirects, response headers, and an X-Robots-Tag on preview domains, none of which exist in your project files.

Is plan mode enough to stop Claude Code changing my site?

Plan mode blocks edits to your source until you approve a plan, and it is the right default for the audit pass. Pair it with a git branch so approved fixes stay reviewable, and with deny rules for anything sensitive. Do not keep secrets in the project folder, since a Read deny rule does not stop shell commands like grep.

How do I know a finding from the agent is real?

Require every finding to quote its evidence: the crawl.csv row or command output, plus the source file and line. Then open the URL and the file yourself for the most serious few. A finding with no pasteable evidence should be treated as unchecked, not as a problem to fix.

Audit your site with your AI coding agent

CrawlKind is a website audit and fix kit for Claude Code: a full crawl, a prioritized findings report, and proposed fixes you review before anything changes. $49 once.

See a sample audit

Checkout isn't open yet.

CrawlKind is being finished and tested before it goes on sale at $49, paid once. Nothing is charged today. Leave an email if you want one message when the kit ships. No newsletter, no follow-ups.

That email doesn't look right. Check for typos.One email when CrawlKind is available. Nothing else.

Saved. You'll get one email when the kit is ready.

Kevin Glover

@gloverbuilds

I ship small products in public. Building toward $1M with SideRoad.

● Built by @gloverbuilds