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(seo-updates): parse --since robustly instead of crashing
Rudy Celekli3ea1a8e41774
diff --git a/scripts/seo_updates.py b/scripts/seo_updates.pyindex 8f446bd..00ba871 100644--- a/scripts/seo_updates.py+++ b/scripts/seo_updates.py@@ -69,6 +69,29 @@ def _load() -> dict:return json.load(fh)+def _parse_since(since: str) -> date:+ """Parse a ``--since`` value into a date.++ Accepts ``yyyy``, ``yyyy-mm`` and ``yyyy-mm-dd``; the month and day may be+ given without a leading zero (``2025-9`` means September 2025). Any other+ shape, or an out-of-range month/day, raises ``ValueError`` with a message+ the CLI turns into a clean error instead of a traceback.+ """+ parts = since.split("-")+ try:+ if len(parts) == 1:+ return date(int(parts[0]), 1, 1)+ if len(parts) == 2:+ return date(int(parts[0]), int(parts[1]), 1)+ if len(parts) == 3:+ return date(int(parts[0]), int(parts[1]), int(parts[2]))+ except ValueError:+ pass+ raise ValueError(+ f"invalid --since value: {since!r} (expected yyyy, yyyy-mm, or yyyy-mm-dd)"+ )++def _filter(updates: Iterable[dict],*,@@ -77,14 +100,7 @@ def _filter() -> list[dict]:out = list(updates)if since:- # Accept yyyy or yyyy-mm- if len(since) == 4:- since_date = date(int(since), 1, 1)- elif len(since) == 7:- y, m = since.split("-")- since_date = date(int(y), int(m), 1)- else:- since_date = date.fromisoformat(since)+ since_date = _parse_since(since)out = [u for u in out if date.fromisoformat(u["date"]) >= since_date]if kinds:# A combined "core+spam" rollout is both a core and a spam update, so@@ -154,7 +170,11 @@ def main() -> int:return 0kinds = set(args.kind) if args.kind else None- filtered = _filter(data["updates"], since=args.since, kinds=kinds)[: args.limit]+ try:+ filtered = _filter(data["updates"], since=args.since, kinds=kinds)[: args.limit]+ except ValueError as exc:+ print(f"Error: {exc}", file=sys.stderr)+ return 2if args.json:json.dump(diff --git a/tests/test_content_quality.py b/tests/test_content_quality.pyindex b6e7b63..a8d1440 100644--- a/tests/test_content_quality.py+++ b/tests/test_content_quality.py@@ -435,6 +435,35 @@ def test_seo_updates_filter_by_year() -> None:assert all(u["date"] >= "2025-01-01" for u in since_2025)+def test_seo_updates_since_accepts_a_non_zero_padded_month() -> None:+ # "2025-9" is 6 chars, so the old length-based dispatch fell through to+ # date.fromisoformat("2025-9") and raised ValueError. A non-padded month+ # is unambiguous September and must filter the same as "2025-09".+ data = seo_updates._load()+ padded = seo_updates._filter(data["updates"], since="2025-09")+ unpadded = seo_updates._filter(data["updates"], since="2025-9")+ assert [u["date"] for u in unpadded] == [u["date"] for u in padded]+++def test_seo_updates_parse_since_rejects_garbage_cleanly() -> None:+ # An out-of-range month (length 7, so it used to reach date(2025, 13, 1)+ # and crash) and non-date text both raise a clear ValueError.+ for bad in ("2025-13", "garbage", "2025-02-30"):+ with pytest.raises(ValueError):+ seo_updates._parse_since(bad)+++def test_seo_updates_cli_reports_a_bad_since_without_a_traceback() -> None:+ script = Path(__file__).resolve().parents[1] / "scripts" / "seo_updates.py"+ result = subprocess.run(+ [sys.executable, str(script), "--since", "2025-13", "--json"],+ capture_output=True, text=True,+ )+ assert result.returncode == 2+ assert "Traceback" not in result.stderr+ assert "invalid --since" in result.stderr++def test_seo_updates_cli_accepts_every_known_kind() -> None:"""`--kind documentation` used to be rejected by argparse while the ledger used it."""script = Path(__file__).resolve().parents[1] / "scripts" / "seo_updates.py"