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(hooks): send schema hook diagnostics to stderr so Claude sees them
Agrici Daniel58019f9d9587
diff --git a/hooks/validate-schema.py b/hooks/validate-schema.pyindex aaa91c0..7471b2e 100755--- a/hooks/validate-schema.py+++ b/hooks/validate-schema.py@@ -313,15 +313,18 @@ def main():critical = [e for e in errors if any(kw in e.lower() for kw in critical_keywords)]warnings = [e for e in errors if e not in critical]+ # Claude Code reads a hook's stderr, not its stdout: on exit 2 a PostToolUse+ # hook's stderr is fed back to Claude, and on exit 1 it is shown to the user.+ # Anything printed to stdout here would be dropped.if warnings:- print("⚠️ Schema validation warnings:")+ print("⚠️ Schema validation warnings:", file=sys.stderr)for w in warnings:- print(f" - {w}")+ print(f" - {w}", file=sys.stderr)if critical:- print("🛑 Schema validation ERRORS (blocking):")+ print("🛑 Schema validation ERRORS (blocking):", file=sys.stderr)for e in critical:- print(f" - {e}")+ print(f" - {e}", file=sys.stderr)sys.exit(2) # Block the editsys.exit(1) # Warnings only; proceeddiff --git a/tests/test_schema_hook_detection.py b/tests/test_schema_hook_detection.pyindex 11f7a02..d782ceb 100644--- a/tests/test_schema_hook_detection.py+++ b/tests/test_schema_hook_detection.py@@ -30,7 +30,7 @@ def _run(tmp_path: Path, filename: str, head: str) -> subprocess.CompletedProcestarget.write_text(f"<html><head>{head}</head><body></body></html>", encoding="utf-8")# The hook prints emoji markers as UTF-8; decode explicitly, because on# Windows text=True uses cp1252 and a decode error inside the pipe reader- # thread leaves stdout as None.+ # thread leaves stderr as None.return subprocess.run([sys.executable, str(HOOK), str(target)],capture_output=True, encoding="utf-8", errors="replace",@@ -47,7 +47,7 @@ def test_block_with_csp_nonce_is_validated(tmp_path: Path) -> None:f'<script type="application/ld+json" nonce="r4nd0m">{PLACEHOLDER}</script>',)assert result.returncode == 2- assert "[Business Name]" in result.stdout+ assert "[Business Name]" in result.stderrdef test_attribute_before_type_is_validated(tmp_path: Path) -> None:@@ -55,7 +55,7 @@ def test_attribute_before_type_is_validated(tmp_path: Path) -> None:tmp_path, "page.html", f'<script id="schema" type="application/ld+json">{RETIRED}</script>')assert result.returncode == 2- assert "ClaimReview" in result.stdout+ assert "ClaimReview" in result.stderrdef test_unquoted_type_value_is_validated(tmp_path: Path) -> None:@@ -85,7 +85,7 @@ def test_jsx_expression_body_is_not_reported(tmp_path: Path) -> None:head = '<script type="application/ld+json">{JSON.stringify(schema)}</script>'result = _run(tmp_path, "page.tsx", head)assert result.returncode == 0- assert result.stdout == ""+ assert result.stderr == ""def test_jsx_identifier_body_is_not_reported(tmp_path: Path) -> None:@@ -123,7 +123,7 @@ def test_malformed_object_literal_in_html_is_still_reported(tmp_path: Path) -> Ntmp_path, "page.html", '<script type="application/ld+json">{name: "unquoted"}</script>')assert result.returncode == 1- assert "Invalid JSON" in result.stdout+ assert "Invalid JSON" in result.stderr# --- @context forms ---------------------------------------------------------@@ -133,7 +133,7 @@ def test_context_with_trailing_slash_is_accepted(tmp_path: Path) -> None:head = '<script type="application/ld+json">{"@context":"https://schema.org/","@type":"Organization","name":"X"}</script>'result = _run(tmp_path, "page.html", head)assert result.returncode == 0- assert result.stdout == ""+ assert result.stderr == ""def test_context_object_with_schema_vocab_is_accepted(tmp_path: Path) -> None:@@ -158,7 +158,7 @@ def test_foreign_context_is_still_reported(tmp_path: Path) -> None:head = '<script type="application/ld+json">{"@context":"https://example.com/ns","@type":"Organization"}</script>'result = _run(tmp_path, "page.html", head)assert result.returncode == 1- assert "@context should be" in result.stdout+ assert "@context should be" in result.stderr# --- tokenizer regressions (a quoted attribute value may contain ">") ------@@ -171,15 +171,15 @@ def test_two_plain_ldjson_blocks_are_both_detected(tmp_path: Path) -> None:)result = _run(tmp_path, "page.html", head)assert result.returncode == 2- assert "Block 2" in result.stdout- assert "ClaimReview" in result.stdout+ assert "Block 2" in result.stderr+ assert "ClaimReview" in result.stderrdef test_block_with_nonce_and_id_is_validated(tmp_path: Path) -> None:head = f'<script id="ld-schema" type="application/ld+json" nonce="r4nd0m">{RETIRED}</script>'result = _run(tmp_path, "page.html", head)assert result.returncode == 2- assert "ClaimReview" in result.stdout+ assert "ClaimReview" in result.stderrdef test_attribute_value_containing_angle_bracket_is_detected(tmp_path: Path) -> None:@@ -190,14 +190,14 @@ def test_attribute_value_containing_angle_bracket_is_detected(tmp_path: Path) ->head = f'<script type="application/ld+json" data-cond="a>b">{VALID}</script>'result = _run(tmp_path, "page.html", head)assert result.returncode == 0- assert result.stdout == ""+ assert result.stderr == ""def test_jsx_json_stringify_inside_ldjson_script_is_not_flagged(tmp_path: Path) -> None:head = '<script type="application/ld+json">{JSON.stringify(schema)}</script>'result = _run(tmp_path, "page.jsx", head)assert result.returncode == 0- assert result.stdout == ""+ assert result.stderr == ""def test_renal_replacement_therapy_string_is_not_flagged(tmp_path: Path) -> None:@@ -209,7 +209,7 @@ def test_renal_replacement_therapy_string_is_not_flagged(tmp_path: Path) -> None)result = _run(tmp_path, "page.html", head)assert result.returncode == 0- assert result.stdout == ""+ assert result.stderr == ""def test_top_level_graph_is_detected(tmp_path: Path) -> None:@@ -223,4 +223,19 @@ def test_top_level_graph_is_detected(tmp_path: Path) -> None:)result = _run(tmp_path, "page.html", head)assert result.returncode == 2- assert "ClaimReview" in result.stdout+ assert "ClaimReview" in result.stderr+++def test_blocking_message_goes_to_stderr_not_stdout(tmp_path: Path) -> None:+ # Claude Code feeds a PostToolUse hook's stderr back to Claude on exit 2 and+ # ignores its stdout, so a blocking reason printed to stdout never arrives.+ result = _run(+ tmp_path,+ "page.html",+ '<script type="application/ld+json">'+ '{"@context":"https://schema.org","@type":"LocalBusiness","name":"[Business Name]"}'+ "</script>",+ )+ assert result.returncode == 2+ assert "[Business Name]" in result.stderr+ assert result.stdout == ""diff --git a/tests/test_schema_hook_policy.py b/tests/test_schema_hook_policy.pyindex d3e8c48..b7e5d7a 100644--- a/tests/test_schema_hook_policy.py+++ b/tests/test_schema_hook_policy.py@@ -68,8 +68,8 @@ def test_graph_members_inherit_context_but_still_require_type(tmp_path: Path) -># represent the emoji markers.result = _run_payload(tmp_path, payload, capture_output=True, encoding="utf-8")assert result.returncode == 1- assert "Missing @type" in result.stdout- assert "Missing @context" not in result.stdout+ assert "Missing @type" in result.stderr+ assert "Missing @context" not in result.stderrdef test_deprecated_graph_member_still_blocks(tmp_path: Path) -> None:@@ -87,8 +87,8 @@ def test_non_object_graph_members_are_reported_without_crashing(tmp_path: Path)}result = _run_payload(tmp_path, payload, capture_output=True, encoding="utf-8")assert result.returncode == 1- assert "@graph member 1 must be an object" in result.stdout- assert "@graph member 2 must be an object" in result.stdout+ assert "@graph member 1 must be an object" in result.stderr+ assert "@graph member 2 must be an object" in result.stderrdef test_graph_must_be_a_list(tmp_path: Path) -> None:@@ -98,7 +98,7 @@ def test_graph_must_be_a_list(tmp_path: Path) -> None:}result = _run_payload(tmp_path, payload, capture_output=True, encoding="utf-8")assert result.returncode == 1- assert "@graph must be a list" in result.stdout+ assert "@graph must be a list" in result.stderrdef test_replace_placeholder_matches_tokens_not_normal_words(tmp_path: Path) -> None: