Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(backlinks): confirm a lost link with GET, keep https and www redirects as exists

Agrici Daniel25cf40067a1c
diff --git a/agents/seo-backlinks.md b/agents/seo-backlinks.md
index c981900..c1fba67 100644
--- a/agents/seo-backlinks.md
+++ b/agents/seo-backlinks.md
@@ -20,6 +20,9 @@ You are a backlink profile analyst. When delegated tasks during an SEO audit:
- Common Crawl domain metrics: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run commoncrawl_graph.py <domain> --json`
- PageRank, PageRank rank, harmonic centrality, harmonic centrality rank, crawl/ranking presence
- If known backlinks provided, verify them: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run verify_backlinks.py --target <url> --links <file> --json`
+ - `status`: `verified`, `link_removed`, `unverifiable_js` (JS page, unconfirmed), `lost` (GET confirmed 404/410), `server_error` (5xx, recheck later, not lost), `error` (could not check, read `error`); with `--head-only`: `exists` or `moved` (redirected to another host or path)
+ - `page_nofollow: true` means a page-level robots nofollow: count every link on that page as nofollow, whatever `rel_attributes` says
+ - `redirect_url` is the final URL when the source redirected (`null` otherwise)
- Report domain-level metrics with **confidence: 0.50** note
- At Tier 0, fewer than 4 scoring factors have data, report **INSUFFICIENT DATA**, not a numeric score
- Never produce a misleading numeric score when most factors lack data sources
@@ -80,7 +83,7 @@ Match existing claude-seo patterns:
- Scores as XX/100 with source confidence noted
- Priority: Critical > High > Medium > Low
- Note data source for every metric: "Moz API (confidence: 0.85)" or "Common Crawl (domain-level, confidence: 0.50)"
-- Include source freshness from API responses when available; otherwise label freshness as approximate (Common Crawl web graphs are quarterly; source: https://commoncrawl.org/web-graphs)
+- Include source freshness from API responses when available; otherwise label freshness as approximate (for Common Crawl, cite the `metadata.release` id in the script output, which names the three crawl months it covers, e.g. `cc-main-2026-jul-aug-sep`; the script picks the newest release Common Crawl lists and falls back to a built-in list; source: https://commoncrawl.org/web-graphs)
## Pre-Delivery Review (MANDATORY)
diff --git a/scripts/verify_backlinks.py b/scripts/verify_backlinks.py
index 758f32a..e6eb0f5 100644
--- a/scripts/verify_backlinks.py
+++ b/scripts/verify_backlinks.py
@@ -4,8 +4,24 @@ Backlink verification crawler for Claude SEO.
Verifies whether known backlinks still exist by fetching source pages and
checking if the target URL appears in their outbound links. Uses HTTP HEAD
-for fast existence checks (falling back to GET when a server rejects HEAD) and
-full GET + HTML parsing for link verification.
+for fast existence checks and full GET + HTML parsing for link verification.
+
+A HEAD answer other than 200 never decides the result on its own: servers
+answer HEAD with 404, 405, 410, 501 or 403 for pages that GET serves, so one
+GET through the safe fetcher confirms it. A URL blocked by the URL safety
+layer is reported as an error and never retried.
+
+Status values (per result, counted in data.summary):
+ verified Page fetched and a link to the target was found.
+ link_removed Page fetched, no link to the target in its HTML.
+ unverifiable_js Page looks JS-rendered; the link cannot be confirmed.
+ lost A GET confirmed the source page is gone (HTTP 404 or 410).
+ server_error Source server answered 5xx; not proof the link is gone.
+ exists --head-only: page is reachable. redirect_url is set if it
+ redirected to the same host and path (https or www switch).
+ moved --head-only: page redirects to another host or path.
+ error Not checked: blocked URL, failed request, or the host
+ refused the checker (HTTP 403 or 429). See the error field.
Usage:
python verify_backlinks.py --target https://example.com --links links.json --json
@@ -85,7 +101,13 @@ def _head_check(url: str, timeout: int = 15) -> dict:
except requests.exceptions.Timeout:
return {"status_code": None, "exists": False, "redirect_url": None, "error": "timeout"}
except requests.exceptions.RequestException as e:
- return {"status_code": None, "exists": False, "redirect_url": None, "error": str(e)}
+ result = {"status_code": None, "exists": False, "redirect_url": None, "error": str(e)}
+ # A redirect to a non-public address is refused inside the pinned
+ # resolver and surfaces as a ConnectionError naming url_safety.
+ if "url_safety:" in str(e):
+ result["error"] = f"blocked by SSRF protection: {e}"
+ result["blocked"] = True
+ return result
def _normalize_url(url: str) -> str:
@@ -143,14 +165,30 @@ def _apply_get_status(result: dict, page_data: dict) -> bool:
return False
if page_data.get("redirect_chain"):
result["redirect_url"] = page_data.get("url")
- if result["http_status"] == 404:
+ status = result["http_status"]
+ if status == 200:
+ return True
+ if status in (404, 410):
result["status"] = "lost"
- return False
- if result["http_status"] != 200:
+ elif status in (403, 429):
result["status"] = "error"
- result["error"] = f"HTTP {result['http_status']}"
- return False
- return True
+ result["error"] = f"HTTP {status}: host refused the checker; the page may still exist"
+ elif status is not None and 500 <= status < 600:
+ result["status"] = "server_error"
+ result["error"] = f"HTTP {status}: server failed; not proof the page or link is gone"
+ else:
+ result["status"] = "error"
+ result["error"] = f"HTTP {status}"
+ return False
+
+
+def _is_moved(source_url: str, final_url: str) -> bool:
+ """True if a redirect changed the host or path, not just scheme, www or a trailing slash."""
+ def key(url: str) -> tuple:
+ parsed = urlparse(url)
+ host = (parsed.hostname or "").lower()
+ return host[4:] if host.startswith("www.") else host, parsed.path.rstrip("/")
+ return key(source_url) != key(final_url)
# Lower rank wins when several links on the page point at the target.
@@ -199,30 +237,31 @@ def verify_single_backlink(source_url: str, target_url: str,
head_result = _head_check(source_url, timeout=min(timeout, 15))
result["http_status"] = head_result["status_code"]
+ # A URL the safety layer blocked is never retried with GET.
if head_result.get("blocked"):
result["status"] = "error"
result["error"] = head_result["error"]
return result
- if head_result["status_code"] == 404:
- result["status"] = "lost"
- return result
-
if head_result["exists"]:
result["redirect_url"] = head_result["redirect_url"]
if head_only:
- # Many servers answer HEAD with 403/405 or fail it outright; only a
- # GET can tell whether the page exists.
+ # Only a HEAD 200 is trusted. Servers answer HEAD with 404, 405, 410,
+ # 501 or 403, or fail it outright, for pages that GET serves, so one
+ # GET confirms. Its body is not parsed in this mode.
if not head_result["exists"]:
_polite_delay(source_domain)
if not _apply_get_status(result, fetch_page(source_url, timeout=timeout)):
return result
- result["status"] = "moved" if result["redirect_url"] else "exists"
+ final_url = result["redirect_url"]
+ moved = bool(final_url) and _is_moved(source_url, final_url)
+ result["status"] = "moved" if moved else "exists"
result["target_found"] = None # Unknown without full check
return result
- # Step 2: Full GET + parse
+ # Step 2: Full GET + parse. This GET is also the confirmation for a HEAD
+ # 404, 405, 410 or 501.
_polite_delay(source_domain)
page_data = fetch_page(source_url, timeout=timeout)
@@ -235,7 +274,8 @@ def verify_single_backlink(source_url: str, target_url: str,
return result
# Step 3: Parse HTML and find target link
- parsed = parse_html(page_data["content"], base_url=source_url)
+ # Relative links resolve against the final URL after a redirect.
+ parsed = parse_html(page_data["content"], base_url=page_data.get("url") or source_url)
all_links = parsed.get("links", {})
external_links = all_links.get("external", [])
internal_links = all_links.get("internal", [])
@@ -333,7 +373,8 @@ def verify_backlinks(target_url: str, links: list, head_only: bool = False,
"""
results = []
summary = {"total": 0, "verified": 0, "lost": 0, "moved": 0,
- "link_removed": 0, "unverifiable_js": 0, "exists": 0, "error": 0}
+ "link_removed": 0, "unverifiable_js": 0, "exists": 0,
+ "server_error": 0, "error": 0}
for item in links:
source_url = item.get("source_url", "")
@@ -453,9 +494,10 @@ def main():
print(f"Backlink Verification: {data.get('target_url', args.target)}")
print(f" Total checked: {summary.get('total', 0)}")
print(f" Verified: {summary.get('verified', 0)}")
- print(f" Lost (404): {summary.get('lost', 0)}")
+ print(f" Lost (404/410): {summary.get('lost', 0)}")
print(f" Moved (3xx): {summary.get('moved', 0)}")
print(f" Link removed: {summary.get('link_removed', 0)}")
+ print(f" Server errors: {summary.get('server_error', 0)}")
print(f" Errors: {summary.get('error', 0)}")
if args.head_only:
print(f" Exists (HEAD): {summary.get('exists', 0)}")
diff --git a/skills/seo-backlinks/SKILL.md b/skills/seo-backlinks/SKILL.md
index 4e78022..7f3c93c 100644
--- a/skills/seo-backlinks/SKILL.md
+++ b/skills/seo-backlinks/SKILL.md
@@ -157,6 +157,22 @@ Output:
**Verification Crawler:** For known links, verify current status with `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run verify_backlinks.py --target <url> --links <file> --json`
+Read each result's `status` (add `--head-only` for a fast page-existence check without link parsing):
+
+| `status` | How to interpret it |
+|----------|---------------------|
+| `verified` | Link to the target found on the page. Read `rel_attributes` and `page_nofollow` before calling it followed. |
+| `link_removed` | Page loads but its HTML has no link to the target. |
+| `unverifiable_js` | Page looks JS-rendered; the link may exist. Report as unconfirmed, not removed. |
+| `lost` | Source page is gone: a GET returned 404 or 410. |
+| `server_error` | Source server answered 5xx. Temporary until proven otherwise: recheck later, never report as lost. |
+| `exists` | `--head-only`: page is reachable, link not checked. A `redirect_url` here is only an https or www switch. |
+| `moved` | `--head-only`: page redirects to another host or path (`redirect_url`). Rerun without `--head-only` to see if the link survived. |
+| `error` | Not checked (blocked URL, timeout, or HTTP 403/429 where the host refused the checker). Read `error`; say "could not check", not "lost". |
+
+- `page_nofollow: true`: the page has a robots nofollow (meta robots or `X-Robots-Tag`), so every link on it is nofollow even when `rel_attributes` is `["follow"]`. Count the link as nofollow.
+- `redirect_url`: the final URL when the source redirected, otherwise `null`. The link was checked on that final page; update the stored source URL when `status` is `moved`.
+
**Note:** Free sources cannot track new/lost links over time. If this section is requested without DataForSEO, inform the user: "Link velocity tracking requires the DataForSEO extension. Free sources provide point-in-time snapshots only."
**Red flags:**
diff --git a/skills/seo/references/free-backlink-sources.md b/skills/seo/references/free-backlink-sources.md
index ec148bd..0330715 100644
--- a/skills/seo/references/free-backlink-sources.md
+++ b/skills/seo/references/free-backlink-sources.md
@@ -23,7 +23,7 @@ When merging data from multiple sources, apply confidence weights to each metric
| Verification Crawler | 0.95 | Direct observation (binary: link exists or not) |
| Moz API | 0.85 | Large index (45.5T links), established metrics, 3-day update lag |
| Bing Webmaster | 0.70 | Smaller index (~15% of web), but authoritative for Bing-indexed pages |
-| Common Crawl | 0.50 | Domain-level only, quarterly updates, no anchor text |
+| Common Crawl | 0.50 | Domain-level only, each release covers three crawl months, no anchor text |
**Composite formula:**
```
@@ -74,12 +74,12 @@ a report (`status: FAIL`) that carries a number in either case. See the
### Common Crawl Web Graph (Always Available)
- **Data source:** `s3://commoncrawl/projects/hyperlinkgraph/`
-- **Releases:** Quarterly (e.g., cc-main-2025-18)
+- **Releases:** Each id names the three crawl months it covers (e.g., cc-main-2026-jul-aug-sep). The script reads Common Crawl's `graphinfo.json` and uses the newest release listed, falling back to a built-in list if that cannot be read
- **No auth needed:** Public data, free to download
- **Data:** Domain-level in-degree, PageRank, harmonic centrality, referring domains
- **Command:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run commoncrawl_graph.py`
- **Cache:** `~/.cache/claude-seo/commoncrawl/` (90-day TTL)
-- **Blind spots:** No anchor text, no page-level data, monthly/quarterly freshness,
+- **Blind spots:** No anchor text, no page-level data, freshness limited to the release's crawl months,
domain-level only (e.g., "nytimes.com links to example.com" but not which page)
### Verification Crawler (Always Available)
diff --git a/tests/test_verify_backlinks.py b/tests/test_verify_backlinks.py
index 5f973d9..ff3a371 100644
--- a/tests/test_verify_backlinks.py
+++ b/tests/test_verify_backlinks.py
@@ -26,13 +26,13 @@ class FakeHeadResponse:
self.history = [object()] if redirected else []
-def _page(html, status_code=200, headers=None, url=SOURCE):
+def _page(html, status_code=200, headers=None, url=SOURCE, redirect_chain=None):
return {
"url": url,
"status_code": status_code,
"content": html,
"headers": headers or {},
- "redirect_chain": [],
+ "redirect_chain": redirect_chain or [],
"error": None,
}
@@ -143,7 +143,7 @@ def test_x_robots_tag_date_with_commas_is_not_a_crawler_scope(fake_network):
assert result["page_nofollow"] is True
[email protected]("head_status", [403, 405, 501])
[email protected]("head_status", [403, 404, 405, 410, 501])
def test_head_rejected_falls_back_to_get(fake_network, head_status):
fake_network["head"] = FakeHeadResponse(head_status)
fake_network["page"] = _page(_html('<a href="https://target.example/tool">t</a>'))
@@ -168,13 +168,57 @@ def test_head_ssrf_block_does_not_fall_back_to_get(fake_network):
assert fake_network["get_calls"] == 0
-def test_head_404_is_lost_without_get(fake_network):
- fake_network["head"] = FakeHeadResponse(404)
+def test_head_blocked_redirect_target_does_not_fall_back_to_get(fake_network):
+ fake_network["head"] = verify_backlinks.requests.exceptions.ConnectionError(
+ "Failed to resolve 'internal' (url_safety: refused to resolve 'internal' "
+ "to non-public IP 10.0.0.5)"
+ )
result = verify_backlinks.verify_single_backlink(SOURCE, TARGET)
- assert result["status"] == "lost"
+ assert result["status"] == "error"
+ assert "SSRF" in result["error"]
assert fake_network["get_calls"] == 0
[email protected]("head_only", [False, True])
[email protected]("head_status", [404, 405, 410, 501])
[email protected]("get_status", [404, 410])
+def test_lost_only_after_get_confirms(fake_network, head_status, get_status, head_only):
+ fake_network["head"] = FakeHeadResponse(head_status)
+ fake_network["page"] = _page("Gone", status_code=get_status)
+ result = verify_backlinks.verify_single_backlink(SOURCE, TARGET, head_only=head_only)
+ assert result["status"] == "lost"
+ assert result["http_status"] == get_status
+ assert fake_network["get_calls"] == 1
+
+
[email protected]("head_only", [False, True])
[email protected]("get_status", [500, 503])
+def test_get_5xx_is_server_error_not_lost(fake_network, get_status, head_only):
+ fake_network["head"] = FakeHeadResponse(404)
+ fake_network["page"] = _page("Unavailable", status_code=get_status)
+ result = verify_backlinks.verify_single_backlink(SOURCE, TARGET, head_only=head_only)
+ assert result["status"] == "server_error"
+ assert result["http_status"] == get_status
+ assert str(get_status) in result["error"]
+
+
[email protected]("get_status", [403, 429])
+def test_get_refused_is_error_with_note(fake_network, get_status):
+ fake_network["head"] = FakeHeadResponse(405)
+ fake_network["page"] = _page("Denied", status_code=get_status)
+ result = verify_backlinks.verify_single_backlink(SOURCE, TARGET)
+ assert result["status"] == "error"
+ assert "refused the checker" in result["error"]
+
+
+def test_server_error_is_counted_in_summary(fake_network):
+ fake_network["page"] = _page("Unavailable", status_code=502)
+ summary = verify_backlinks.verify_backlinks(TARGET, [{"source_url": SOURCE}])["data"]["summary"]
+ assert summary["server_error"] == 1
+ assert summary["error"] == 0
+ assert summary["lost"] == 0
+
+
def test_get_fallback_404_is_lost(fake_network):
fake_network["head"] = FakeHeadResponse(405)
fake_network["page"] = _page("Not found", status_code=404)
@@ -200,13 +244,54 @@ def test_head_only_falls_back_to_get_for_existence(fake_network):
assert result["http_status"] == 200
-def test_head_only_redirect_is_moved(fake_network):
- fake_network["head"] = FakeHeadResponse(
- 200, url="https://blog.example.org/new-post", redirected=True
- )
[email protected]("head_status", [404, 405, 410, 501])
+def test_head_only_get_confirms_existence_without_parsing(fake_network, monkeypatch, head_status):
+ def no_parse(*args, **kwargs):
+ raise AssertionError("head-only mode must not parse the body")
+
+ monkeypatch.setattr(verify_backlinks, "parse_html", no_parse)
+ fake_network["head"] = FakeHeadResponse(head_status)
+ fake_network["page"] = _page(_html("hello"))
result = verify_backlinks.verify_single_backlink(SOURCE, TARGET, head_only=True)
+ assert result["status"] == "exists"
+ assert result["http_status"] == 200
+ assert fake_network["get_calls"] == 1
+
+
[email protected]("source, final", [
+ ("https://blog.example.org/post", "https://blog.example.org/new-post"), # path change
+ ("https://blog.example.org/post", "https://news.example.org/post"), # host change
+ ("https://blog.example.org/post", "https://blog.example.net/post"), # host change
+])
+def test_head_only_redirect_to_other_host_or_path_is_moved(fake_network, source, final):
+ fake_network["head"] = FakeHeadResponse(200, url=final, redirected=True)
+ result = verify_backlinks.verify_single_backlink(source, TARGET, head_only=True)
assert result["status"] == "moved"
- assert result["redirect_url"] == "https://blog.example.org/new-post"
+ assert result["redirect_url"] == final
+
+
[email protected]("source, final", [
+ ("http://blog.example.org/post", "https://blog.example.org/post"), # http to https
+ ("https://example.org/post", "https://www.example.org/post"), # add www
+ ("https://www.example.org/post", "https://example.org/post"), # drop www
+ ("http://Example.org/post", "https://WWW.example.org/post/"), # case, trailing slash
+ ("http://example.org", "https://www.example.org/"), # bare host
+])
+def test_head_only_scheme_or_www_redirect_is_exists(fake_network, source, final):
+ fake_network["head"] = FakeHeadResponse(200, url=final, redirected=True)
+ result = verify_backlinks.verify_single_backlink(source, TARGET, head_only=True)
+ assert result["status"] == "exists"
+ assert result["redirect_url"] == final
+
+
+def test_head_only_get_fallback_redirect_uses_same_verdict(fake_network):
+ fake_network["head"] = FakeHeadResponse(405)
+ fake_network["page"] = _page(
+ _html("hello"), url="https://www.blog.example.org/post", redirect_chain=[SOURCE]
+ )
+ result = verify_backlinks.verify_single_backlink(SOURCE, TARGET, head_only=True)
+ assert result["status"] == "exists"
+ assert result["redirect_url"] == "https://www.blog.example.org/post"
def test_head_only_url_normalization_alone_is_not_moved(fake_network):
@@ -223,3 +308,17 @@ def test_full_check_on_redirected_page_reports_redirect_url(fake_network):
result = verify_backlinks.verify_single_backlink(SOURCE, TARGET)
assert result["status"] == "verified"
assert result["redirect_url"] == final
+
+
+def test_relative_link_resolves_against_final_url_after_redirect(fake_network):
+ source = "https://old.example.org/post"
+ final = "https://target.example/blog/post"
+ fake_network["head"] = FakeHeadResponse(200, url=final, redirected=True)
+ fake_network["page"] = _page(
+ _html('<p>Try <a href="/tool">the tool</a>.</p>'), url=final, redirect_chain=[source]
+ )
+ result = verify_backlinks.verify_single_backlink(source, TARGET)
+ assert result["status"] == "verified"
+ assert result["match_type"] == "exact_url"
+ assert result["anchor_text"] == "the tool"
+ assert result["redirect_url"] == final