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.

3.1 KB
Raw Blame
"""Static instruction guards for full audit persistence and SPA wiring."""

from __future__ import annotations

from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parents[1]


def test_seo_audit_starts_with_render_page_auto() -> None:
    text = (REPO_ROOT / "skills" / "seo-audit" / "SKILL.md").read_text(encoding="utf-8")
    process = text[text.index("## Process"):text.index("## Crawl Configuration")]
    assert '"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run render_page.py' in process
    assert "python3 scripts/render_page.py" not in process
    assert "--mode auto" in process
    assert "scripts/fetch_page.py` to retrieve HTML" not in process


def test_seo_audit_requires_persistent_artifacts() -> None:
    text = (REPO_ROOT / "skills" / "seo-audit" / "SKILL.md").read_text(encoding="utf-8")
    for artifact in (
        "FULL-AUDIT-REPORT.md",
        "ACTION-PLAN.md",
        "audit-data.json",
        "findings/",
        "screenshots/",
    ):
        assert artifact in text
    assert "{domain}-audit" in text


def test_audit_agents_use_renderer_or_capture_script() -> None:
    expectations = {
        "seo-performance.md": "render_page.py",
        "seo-visual.md": "capture_screenshot.py",
        "seo-technical.md": "render_page.py",
        "seo-content.md": "render_page.py",
        "seo-schema.md": "render_page.py",
    }
    for filename, marker in expectations.items():
        text = (REPO_ROOT / "agents" / filename).read_text(encoding="utf-8")
        assert marker in text, f"{filename} must mention {marker}"


def test_audit_agents_document_output_dir_findings_contract() -> None:
    for filename in (
        "seo-performance.md",
        "seo-visual.md",
        "seo-technical.md",
        "seo-content.md",
        "seo-schema.md",
        "seo-sitemap.md",
        "seo-geo.md",
        "seo-local.md",
        "seo-maps.md",
        "seo-google.md",
        "seo-backlinks.md",
        "seo-cluster.md",
        "seo-sxo.md",
        "seo-drift.md",
        "seo-ecommerce.md",
        "seo-agentic.md",
    ):
        text = (REPO_ROOT / "agents" / filename).read_text(encoding="utf-8")
        assert "output_dir" in text
        assert "findings/" in text


def test_seo_audit_report_command_keeps_outputs_in_audit_dir() -> None:
    text = (REPO_ROOT / "skills" / "seo-audit" / "SKILL.md").read_text(encoding="utf-8")
    assert "--output-dir {domain}-audit/" in text


def test_hub_invocation_keeps_the_command_word() -> None:
    """Claude Code indexes skill arguments from 0. $1 is the second word (#342).

    https://code.claude.com/docs/en/skills
    $ARGUMENTS is the full input. $0 is the first argument, $1 the second.
    An index with no argument stays literal, and ARGUMENTS is appended only
    when no placeholder received a value. `/seo $1 $2` therefore drops `audit`
    from `/seo audit https://example.com`.
    """
    text = (REPO_ROOT / "skills" / "seo" / "SKILL.md").read_text(encoding="utf-8")
    invocation = next(line for line in text.splitlines() if line.startswith("**Invocation:**"))
    assert "$1" not in invocation
    assert "$2" not in invocation
    assert invocation.startswith("**Invocation:** `/seo $ARGUMENTS`")