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(crux): report degradation from a zero CLS baseline
xunguangzlj-cloud95ef64c51a40
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 648be42..f204169 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed++- CrUX History reports an increase from a zero CLS baseline as degrading, with+ an undefined percentage (`null` in JSON), instead of stable with a 0% change.+## [2.5.0] - 2026-10-22Security and accuracy fixes from a full audit, and Claude Desktop installs again.diff --git a/scripts/crux_history.py b/scripts/crux_history.pyindex 2dfab2a..b8a8839 100644--- a/scripts/crux_history.py+++ b/scripts/crux_history.py@@ -214,6 +214,7 @@ def detect_trends(metrics: dict) -> dict:Returns:Dictionary mapping metric names to trend info:direction (improving/stable/degrading), change_pct, latest, earliest.+ change_pct is None for an increase from zero, where a percentage is undefined."""trends = {}@@ -235,13 +236,15 @@ def detect_trends(metrics: dict) -> dict:avg_last = sum(last_4) / len(last_4)if avg_first == 0:- change_pct = 0+ change_pct = 0 if avg_last == 0 else Noneelse:change_pct = ((avg_last - avg_first) / avg_first) * 100# For CWV, lower is better (except CLS where lower is also better)# So a negative change_pct means improvement- if abs(change_pct) < 5:+ if change_pct is None:+ direction = "degrading"+ elif abs(change_pct) < 5:direction = "stable"elif change_pct < 0:direction = "improving"@@ -250,7 +253,7 @@ def detect_trends(metrics: dict) -> dict:trends[metric_name] = {"direction": direction,- "change_pct": round(change_pct, 1),+ "change_pct": round(change_pct, 1) if change_pct is not None else None,"earliest_avg": round(avg_first, 3) if data.get("unit") == "" else round(avg_first),"latest_avg": round(avg_last, 3) if data.get("unit") == "" else round(avg_last),"label": data.get("label", metric_name),@@ -325,7 +328,8 @@ def main():change = trend.get("change_pct", 0)earliest = trend.get("earliest_avg")latest = trend.get("latest_avg")- print(f" {label}: {arrow} ({change:+.1f}%) | {earliest} -> {latest}")+ change_text = f"{change:+.1f}%" if change is not None else "n/a: zero baseline"+ print(f" {label}: {arrow} ({change_text}) | {earliest} -> {latest}")if __name__ == "__main__":diff --git a/tests/test_crux_history_trends.py b/tests/test_crux_history_trends.pynew file mode 100644index 0000000..4577c01--- /dev/null+++ b/tests/test_crux_history_trends.py@@ -0,0 +1,61 @@+"""Regression coverage for CrUX trends whose initial CLS average is zero."""++import json+import os+import sys+from unittest.mock import patch++import pytest++_SCRIPTS = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "scripts")+if _SCRIPTS not in sys.path:+ sys.path.insert(0, _SCRIPTS)++pytest.importorskip("requests")+import crux_history # noqa: E402+++def _cls(values):+ return {"cumulative_layout_shift": {"p75_values": values, "label": "CLS", "unit": ""}}+++ ("values", "direction", "change_pct"),+ [+ ([0] * 4 + [0.2] * 4, "degrading", None),+ ([0] * 8, "stable", 0),+ ([0.2] * 4 + [0] * 4, "improving", -100),+ ([0.1] * 4 + [0.2] * 4, "degrading", 100),+ ],+)+def test_cls_zero_baseline_and_nonzero_controls(values, direction, change_pct):+ trend = crux_history.detect_trends(_cls(values))["cumulative_layout_shift"]+ assert trend["direction"] == direction+ assert trend["change_pct"] == change_pct+ assert trend["earliest_avg"] == values[0]+ assert trend["latest_avg"] == values[-1]+ assert trend["data_points"] == 8+ json.dumps(trend, allow_nan=False)++[email protected]("json_output", [False, True])+def test_cli_reports_a_zero_baseline_without_a_misleading_percentage(capsys, json_output):+ result = {+ "target": "https://example.com",+ "form_factor": "ALL",+ "trends": crux_history.detect_trends(_cls([0] * 4 + [0.2] * 4)),+ }+ argv = ["crux_history.py", "https://example.com", "--api-key", "DUMMY"]+ if json_output:+ argv.append("--json")+ with patch.object(sys, "argv", argv), patch.object(crux_history, "query_history", return_value=result):+ crux_history.main()+ output = capsys.readouterr().out+ if json_output:+ trend = json.loads(output)["trends"]["cumulative_layout_shift"]+ assert trend["direction"] == "degrading"+ assert trend["change_pct"] is None+ else:+ assert "CLS: DEGRADING" in output+ assert "zero baseline" in output+ assert "+0.0%" not in output