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(preload_check): exit 0 on a completed run, gate only with --fail-under

Tobi | Nordaluxb43dd972733f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33ff115..7af8e59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- `preload_check.py` exited 1 on every successful run that scored below a
+ hard-coded 75, so `set -e` scripts and CI steps aborted on healthy pages. A
+ completed analysis now exits 0; the gate is opt-in through `--fail-under N`.
+ Exit 2 for a URL refused by url_safety is unchanged. (#281)
- CI now runs the full test suite on Windows and macOS, not just the three
platform-neutral modules. The tests that assert POSIX mode bits skip on
Windows instead of failing.
diff --git a/scripts/preload_check.py b/scripts/preload_check.py
index 5989c3c..d3c77f2 100644
--- a/scripts/preload_check.py
+++ b/scripts/preload_check.py
@@ -46,6 +46,12 @@ Result JSON::
"score": 0..100,
"recommendations": ["…"]
}
+
+Exit status::
+
+ 0 analysis completed (a low score is a finding, not a failed run)
+ 1 score below ``--fail-under N`` (opt-in gate, off by default)
+ 2 URL refused by url_safety
"""
from __future__ import annotations
@@ -195,6 +201,14 @@ def main() -> int:
)
parser.add_argument("url")
parser.add_argument("--json", action="store_true")
+ parser.add_argument(
+ "--fail-under",
+ type=int,
+ default=None,
+ metavar="N",
+ help="Exit 1 if the score is below N. Off by default: a successful "
+ "run exits 0 whatever the score.",
+ )
args = parser.parse_args()
try:
@@ -228,7 +242,9 @@ def main() -> int:
for r in result["recommendations"]:
print(f" - {r}")
- return 0 if result["score"] >= 75 else 1
+ if args.fail_under is not None and result["score"] < args.fail_under:
+ return 1
+ return 0
if __name__ == "__main__":
diff --git a/tests/test_technical_depth.py b/tests/test_technical_depth.py
index 54cbf2e..c47031a 100644
--- a/tests/test_technical_depth.py
+++ b/tests/test_technical_depth.py
@@ -14,8 +14,10 @@ deferred to manual smoke tests.
from __future__ import annotations
+import json
import os
import sys
+from types import SimpleNamespace
from unittest.mock import patch
_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")
@@ -170,3 +172,41 @@ def test_unlighthouse_reports_missing_node(monkeypatch) -> None:
result = unlighthouse_run.run("https://example.com/")
assert result["ok"] is False
assert "npx" in result["error"].lower() or "node" in result["error"].lower()
+
+
+# ---------------------------------------------------------------------------
+# preload_check exit status (issue #281): success is 0, gating is opt-in
+# ---------------------------------------------------------------------------
+
+_PLAIN_HTML = "<html><head></head><body><p>nothing to preload</p></body></html>"
+
+
+def _run_preload_main(monkeypatch, capsys, *argv: str) -> tuple[int, str]:
+ response = SimpleNamespace(url="https://example.com/", text=_PLAIN_HTML, headers={})
+ monkeypatch.setattr(preload_check, "safe_requests_get", lambda *a, **k: response)
+ monkeypatch.setattr(sys, "argv", ["preload_check.py", "https://example.com/", *argv])
+ code = preload_check.main()
+ return code, capsys.readouterr().out
+
+
+def test_preload_main_exits_zero_on_a_low_score(monkeypatch, capsys) -> None:
+ score = preload_check.analyse(_PLAIN_HTML, {})["score"]
+ assert score < 75 # the old hard-coded gate would have exited 1 here
+ code, out = _run_preload_main(monkeypatch, capsys, "--json")
+ assert code == 0
+ assert json.loads(out)["score"] == score
+
+
+def test_preload_main_fail_under_gates_on_the_score(monkeypatch, capsys) -> None:
+ score = preload_check.analyse(_PLAIN_HTML, {})["score"]
+ assert _run_preload_main(monkeypatch, capsys, "--fail-under", str(score + 1))[0] == 1
+ assert _run_preload_main(monkeypatch, capsys, "--fail-under", str(score))[0] == 0
+
+
+def test_preload_main_still_exits_two_on_url_safety_error(monkeypatch, capsys) -> None:
+ def refuse(*a, **k):
+ raise preload_check.URLSafetyError("blocked")
+
+ monkeypatch.setattr(preload_check, "safe_requests_get", refuse)
+ monkeypatch.setattr(sys, "argv", ["preload_check.py", "http://127.0.0.1/"])
+ assert preload_check.main() == 2