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(google): bind properties to audited site
dajiaohuang0560677a5fb7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 648be42..9375dae 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Fixed++- Google SEO scripts now resolve GA4 and Search Console properties by the audited domain and refuse to silently use another site's configured defaults.+## [2.5.0] - 2026-10-22Security and accuracy fixes from a full audit, and Claude Desktop installs again.diff --git a/agents/seo-google.md b/agents/seo-google.mdindex bb9dea0..7d1e9ef 100644--- a/agents/seo-google.md+++ b/agents/seo-google.md@@ -22,16 +22,17 @@ You are a Google SEO API data analyst. When delegated tasks during an SEO audit:### Tier 1 (+ Service Account)- All Tier 0 checks-- GSC top queries/pages (28 days): `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py --property <prop> --json`+- GSC top queries/pages (28 days): `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py --domain <audited-domain> --json`- Use only totals with `totals_complete: true` as site-wide totals. Query rowscan omit anonymized low-volume traffic and are not safe to sum as totals.-- URL Inspection on homepage + key pages: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --json`-- GSC sitemap status: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py sitemaps --property <prop> --json`+- URL Inspection on homepage + key pages: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --domain <audited-domain> --json`+- GSC sitemap status: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py sitemaps --domain <audited-domain> --json`+- Never rely on the global default property for an audited site. The domain must resolve to a matching `sites` entry or matching legacy single-site configuration; if it does not, report the missing mapping and skip that Google data rather than querying another site's property.### Tier 2 (Full)- All Tier 1 checks-- GA4 organic traffic (28 days): `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --property <id> --json`-- Top organic landing pages: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --property <id> --report top-pages --json`+- GA4 organic traffic (28 days): `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --domain <audited-domain> --json`+- Top organic landing pages: `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --domain <audited-domain> --report top-pages --json`## Core Web Vitals Thresholdsdiff --git a/scripts/ga4_report.py b/scripts/ga4_report.pyindex 0c36887..e05af98 100644--- a/scripts/ga4_report.py+++ b/scripts/ga4_report.py@@ -37,10 +37,12 @@ except ImportError:try:from google_auth import get_oauth_credentials, load_config+ from google_properties import resolve_site_propertyexcept ImportError:import ossys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))from google_auth import get_oauth_credentials, load_config+ from google_properties import resolve_site_propertyGA4_SCOPES = ["https://www.googleapis.com/auth/analytics.readonly"]@@ -397,10 +399,15 @@ def main():parser = argparse.ArgumentParser(description="GA4 Data API - organic traffic reporting")- parser.add_argument(+ property_group = parser.add_mutually_exclusive_group()+ property_group.add_argument("--property", "-p",help="GA4 property ID (numeric, e.g., 123456789). Uses config default if not specified.",)+ property_group.add_argument(+ "--domain",+ help="Audited site domain/URL; resolves its sites entry and refuses another site's default.",+ )parser.add_argument("--days", "-d", type=int, default=28, help="Number of days (default: 28)")parser.add_argument("--report", "-r",@@ -417,7 +424,14 @@ def main():prop = args.propertyif not prop:config = load_config()- prop = config.get("ga4_property_id") or ""+ if args.domain:+ try:+ prop = resolve_site_property(config, "ga4", args.domain)+ except ValueError as error:+ print(f"Error: {error}", file=sys.stderr)+ sys.exit(1)+ else:+ prop = config.get("ga4_property_id") or ""# Strip 'properties/' prefix if present for consistencyif prop and prop.startswith("properties/"):prop = prop[len("properties/"):]diff --git a/scripts/google_auth.py b/scripts/google_auth.pyindex 0408b90..a951db9 100644--- a/scripts/google_auth.py+++ b/scripts/google_auth.py@@ -866,11 +866,16 @@ def check_credentials(service: str) -> dict:# GA4 also needs property IDif service == "ga4" and result["available"]:ga4_id = config.get("ga4_property_id")- if not ga4_id:+ site_map = config.get("sites") or {}+ has_site_ga4 = isinstance(site_map, dict) and any(+ isinstance(site, dict) and site.get("ga4_property_id")+ for site in site_map.values()+ )+ if not ga4_id and not has_site_ga4:result["available"] = Falseresult["error"] = ("Credentials found but no GA4 property ID configured. "- f"Set GA4_PROPERTY_ID or add 'ga4_property_id' to {CONFIG_PATH}"+ f"Set GA4_PROPERTY_ID or add 'ga4_property_id' or a sites mapping to {CONFIG_PATH}")else:result["error"] = f"Unknown service: {service}"@@ -913,7 +918,12 @@ def detect_tier() -> dict:except (json.JSONDecodeError, IOError):pass- if has_authenticated and config.get("ga4_property_id"):+ site_map = config.get("sites") or {}+ has_site_ga4 = isinstance(site_map, dict) and any(+ isinstance(site, dict) and site.get("ga4_property_id")+ for site in site_map.values()+ )+ if has_authenticated and (config.get("ga4_property_id") or has_site_ga4):has_ga4 = Trueif has_ga4:@@ -1117,9 +1127,15 @@ def main():continueresults[svc] = check_credentials(svc)+ site_map = load_config().get("sites") or {}+ site_summary = {+ domain: [name for name, key in (("GSC", "gsc_property"), ("GA4", "ga4_property_id"))+ if isinstance(site, dict) and site.get(key)]+ for domain, site in site_map.items()+ } if isinstance(site_map, dict) else {}if args.json:tier_info = detect_tier()- output = {"tier": tier_info, "services": results}+ output = {"tier": tier_info, "services": results, "sites": site_summary}print(json.dumps(output, indent=2))else:tier_info = detect_tier()@@ -1132,6 +1148,10 @@ def main():print(f" {result['error']}")if result.get("client_email"):print(f" Service account: {result['client_email']}")+ if site_summary:+ print("Configured site properties:")+ for domain, services_for_site in sorted(site_summary.items()):+ print(f" {domain}: {', '.join(services_for_site) or 'no Google properties'}")print()if tier_info["missing"]:print(f"Tip: {tier_info['missing']}")diff --git a/scripts/google_properties.py b/scripts/google_properties.pynew file mode 100644index 0000000..b2dda90--- /dev/null+++ b/scripts/google_properties.py@@ -0,0 +1,68 @@+"""Fail-closed resolution of Google properties for a specific audited site."""++from __future__ import annotations++from urllib.parse import urlsplit+++def normalize_site_domain(value: str) -> str:+ """Return the exact hostname represented by a host or URL."""+ text = value.strip()+ parsed = urlsplit(text if "://" in text else f"//{text}")+ if not parsed.hostname:+ raise ValueError(f"Invalid site domain or URL: {value!r}")+ return parsed.hostname.rstrip(".").lower()+++def _property_domain(value: str) -> str:+ if value.startswith("sc-domain:"):+ return normalize_site_domain(value[len("sc-domain:"):])+ return normalize_site_domain(value)+++def resolve_site_property(config: dict, service: str, domain: str) -> str:+ """Resolve an exact site's GSC or GA4 property without crossing sites.++ ``sites`` maps hostnames to ``gsc_property`` and/or+ ``ga4_property_id``. The legacy single-site fields are used only when the+ requested domain matches the domain of ``default_property``.+ """+ fields = {"gsc": "gsc_property", "ga4": "ga4_property_id"}+ if service not in fields:+ raise ValueError(f"Unsupported Google property service: {service}")+ host = normalize_site_domain(domain)+ sites = config.get("sites") or {}+ if not isinstance(sites, dict):+ raise ValueError("sites must be an object keyed by site domain")++ matches = []+ for configured_domain, values in sites.items():+ if normalize_site_domain(configured_domain) == host:+ matches.append(values)+ if len(matches) > 1:+ raise ValueError(f"Multiple sites entries normalize to {host!r}")+ if matches:+ values = matches[0]+ if not isinstance(values, dict) or not values.get(fields[service]):+ raise ValueError(f"No {fields[service]} configured for site {host!r}")+ return str(values[fields[service]])++ default_property = config.get("default_property")+ if default_property:+ try:+ default_text = str(default_property)+ default_host = _property_domain(default_text)+ is_domain_property = default_text.startswith("sc-domain:")+ matches_default = host == default_host or (+ is_domain_property and host.endswith("." + default_host)+ )+ if matches_default:+ prop = default_property if service == "gsc" else config.get("ga4_property_id")+ if prop:+ return str(prop)+ except ValueError:+ pass+ raise ValueError(+ f"No site-specific {service.upper()} property configured for {host!r}; "+ "refusing to use a different site's default. Add a matching sites entry."+ )diff --git a/scripts/gsc_inspect.py b/scripts/gsc_inspect.pyindex 672b379..82152a6 100644--- a/scripts/gsc_inspect.py+++ b/scripts/gsc_inspect.py@@ -28,10 +28,12 @@ except ImportError:try:from google_auth import get_oauth_credentials, load_config, validate_url+ from google_properties import resolve_site_propertyexcept ImportError:import ossys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))from google_auth import get_oauth_credentials, load_config, validate_url+ from google_properties import resolve_site_propertyGSC_SCOPES = ["https://www.googleapis.com/auth/webmasters.readonly"]@@ -245,9 +247,14 @@ def main():description="Google Search Console URL Inspection API helper")parser.add_argument("url", nargs="?", help="URL to inspect")- parser.add_argument(+ property_group = parser.add_mutually_exclusive_group()+ property_group.add_argument("--site-url", "-s",- help="GSC property (e.g., sc-domain:example.com). Uses default from config if not specified.",+ help="Explicit GSC property (e.g., sc-domain:example.com).",+ )+ property_group.add_argument(+ "--domain",+ help="Audited site domain/URL; resolves its sites entry and refuses another site's default.",)parser.add_argument("--batch", "-b",@@ -263,13 +270,23 @@ def main():args = parser.parse_args()- # Resolve site URL+ # Resolve the property against the requested site's domain when possible.site_url = args.site_url+ if args.batch and not args.site_url and not args.domain:+ parser.error("--batch requires --site-url or --domain to identify the site's property")if not site_url:config = load_config()- site_url = config.get("default_property")+ domain = args.domain or args.url+ if domain:+ try:+ site_url = resolve_site_property(config, "gsc", domain)+ except ValueError as error:+ print(f"Error: {error}", file=sys.stderr)+ sys.exit(1)+ else:+ site_url = config.get("default_property")if not site_url:- print("Error: No site URL specified. Use --site-url or set default_property in config.", file=sys.stderr)+ print("Error: No site URL specified. Use --site-url, --domain, or set default_property in config.", file=sys.stderr)sys.exit(1)if args.batch:diff --git a/scripts/gsc_query.py b/scripts/gsc_query.pyindex 2a79355..13fc771 100644--- a/scripts/gsc_query.py+++ b/scripts/gsc_query.py@@ -30,10 +30,12 @@ except ImportError:try:from google_auth import get_oauth_credentials, load_config+ from google_properties import resolve_site_propertyexcept ImportError:import ossys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))from google_auth import get_oauth_credentials, load_config+ from google_properties import resolve_site_propertyGSC_SCOPES = ["https://www.googleapis.com/auth/webmasters.readonly"]INDEXATION_NOTE = (@@ -436,9 +438,14 @@ def main():choices=["query", "sitemaps", "sites"],help="Command: query (default), sitemaps, sites",)- parser.add_argument(+ property_group = parser.add_mutually_exclusive_group()+ property_group.add_argument("--property", "-p",- help="GSC property (e.g., sc-domain:example.com). Uses default from config if not specified.",+ help="Explicit GSC property (e.g., sc-domain:example.com). Uses config default if not specified.",+ )+ property_group.add_argument(+ "--domain",+ help="Audited site domain/URL; resolves its sites entry and refuses another site's default.",)parser.add_argument("--days", "-d", type=int, default=28, help="Number of days (default: 28)")parser.add_argument("--start-date", help="Start date (YYYY-MM-DD)")@@ -464,7 +471,14 @@ def main():prop = args.propertyif not prop:config = load_config()- prop = config.get("default_property")+ if args.domain and args.command != "sites":+ try:+ prop = resolve_site_property(config, "gsc", args.domain)+ except ValueError as error:+ print(f"Error: {error}", file=sys.stderr)+ sys.exit(1)+ elif not args.domain:+ prop = config.get("default_property")if not prop and args.command != "sites":print("Error: No property specified. Use --property or set default_property in config.", file=sys.stderr)sys.exit(1)diff --git a/skills/seo-google/SKILL.md b/skills/seo-google/SKILL.mdindex 699d311..8a3a422 100644--- a/skills/seo-google/SKILL.md+++ b/skills/seo-google/SKILL.md@@ -120,7 +120,7 @@ Output includes per-metric trend direction, percentage change, and weekly p75 vaSearch Analytics: clicks, impressions, CTR, position for last 28 days.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py --property <property> --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py --domain <audited-domain> --json`**Reference:** `references/search-console-api.md`**Default:** 28 days, dimensions=query,page, type=web, limit=1000.@@ -150,7 +150,7 @@ dimension rows, not the size of every pagination request.URL Inspection: real indexation status from Google.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --domain <audited-domain> --json`Returns: verdict (PASS/FAIL), coverage state, robots.txt status, indexing state,page fetch state, canonical selection, rich results. (`mobileUsabilityResult` is deprecated@@ -160,7 +160,7 @@ in the API; do not report it as a mobile-usability check.)Batch inspection from a file (one URL per line). Rate limited to 2,000/day per site.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py --batch <file> --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py --batch <file> --domain <audited-domain> --json`### `/seo google sitemaps <property>`@@ -168,7 +168,7 @@ List submitted sitemaps with status, errors, warnings. Sitemap contents reportsubmitted counts only; URL Inspection API is the indexation truth for whetherspecific URLs are indexed.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py sitemaps --property <property> --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_query.py sitemaps --domain <audited-domain> --json`---@@ -198,7 +198,7 @@ Batch submit URLs from a file. Tracks quota usage.Organic traffic report: daily sessions, users, pageviews, bounce rate, engagement.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --property <id> --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --domain <audited-domain> --json`**Reference:** `references/ga4-data-api.md`**Default:** 28 days, filtered to Organic Search channel group.@@ -208,7 +208,7 @@ Organic traffic report: daily sessions, users, pageviews, bounce rate, engagemenTop organic landing pages ranked by sessions.-**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --property <id> --report top-pages --json`+**Script:** `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run ga4_report.py --domain <audited-domain> --report top-pages --json`---diff --git a/skills/seo-google/references/auth-setup.md b/skills/seo-google/references/auth-setup.mdindex 8265533..030fa3e 100644--- a/skills/seo-google/references/auth-setup.md+++ b/skills/seo-google/references/auth-setup.md@@ -92,10 +92,29 @@ Save to `~/.config/claude-seo/google-api.json`:"service_account_path": "~/.config/claude-seo/service_account.json","api_key": "<GOOGLE_API_KEY>","default_property": "sc-domain:example.com",- "ga4_property_id": "properties/123456789"+ "ga4_property_id": "properties/123456789",+ "sites": {+ "example.com": {+ "gsc_property": "sc-domain:example.com",+ "ga4_property_id": "properties/123456789"+ },+ "client.example": {+ "gsc_property": "sc-domain:client.example",+ "ga4_property_id": "properties/987654321"+ }+ }}```+For site audits, pass `--domain <audited-domain>` to `gsc_query.py` and+`ga4_report.py`; `gsc_inspect.py` accepts the same flag (or derives the host+from a single inspected URL). `sites` keys are exact hostnames and+map to that site's properties. If no exact mapping exists, a legacy global+property is usable only when its GSC domain matches the requested domain;+otherwise the script fails closed rather than querying another site's data.+Keep explicit `--property` / `--site-url` for intentional direct property+queries outside a domain-specific audit.+### Property URL Formats| Format | Example | When to Use |diff --git a/skills/seo-technical/SKILL.md b/skills/seo-technical/SKILL.mdindex 2184128..1c74689 100644--- a/skills/seo-technical/SKILL.md+++ b/skills/seo-technical/SKILL.md@@ -251,7 +251,7 @@ If DataForSEO MCP tools are available, use `on_page_instant_pages` for real page## Google API Integration (Optional)-If Google API credentials are configured, use `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run pagespeed_check.py <url> --json` for real PSI + CrUX field data (replaces lab-only CWV estimates), `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run crux_history.py <url> --form-factor PHONE --json` for 25-week CWV trends (use PHONE: the all-devices view can hide a mobile failure), and `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --json` for real indexation status per URL.+If Google API credentials are configured, use `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run pagespeed_check.py <url> --json` for real PSI + CrUX field data (replaces lab-only CWV estimates), `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run crux_history.py <url> --form-factor PHONE --json` for 25-week CWV trends (use PHONE: the all-devices view can hide a mobile failure), and `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run gsc_inspect.py <url> --domain <audited-domain> --json` for real indexation status per URL. Domain-specific calls fail closed rather than using a different site's default property.## Auditing a Local or Private Hostdiff --git a/tests/test_google_property_resolution.py b/tests/test_google_property_resolution.pynew file mode 100644index 0000000..fa71ccb--- /dev/null+++ b/tests/test_google_property_resolution.py@@ -0,0 +1,77 @@+"""Site-specific Google property selection must never cross domains."""++from __future__ import annotations++import sys+from pathlib import Path++import pytest++REPO_ROOT = Path(__file__).resolve().parents[1]+_SCRIPTS = REPO_ROOT / "scripts"+if str(_SCRIPTS) not in sys.path:+ sys.path.insert(0, str(_SCRIPTS))++from google_properties import resolve_site_property # noqa: E402+++def test_resolves_properties_from_exact_site_mapping() -> None:+ config = {+ "default_property": "sc-domain:primary.example",+ "ga4_property_id": "properties/100",+ "sites": {+ "client.example": {+ "gsc_property": "sc-domain:client.example",+ "ga4_property_id": "properties/200",+ }+ },+ }++ assert resolve_site_property(config, "gsc", "https://CLIENT.example/report") == "sc-domain:client.example"+ assert resolve_site_property(config, "ga4", "client.example") == "properties/200"+++def test_does_not_fall_back_to_another_sites_global_properties() -> None:+ config = {+ "default_property": "sc-domain:primary.example",+ "ga4_property_id": "properties/100",+ }++ with pytest.raises(ValueError, match="refusing to use a different site's default"):+ resolve_site_property(config, "gsc", "client.example")+ with pytest.raises(ValueError, match="refusing to use a different site's default"):+ resolve_site_property(config, "ga4", "client.example")+++def test_legacy_single_site_properties_are_usable_only_for_matching_domain() -> None:+ config = {+ "default_property": "sc-domain:example.com",+ "ga4_property_id": "properties/123",+ }++ assert resolve_site_property(config, "gsc", "https://example.com/page") == "sc-domain:example.com"+ assert resolve_site_property(config, "gsc", "https://www.example.com/page") == "sc-domain:example.com"+ assert resolve_site_property(config, "ga4", "example.com") == "properties/123"+++def test_incomplete_site_mapping_does_not_fall_back_to_global_value() -> None:+ config = {+ "default_property": "sc-domain:example.com",+ "ga4_property_id": "properties/123",+ "sites": {"example.com": {"gsc_property": "sc-domain:example.com"}},+ }++ with pytest.raises(ValueError, match="No ga4_property_id configured"):+ resolve_site_property(config, "ga4", "example.com")+++def test_duplicate_normalized_site_keys_are_rejected() -> None:+ config = {+ "sites": {+ "example.com": {"gsc_property": "sc-domain:example.com"},+ "EXAMPLE.COM.": {"gsc_property": "https://example.com/"},+ }+ }++ with pytest.raises(ValueError, match="Multiple sites entries"):+ resolve_site_property(config, "gsc", "example.com")