Skip to content

balsm-health/website / .claude/skills/seo

Comprehensive SEO analysis for any website or business type. Full site audits, single-page analysis, technical SEO (crawlability, indexability, Core Web Vitals with INP), schema markup, content quality (E-E-A-T), image optimization, sitemap analysis, and GEO for AI Overviews/ChatGPT/Perplexity. Industry detection for SaaS, e-commerce, local, publishers, agencies. Triggers on: SEO, audit, schema, Core Web Vitals, sitemap, E-E-A-T, AI Overviews, GEO, technical SEO, content quality, page speed.

FileKindSize
LICENSE.txtmarkdown143 B
SKILL.mdskill md16.9 KB
bin/claude-seoexecutablescript1.5 KB
extensions/banana/references/cost-tracking.mdmarkdown1.2 KB
extensions/banana/references/gemini-models.mdmarkdown5.8 KB
extensions/banana/references/mcp-tools.mdmarkdown3.7 KB
extensions/banana/references/post-processing.mdmarkdown5.1 KB
extensions/banana/references/presets.mdmarkdown2.2 KB
extensions/banana/references/prompt-engineering.mdmarkdown20.9 KB
extensions/banana/references/seo-image-presets.mdmarkdown4.0 KB
extensions/banana/scripts/batch.pyexecutablescript3.3 KB
extensions/banana/scripts/cost_tracker.pyexecutablescript7.2 KB
extensions/banana/scripts/edit.pyexecutablescript5.6 KB
extensions/banana/scripts/generate.pyexecutablescript6.4 KB
extensions/banana/scripts/presets.pyexecutablescript4.9 KB
extensions/banana/scripts/setup_mcp.pyexecutablescript4.5 KB
extensions/banana/scripts/validate_setup.pyexecutablescript3.8 KB
hooks/hooks.jsonconfig416 B
hooks/run-python-hook.jsscript1.7 KB
hooks/validate-schema.pyexecutablescript5.9 KB
pdf/google-seo-reference.mdmarkdown8.0 KB
references/backlink-quality.mdmarkdown3.4 KB
references/cwv-thresholds.mdmarkdown6.9 KB
references/eeat-framework.mdmarkdown8.1 KB
references/free-backlink-sources.mdmarkdown5.6 KB
references/local-schema-types.mdmarkdown9.2 KB
references/local-seo-signals.mdmarkdown9.6 KB
references/maps-api-endpoints.mdmarkdown5.9 KB
references/maps-free-apis.mdmarkdown6.0 KB
references/maps-gbp-checklist.mdmarkdown5.9 KB
references/maps-geo-grid.mdmarkdown4.3 KB
references/quality-gates.mdmarkdown5.1 KB
references/schema-types.mdmarkdown7.8 KB
references/thinking-framework.mdmarkdown9.3 KB
requirements.txtmanifest1.5 KB
runtime-plugin.jsonconfig1.5 KB
schema/templates.jsonconfig9.4 KB
scripts/agent_ux_check.pyscript8.2 KB
scripts/analyze_visual.pyexecutablescript7.2 KB
scripts/backlinks_auth.pyscript16.1 KB
scripts/bing_webmaster.pyscript21.8 KB
scripts/capture_screenshot.pyexecutablescript6.4 KB
scripts/commoncrawl_graph.pyscript15.6 KB
scripts/consistency_check.pyscript12.5 KB
scripts/content_humanize.pyscript7.2 KB
scripts/content_quality.pyscript9.7 KB
scripts/content_verify.pyscript7.1 KB
scripts/crux_history.pyscript10.7 KB
scripts/dataforseo_costs.pyscript15.8 KB
scripts/dataforseo_merchant.pyexecutablescript16.7 KB
scripts/dataforseo_normalize.pyexecutablescript14.7 KB
scripts/domain_history.pyscript9.6 KB
scripts/drift_baseline.pyscript13.5 KB
scripts/drift_compare.pyscript22.3 KB
scripts/drift_history.pyscript3.4 KB
scripts/drift_report.pyscript11.0 KB
scripts/fetch_page.pyexecutablescript9.4 KB
scripts/ga4_report.pyscript16.8 KB
scripts/gbp_deprecation_lint.pyexecutablescript4.7 KB
scripts/google_auth.pyscript31.0 KB
scripts/google_report.pyscript97.6 KB
scripts/gsc_inspect.pyscript11.0 KB
scripts/gsc_query.pyscript18.6 KB
scripts/indexing_notify.pyscript10.3 KB
scripts/indexnow_submit.pyscript8.8 KB
scripts/iptc_ai_label.pyscript7.6 KB
scripts/keyword_planner.pyscript10.8 KB
scripts/lcp_subparts.pyscript7.2 KB
scripts/moz_api.pyscript14.7 KB
scripts/nlp_analyze.pyscript12.1 KB
scripts/pagespeed_check.pyscript22.9 KB
scripts/parasite_risk.pyexecutablescript8.6 KB
scripts/parse_html.pyexecutablescript8.8 KB
scripts/portability_check.pyscript7.8 KB
scripts/preload_check.pyscript8.1 KB
scripts/release_sign.pyscript5.6 KB
scripts/render_page.pyscript20.9 KB
scripts/runtime.pyexecutablescript15.1 KB
scripts/schema_ecommerce_validate.pyscript11.8 KB
scripts/schema_generate.pyscript12.0 KB
scripts/seo_updates.pyscript4.8 KB
scripts/sitemap_discovery.pyscript10.0 KB
scripts/sync_flow.pyscript11.9 KB
scripts/ucp_check.pyscript8.4 KB
scripts/unlighthouse_run.pyscript5.6 KB
scripts/url_safety.pyscript22.0 KB
scripts/validate_backlink_report.pyscript11.7 KB
scripts/verify_backlinks.pyscript12.9 KB
scripts/verify_release.pyscript4.8 KB
scripts/youtube_search.pyscript12.3 KB

scripts/backlinks_auth.py

View on GitHub
#!/usr/bin/env python3
"""
Backlink API credential management for Claude SEO.

Loads and validates credentials for Moz Link Explorer API,
Bing Webmaster Tools API, and Common Crawl web graphs.
Supports config file and environment variable fallbacks.

Usage:
    python backlinks_auth.py --check                  # Check all credentials
    python backlinks_auth.py --check moz              # Check specific service
    python backlinks_auth.py --check --json            # JSON output
    python backlinks_auth.py --setup                   # Show setup instructions
    python backlinks_auth.py --tier                    # Show detected credential tier
"""

import argparse
import json
import os
import sys
from typing import Optional

# Import SSRF protection from the canonical url_safety module.
# google_auth.validate_url is a back-compat wrapper around the same function.
_SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
if _SCRIPTS_DIR not in sys.path:
    sys.path.insert(0, _SCRIPTS_DIR)
try:
    from url_safety import validate_url
except ImportError as _import_exc:
    # Hard fail: a private-IP/loopback fallback that omits SSRF checks is
    # worse than no validation at all. The previous fallback shipped in
    # v1.9.0 silently allowed private IP literals and was flagged in the
    # cybersecurity audit (v2.0.0 Phase H). Refuse to run instead.
    raise RuntimeError(
        "scripts/url_safety.py is required for SSRF protection. "
        "Install with: pip install -r requirements.txt"
    ) from _import_exc

CONFIG_PATH = os.path.expanduser("~/.config/claude-seo/backlinks-api.json")
CACHE_DIR = os.path.expanduser("~/.cache/claude-seo/commoncrawl")

# Which services need which auth type
SERVICE_AUTH = {
    "moz": "api_key",
    "bing": "api_key",
    "commoncrawl": "none",
    "verify": "none",
}

# Human-readable service names
SERVICE_NAMES = {
    "moz": "Moz Link Explorer API",
    "bing": "Bing Webmaster Tools API",
    "commoncrawl": "Common Crawl Web Graph",
    "verify": "Backlink Verification Crawler",
}


def load_config() -> dict:
    """
    Load configuration from config file with environment variable fallbacks.

    Reads ~/.config/claude-seo/backlinks-api.json first. Any missing fields
    are filled from environment variables.

    Returns:
        Dictionary with keys: moz_api_key, bing_api_key,
        bing_verified_sites, commoncrawl_cache_dir.
    """
    config = {
        "moz_api_key": None,
        "bing_api_key": None,
        "bing_verified_sites": [],
        "commoncrawl_cache_dir": CACHE_DIR,
    }

    # Load from config file
    if os.path.exists(CONFIG_PATH):
        try:
            with open(CONFIG_PATH, "r") as f:
                file_config = json.load(f)
            for k, v in file_config.items():
                if v is not None and v != "":
                    config[k] = v
        except (json.JSONDecodeError, IOError) as e:
            print(f"Warning: Could not read config file: {e}", file=sys.stderr)

    # Environment variable fallbacks
    if not config["moz_api_key"]:
        config["moz_api_key"] = os.environ.get("MOZ_API_KEY")

    if not config["bing_api_key"]:
        config["bing_api_key"] = os.environ.get("BING_WEBMASTER_API_KEY")

    # Expand cache dir path
    config["commoncrawl_cache_dir"] = os.path.expanduser(
        config.get("commoncrawl_cache_dir", CACHE_DIR)
    )

    return config


def check_credentials(service: str) -> dict:
    """
    Validate credentials for a specific backlink data service.

    Args:
        service: One of 'moz', 'bing', 'commoncrawl', 'verify'.

    Returns:
        Dictionary with:
            - available: bool
            - method: auth method description
            - service: human-readable service name
            - error: error message or None
    """
    result = {
        "available": False,
        "method": SERVICE_AUTH.get(service, "unknown"),
        "service": SERVICE_NAMES.get(service, service),
        "error": None,
    }

    config = load_config()

    if service == "moz":
        api_key = config.get("moz_api_key")
        if api_key:
            result["available"] = True
            result["method"] = "api_key_configured"
            result["verified"] = False
            result["note"] = (
                "Moz credentials are configured but not live-verified by --check. "
                "Run a Moz command such as `python scripts/moz_api.py metrics "
                "example.com --json` to test quota and permissions."
            )
        else:
            result["error"] = (
                "No Moz API key found. Set MOZ_API_KEY environment variable "
                f"or add 'moz_api_key' to {CONFIG_PATH}\n"
                "         Sign up free at https://moz.com/products/api"
            )

    elif service == "bing":
        api_key = config.get("bing_api_key")
        if api_key:
            result["available"] = True
            result["method"] = "api_key_configured"
            result["verified"] = False
            sites = config.get("bing_verified_sites", [])
            if sites:
                result["verified_sites"] = sites
                result["note"] = (
                    "Bing credentials and site list are configured but not live-verified "
                    "by --check. Run a Bing Webmaster query to test access."
                )
            else:
                result["note"] = (
                    "Bing API key is configured but not live-verified. No verified "
                    "sites are listed; add 'bing_verified_sites' to config for "
                    "site-specific backlink queries."
                )
        else:
            result["error"] = (
                "No Bing Webmaster API key found. Set BING_WEBMASTER_API_KEY "
                f"environment variable or add 'bing_api_key' to {CONFIG_PATH}\n"
                "         Get free key at https://www.bing.com/webmasters"
            )

    elif service == "commoncrawl":
        # Common Crawl is always available (public data, no auth needed)
        result["available"] = True
        result["method"] = "none (public data)"
        cache_dir = config.get("commoncrawl_cache_dir", CACHE_DIR)
        result["cache_dir"] = cache_dir
        if os.path.exists(cache_dir):
            cached_files = [f for f in os.listdir(cache_dir) if f.endswith(".json")]
            result["cached_domains"] = len(cached_files)
        else:
            result["cached_domains"] = 0

    elif service == "verify":
        # Verification crawler is always available (uses fetch_page.py + parse_html.py)
        result["available"] = True
        result["method"] = "none (local crawler)"
        # Check that required scripts exist
        fetch_script = os.path.join(_SCRIPTS_DIR, "fetch_page.py")
        parse_script = os.path.join(_SCRIPTS_DIR, "parse_html.py")
        if not os.path.exists(fetch_script):
            result["available"] = False
            result["error"] = f"Required script not found: {fetch_script}"
        elif not os.path.exists(parse_script):
            result["available"] = False
            result["error"] = f"Required script not found: {parse_script}"

    else:
        result["error"] = f"Unknown service: {service}"

    return result


def detect_tier() -> dict:
    """
    Detect the backlink credential tier available.

    Tier 0: No API keys (Common Crawl + Verification Crawler always available)
    Tier 1: Moz API key configured
    Tier 2: Moz + Bing configured
    Tier 3: All + DataForSEO MCP available (checked externally)

    Returns:
        Dictionary with tier, description, capabilities, missing.
    """
    config = load_config()

    has_moz = bool(config.get("moz_api_key"))
    has_bing = bool(config.get("bing_api_key"))

    if has_moz and has_bing:
        return {
            "tier": 2,
            "description": "Full Free (Moz + Bing + Common Crawl + Verify)",
            "capabilities": [
                "Moz DA/PA/Spam Score (any domain)",
                "Moz referring domains and anchors",
                "Bing inbound links (verified sites)",
                "Bing comparison between registered properties",
                "Common Crawl domain-level graph",
                "Backlink verification crawler",
            ],
            "missing": "Add DataForSEO extension for premium backlink data (paid)",
        }
    elif has_moz:
        return {
            "tier": 1,
            "description": "Moz Only (Moz + Common Crawl + Verify)",
            "capabilities": [
                "Moz DA/PA/Spam Score (any domain)",
                "Moz referring domains and anchors",
                "Common Crawl domain-level graph",
                "Backlink verification crawler",
            ],
            "missing": (
                "Add Bing Webmaster API key for registered-property link data. "
                "Free at https://www.bing.com/webmasters"
            ),
        }
    else:
        return {
            "tier": 0,
            "description": "Basic (Common Crawl + Verify only)",
            "capabilities": [
                "Common Crawl domain-level graph (PageRank, in-degree)",
                "Backlink verification crawler",
            ],
            "missing": (
                "Add Moz API key for DA/PA and spam scoring. "
                "Free at https://moz.com/products/api (2,500 rows/month)"
            ),
        }


def get_moz_api_key() -> Optional[str]:
    """Get the Moz API key from config or environment."""
    config = load_config()
    return config.get("moz_api_key")


def get_bing_api_key() -> Optional[str]:
    """Get the Bing Webmaster API key from config or environment."""
    config = load_config()
    return config.get("bing_api_key")


def get_bing_verified_sites() -> list:
    """Get the list of Bing-verified sites from config."""
    config = load_config()
    return config.get("bing_verified_sites", [])


def get_cache_dir() -> str:
    """Get the Common Crawl cache directory, creating it if needed."""
    config = load_config()
    cache_dir = config.get("commoncrawl_cache_dir", CACHE_DIR)
    os.makedirs(cache_dir, exist_ok=True)
    return cache_dir


def print_setup_instructions():
    """Print step-by-step setup instructions for all backlink APIs."""
    print("""
Backlink API Setup Instructions
================================

Free backlink data sources for Claude SEO. No payment required for any of these.

TIER 0: ALWAYS AVAILABLE (no setup needed)
------------------------------------------
  Common Crawl Web Graph: Public domain-level link data with PageRank.
  Backlink Verification:  Crawls pages to verify if backlinks still exist.

  These work immediately with no configuration.

TIER 1: MOZ API (free signup, 2,500 rows/month)
-------------------------------------------------
  1. Go to https://moz.com/products/api
  2. Click "Start your free 30-day trial" or "Get Free Access"
     (Free tier continues after trial with 2,500 rows/month)
  3. A valid credit card is required at signup but will NOT be charged
  4. After signup, go to https://moz.com/products/api/keys
  5. Copy your API credentials. Claude SEO accepts either:
     - a token-style key (looks like: mozscape-xxxxxxxx)
     - free-tier accessId:secret credentials, raw or base64 encoded

  Configure:
    export MOZ_API_KEY="mozscape-xxxxxxxx"
    # or: export MOZ_API_KEY="accessId:secret"

  Or save to """ + CONFIG_PATH + """:
    {
      "moz_api_key": "mozscape-xxxxxxxx"
    }

  Provides: Domain Authority, Page Authority, Spam Score, link counts,
            referring domains, anchor text distribution (any domain).
  Rate limit: 1 request per 10 seconds.
  Note: `--check moz` reports whether credentials are configured; run
        `python scripts/moz_api.py metrics example.com --json` for a live
        permission/quota test.

TIER 2: + BING WEBMASTER TOOLS API (free, verified sites)
-----------------------------------------------------------
  1. Go to https://www.bing.com/webmasters
  2. Sign in with Microsoft account
  3. Add and verify your site(s) (DNS, meta tag, or CNAME)
  4. Go to Settings > API access > API key
  5. Copy your API key

  Add to """ + CONFIG_PATH + """:
    {
      "moz_api_key": "mozscape-xxxxxxxx",
      "bing_api_key": "your-bing-api-key",
      "bing_verified_sites": ["example.com", "other-site.com"]
    }

  Or set environment variable:
    export BING_WEBMASTER_API_KEY="your-bing-api-key"

  Provides: Inbound links with anchor text, referring domains,
            competitor backlink comparison (unique feature!).
  Limitation: Only works for verified sites + their competitors.

PREMIUM: DATAFORSEO EXTENSION (paid, most comprehensive)
----------------------------------------------------------
  For full commercial-grade backlink data, install the DataForSEO extension:
    ./extensions/dataforseo/install.sh

  Provides: 35+ trillion links, real-time updates, toxic scoring,
            anchor text, competitor gap analysis, link velocity.

VERIFY CONFIGURATION:
  python scripts/backlinks_auth.py --check
  python scripts/backlinks_auth.py --tier
  `--check` is configuration-only for Moz/Bing and does not claim live
  verification unless a specific API query has been run.
""")


def main():
    parser = argparse.ArgumentParser(
        description="Backlink API credential management for Claude SEO"
    )
    parser.add_argument(
        "--check",
        nargs="?",
        const="all",
        metavar="SERVICE",
        help="Check credentials. Optionally specify: moz, bing, commoncrawl, verify",
    )
    parser.add_argument(
        "--setup",
        action="store_true",
        help="Show setup instructions",
    )
    parser.add_argument(
        "--tier",
        action="store_true",
        help="Show detected credential tier",
    )
    parser.add_argument(
        "--json",
        action="store_true",
        help="Output as JSON",
    )

    args = parser.parse_args()

    if args.setup:
        print_setup_instructions()
        return

    if args.tier:
        tier_info = detect_tier()
        if args.json:
            print(json.dumps(tier_info, indent=2))
        else:
            print(f"Backlink Tier: {tier_info['tier']} -- {tier_info['description']}")
            if tier_info["capabilities"]:
                print(f"Capabilities: {', '.join(tier_info['capabilities'])}")
            if tier_info["missing"]:
                print(f"Next tier: {tier_info['missing']}")
        return

    if args.check:
        services = (
            list(SERVICE_AUTH.keys())
            if args.check == "all"
            else [args.check]
        )

        results = {}
        for svc in services:
            if svc not in SERVICE_AUTH:
                results[svc] = {"available": False, "error": f"Unknown service: {svc}"}
                continue
            results[svc] = check_credentials(svc)

        if args.json:
            tier_info = detect_tier()
            output = {"status": "success", "tier": tier_info, "services": results}
            print(json.dumps(output, indent=2))
        else:
            tier_info = detect_tier()
            print(f"Backlink Tier: {tier_info['tier']} -- {tier_info['description']}")
            print()
            for svc, result in results.items():
                status = "OK" if result["available"] else "MISSING"
                print(f"  [{status}] {result.get('service', svc)}")
                if result.get("error"):
                    print(f"         {result['error']}")
                if result.get("verified_sites"):
                    print(f"         Verified sites: {', '.join(result['verified_sites'])}")
                if result.get("note"):
                    print(f"         Note: {result['note']}")
                if result.get("cached_domains") is not None:
                    print(f"         Cached domains: {result['cached_domains']}")
            print()
            if tier_info["missing"]:
                print(f"Tip: {tier_info['missing']}")
        return

    # Default: show tier
    tier_info = detect_tier()
    if args.json:
        print(json.dumps({"status": "success", "tier": tier_info}, indent=2))
    else:
        print(f"Backlink Tier: {tier_info['tier']} -- {tier_info['description']}")
        if tier_info["missing"]:
            print("Run --setup for configuration instructions.")


if __name__ == "__main__":
    main()
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall