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: close the crash shapes and robots edge cases the verification pass found
Agrici Daniel9849dc7e2ec5
diff --git a/scripts/agentic_check.py b/scripts/agentic_check.pyindex 009cdd4..5961cdf 100644--- a/scripts/agentic_check.py+++ b/scripts/agentic_check.py@@ -188,6 +188,21 @@ def _check(cid, title, priority, status, standard, evidence=None, fix=None) -> d# --------------------------------------------------------------------------- robots.txt+_LINE_BREAK = re.compile(r"\r\n|\n|\r")+++def robots_lines(text: str) -> list:+ """Split robots.txt on CR, LF or CRLF only (RFC 9309).++ ``str.splitlines`` also breaks on U+2028 and other Unicode separators, which+ would turn text inside a comment into a live rule.+ """+ lines = _LINE_BREAK.split(text.lstrip("\ufeff"))+ if lines and lines[-1] == "" and _LINE_BREAK.search(text[-2:] if text else ""):+ lines.pop()+ return lines++def parse_robots(text: str) -> dict:"""Parse robots.txt into RFC 9309 groups plus global lines.@@ -198,7 +213,7 @@ def parse_robots(text: str) -> dict:global_lines = {"sitemap": [], "agentmap": [], "orphan_content_signal": []}current = Nonelast_was_ua = False- for raw in text.lstrip("\ufeff").splitlines():+ for raw in robots_lines(text):line = raw.split("#", 1)[0].strip()if not line or ":" not in line:continuediff --git a/scripts/agentic_fix.py b/scripts/agentic_fix.pyindex a5b6531..ab2f212 100644--- a/scripts/agentic_fix.py+++ b/scripts/agentic_fix.py@@ -45,7 +45,12 @@ from urllib.parse import urljoin, urlparse_SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))if _SCRIPTS_DIR not in sys.path:sys.path.insert(0, _SCRIPTS_DIR)-from agentic_check import fetch, parse_content_signal, validate_ai_catalog # noqa: E402+from agentic_check import ( # noqa: E402+ fetch,+ parse_content_signal,+ robots_lines,+ validate_ai_catalog,+)DEFAULT_SIGNAL = "search=yes, ai-input=yes, ai-train=no"SLUG = re.compile(r"[^a-z0-9]+")@@ -68,7 +73,7 @@ def add_content_signal(robots_text: str, signal: str) -> dict:raise ValueError("invalid signal: " + "; ".join(parsed["issues"]))robots_text = robots_text.lstrip("\ufeff")newline = "\r\n" if "\r\n" in robots_text else "\n"- lines = robots_text.splitlines()+ lines = robots_lines(robots_text)# Pass 1: find groups as (index of last user-agent line, agents, has_signal).groups, current, in_ua_block = [], None, False@@ -110,8 +115,15 @@ def add_content_signal(robots_text: str, signal: str) -> dict:def _field(line: str) -> str:+ """Lower-cased field name; "" for blank or comment lines.++ A line with a colon but no name (': junk') is a non-user-agent field, as in+ agentic_check.parse_robots, so it ends a user-agent block.+ """body = line.lstrip("\ufeff").split("#", 1)[0]- return body.split(":", 1)[0].strip().lower() if ":" in body else ""+ if ":" not in body:+ return ""+ return body.split(":", 1)[0].strip().lower() or "(unnamed)"# --------------------------------------------------------------------------- llms.txtdiff --git a/scripts/keywordseverywhere_api.py b/scripts/keywordseverywhere_api.pyindex 675cc86..eb0e9b9 100644--- a/scripts/keywordseverywhere_api.py+++ b/scripts/keywordseverywhere_api.py@@ -130,7 +130,7 @@ def get_rank(domains: list, api_key: str) -> dict:err_body = response.json()err = err_body.get("error") if isinstance(err_body, dict) else Noneerr_msg = (err.get("message") if isinstance(err, dict) else err) or "no error message"- except ValueError:+ except (ValueError, RecursionError):# Never echo an HTML error page; the status code says enough.err_msg = "no JSON error body"# Never echo the key back through an upstream error body.@@ -151,7 +151,7 @@ def get_rank(domains: list, api_key: str) -> dict:}try:body = response.json()- except ValueError:+ except (ValueError, RecursionError):return {"status": "error","data": None,diff --git a/scripts/lighthouse_agentic.py b/scripts/lighthouse_agentic.pyindex 4b66cd5..843df64 100644--- a/scripts/lighthouse_agentic.py+++ b/scripts/lighthouse_agentic.py@@ -311,10 +311,17 @@ def extract_lhr(data: dict) -> dict:return {}audits = lhr.get("audits")categories = lhr.get("categories")+ clean_categories = {}+ for cid, cat in (categories or {}).items() if isinstance(categories, dict) else []:+ if not isinstance(cat, dict):+ continue+ refs = cat.get("auditRefs")+ clean_categories[cid] = {**cat, "auditRefs": [r for r in refs if isinstance(r, dict)]+ if isinstance(refs, list) else []}return {**lhr,"audits": {k: v for k, v in (audits or {}).items() if isinstance(v, dict)}if isinstance(audits, dict) else {},- "categories": categories if isinstance(categories, dict) else {}}+ "categories": clean_categories}def run_psi(url: str, strategy: str, api_key: Optional[str], timeout: int = 180) -> dict:@@ -334,15 +341,19 @@ def run_psi(url: str, strategy: str, api_key: Optional[str], timeout: int = 180)try:body = resp.json()error = body.get("error") if isinstance(body, dict) else None- message = error.get("message", "") if isinstance(error, dict) else str(body)- except ValueError:+ message = error.get("message", "") if isinstance(error, dict) else str(body)[:300]+ except (ValueError, RecursionError):message = resp.text[:300]hint = ""if resp.status_code == 429 or "Quota" in message:hint = " Configure a Google API key (see /seo google setup)."raise RuntimeError(redact_google_api_key(f"PSI returned HTTP {resp.status_code}: {message[:300]}{hint}"))- return extract_lhr(resp.json())+ try:+ data = resp.json()+ except (ValueError, RecursionError):+ raise RuntimeError("PSI returned a body that is not usable JSON.") from None+ return extract_lhr(data)def _print_text(report: dict) -> None:diff --git a/scripts/ucp_check.py b/scripts/ucp_check.pyindex e386dd3..eedd3c6 100644--- a/scripts/ucp_check.py+++ b/scripts/ucp_check.py@@ -140,7 +140,8 @@ def parse_profile(payload: str) -> dict:entry = {"id": name, "version": variant.get("version"),"transport": variant.get("transport"),"endpoint": variant.get("endpoint"), "issues": []}- if variant.get("transport") not in UCP_TRANSPORTS:+ transport = variant.get("transport")+ if not isinstance(transport, str) or transport not in UCP_TRANSPORTS:entry["issues"].append("unknown-transport")if not variant.get("version"):entry["issues"].append("missing-version")diff --git a/tests/test_hostile_inputs.py b/tests/test_hostile_inputs.pyindex 1ed4ba2..e1fc1b7 100644--- a/tests/test_hostile_inputs.py+++ b/tests/test_hostile_inputs.py@@ -107,3 +107,48 @@ def test_agentic_decoder_matches_the_shared_decoder_on_utf16():body = "Café".encode("utf-16-le")body = b"\xff\xfe" + body[2:]assert ac._decode(body, "text/html") == "Café"+++# Second verification pass (same day): remaining crash shapes and robots edge cases.++def test_ucp_list_transport_is_an_issue_not_a_crash():+ profile = {"ucp": {"version": "2026-08-25", "services": {"dev.ucp.shopping": [+ {"version": "2026-08-25", "transport": ["rest"], "endpoint": "https://e.test/a"}]},+ "capabilities": {"dev.ucp.shopping.cart": [{"version": "v", "spec": "s", "schema": "s"}]}}}+ parsed = ucp_check.parse_profile(json.dumps(profile))+ assert "unknown-transport" in parsed["services"][0]["issues"]+++def test_keywordseverywhere_deep_json_success_body():+ class Deep(_Resp):+ def json(self):+ return json.loads(DEEP)+ with patch.object(ke, "_post", return_value=Deep(200, None)):+ result = ke.get_rank(["example.com"], "opr_live_testkey")+ assert result["status"] == "error"++[email protected]("category", [+ {"auditRefs": None}, {"auditRefs": ["x", 3]}, ["not", "a", "dict"],+])+def test_lighthouse_malformed_category_shapes(category):+ report = la.summarize(la.extract_lhr({"categories": {"agentic-browsing": category},+ "audits": {}}), "file")+ assert isinstance(report, dict)+++def test_robots_colon_only_line_ends_a_user_agent_block_in_both_tools():+ import agentic_fix as af+ robots = "User-agent: A\n: junk\nUser-agent: B\nDisallow: /\n"+ draft = af.add_content_signal(robots, "search=yes")["robots_txt"]+ groups = ac.parse_robots(draft)["groups"]+ assert all(g["content_signal"] for g in groups), draft+++def test_robots_unicode_line_separator_inside_a_comment_stays_a_comment():+ import agentic_fix as af+ robots = "User-agent: *\n# note Disallow: /\nAllow: /\n"+ draft = af.add_content_signal(robots, "search=yes")["robots_txt"]+ assert " " in draft # the comment is not split into a live rule+ parsed = ac.parse_robots(robots)+ assert ac.is_allowed(ac.select_group(parsed, "GPTBot")["rules"], "/")