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(audit): raise subagent turn budgets and write findings early
Agrici Daniel614013bbc857
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c953e25..70ec626 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,6 +28,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0no longer aborts on a marketplace/plugin install: it now also checks`${CLAUDE_PLUGIN_ROOT}` and the plugin cache before requiring the manual`~/.claude/skills/seo` layout. Fixes #189.+- Raised `maxTurns` on all 16 agents `seo-audit` can spawn (`seo-technical`+ 20→45, `seo-content` 15→45, and thirteen others that were below 30) so a+ large-site audit doesn't hit its turn budget before finishing. Every one of+ those agents now writes a partial findings file after its first analysis+ pass and overwrites it with the complete findings at the end, so a+ turn-budget stop never throws away completed work; `seo-audit`'s+ error-handling table documents the same contract for the orchestrator.+ Fixes #177, #272.## [2.2.6] - 2026-09-10diff --git a/agents/seo-backlinks.md b/agents/seo-backlinks.mdindex 25f4248..e541dd2 100644--- a/agents/seo-backlinks.md+++ b/agents/seo-backlinks.md@@ -2,7 +2,7 @@name: seo-backlinksdescription: Backlink profile analyst using free and paid sources. Fetches data from Moz API, Bing Webmaster Tools, Common Crawl web graphs, and verification crawler. Merges multi-source data with confidence-weighted scoring.model: sonnet-maxTurns: 20+maxTurns: 40tools: Read, Bash, Write, Glob, Grep---@@ -122,6 +122,8 @@ Backlink verification (`/seo backlinks verify`) primarily reads outbound `<a>` t## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/backlinks.md`: backlink source coverage, authority, anchor text, toxicity, and verification findings- Structured JSON-compatible findings for `audit-data.json` under the Backlink Profile categorydiff --git a/agents/seo-cluster.md b/agents/seo-cluster.mdindex f94dd4c..5b2afae 100644--- a/agents/seo-cluster.md+++ b/agents/seo-cluster.md@@ -5,7 +5,7 @@ description: >keywords, performs pairwise SERP comparison, classifies intent, designshub-and-spoke content architecture, and generates internal link matrices.model: sonnet-maxTurns: 20+maxTurns: 40tools: WebSearch, WebFetch, Read, Write, Bash, Glob, Grep---@@ -50,7 +50,9 @@ Your primary output is a `cluster-plan.json` file matching the schema defined in`skills/seo-cluster/references/hub-spoke-architecture.md`. Also produce ahuman-readable `cluster-plan.md` summary.-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/cluster.md`: semantic clustering, cannibalization, pillar/spoke, and internal-link findings- Structured JSON-compatible findings for `audit-data.json` under the Content Architecture categorydiff --git a/agents/seo-content.md b/agents/seo-content.mdindex 11fdd30..4b3f773 100644--- a/agents/seo-content.md+++ b/agents/seo-content.md@@ -2,7 +2,7 @@name: seo-contentdescription: Content quality reviewer. Evaluates E-E-A-T signals, readability, content depth, AI citation readiness, and thin content detection.model: sonnet-maxTurns: 15+maxTurns: 45tools: Read, Bash, Write, Grep---@@ -75,7 +75,9 @@ Use `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run render_page.py <URL> --mode## Persistence Contract-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/content.md`: E-E-A-T, readability, thin content, duplication, topical coverage, and AI citation findings- Structured JSON-compatible findings for `audit-data.json` under the Content Quality categorydiff --git a/agents/seo-dataforseo.md b/agents/seo-dataforseo.mdindex f03e6ba..256bdbb 100644--- a/agents/seo-dataforseo.md+++ b/agents/seo-dataforseo.md@@ -2,7 +2,7 @@name: seo-dataforseodescription: DataForSEO data analyst. Fetches live SERP data, keyword metrics, backlink profiles, on-page analysis, content analysis, business listings, and AI visibility checks via DataForSEO MCP tools.model: sonnet-maxTurns: 25+maxTurns: 35tools: Read, Write, Glob, Grep, mcp__dataforseo__*---@@ -36,3 +36,11 @@ Match existing claude-seo patterns:- Priority: Critical > High > Medium > Low- Note data source as "DataForSEO (live)" to distinguish from static HTML analysis- Include timestamps for time-sensitive data (SERP positions, backlink counts)++## Audit Persistence++If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:+- `output_dir/findings/dataforseo.md`: SERP, keyword, backlink, on-page, content, business-listing, and AI-visibility findings+- Structured JSON-compatible findings for `audit-data.json` under the DataForSEO Live Data categorydiff --git a/agents/seo-drift.md b/agents/seo-drift.mdindex db31d0c..08bc197 100644--- a/agents/seo-drift.md+++ b/agents/seo-drift.md@@ -5,7 +5,7 @@ description: >compares against stored snapshots to detect regressions. Reports changes withseverity classification. Only spawned when a drift baseline exists for the URL.model: sonnet-maxTurns: 15+maxTurns: 30tools: Read, Bash, Write, Glob, Grep---@@ -64,6 +64,8 @@ For comparisons, present:## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/drift.md`: baseline availability, triggered rules, old/new values, and regression findings- Structured JSON-compatible findings for `audit-data.json` under the SEO Drift categorydiff --git a/agents/seo-ecommerce.md b/agents/seo-ecommerce.mdindex fef4bb5..45335a5 100644--- a/agents/seo-ecommerce.md+++ b/agents/seo-ecommerce.md@@ -5,7 +5,7 @@ description: >Amazon marketplace visibility, identifies pricing gaps, and recommends productpage optimizations. Spawned when e-commerce site detected during audits.model: sonnet-maxTurns: 20+maxTurns: 35tools: Read, Bash, Write, Glob, Grep---@@ -75,6 +75,8 @@ E-commerce sites overwhelmingly inject product schema client-side (Shopify, Mage## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/ecommerce.md`: product schema, marketplace, image, pricing, content, and internal-link findings- Structured JSON-compatible findings for `audit-data.json` under the E-commerce SEO categorydiff --git a/agents/seo-geo.md b/agents/seo-geo.mdindex 1516af6..e25ec72 100644--- a/agents/seo-geo.md+++ b/agents/seo-geo.md@@ -2,7 +2,7 @@name: seo-geodescription: GEO and AI search specialist. Analyzes AI crawler accessibility, llms.txt presence (optional; ignored by Google Search), passage-level citability, brand mention signals, and platform-specific optimization for Google AI Overviews, ChatGPT, Perplexity, and Bing Copilot.model: sonnet-maxTurns: 20+maxTurns: 35tools: Read, Bash, WebFetch, Glob, Grep, Write---@@ -75,6 +75,8 @@ AI citation analysis benefits from the `extracted_text` field, passage-level sco## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/geo.md`: AI crawler access, llms.txt, citability, entity, and platform visibility findings- Structured JSON-compatible findings for `audit-data.json` under the AI Search Readiness categorydiff --git a/agents/seo-google.md b/agents/seo-google.mdindex 68acc42..8d16e27 100644--- a/agents/seo-google.md+++ b/agents/seo-google.md@@ -2,7 +2,7 @@name: seo-googledescription: Google SEO API analyst. Fetches CWV field data via CrUX, indexation status via GSC, and organic traffic via GA4 for enriched audit data.model: sonnet-maxTurns: 15+maxTurns: 35tools: Read, Bash, Write, Glob, Grep # Write needed for report/data file output---@@ -65,7 +65,9 @@ Before presenting: verify `"review": {"status": "PASS"}` in the JSON output.## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/google.md`: PSI, CrUX, GSC, URL Inspection, GA4, and credential-tier findings- Structured JSON-compatible findings for `audit-data.json` under the Google SEO Data category- Generated PDF/HTML/XLSX reports under `output_dir/` with `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run google_report.py --output-dir "$output_dir"`diff --git a/agents/seo-local.md b/agents/seo-local.mdindex 3ba5aba..5cc9414 100644--- a/agents/seo-local.md+++ b/agents/seo-local.md@@ -2,7 +2,7 @@name: seo-localdescription: Local SEO specialist. Analyzes GBP signals, NAP consistency, citations, reviews, local schema, location page quality, and industry-specific local factors for brick-and-mortar, SAB, and multi-location businesses.model: sonnet-maxTurns: 20+maxTurns: 32tools: Read, Bash, WebFetch, Glob, Grep, Write---@@ -89,6 +89,8 @@ Map embeds, GBP widgets, and review carousels are commonly injected client-side.## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/local.md`: GBP, NAP, reviews, local schema, citation, and location-page findings- Structured JSON-compatible findings for `audit-data.json` under the Local SEO categorydiff --git a/agents/seo-maps.md b/agents/seo-maps.mdindex 29ae57a..63c54c1 100644--- a/agents/seo-maps.md+++ b/agents/seo-maps.md@@ -2,7 +2,7 @@name: seo-mapsdescription: Maps intelligence specialist. Geo-grid rank tracking, GBP profile auditing, review intelligence, cross-platform NAP verification, and competitor radius mapping via DataForSEO and free APIs.model: sonnet-maxTurns: 25+maxTurns: 40tools: Read, Bash, WebFetch, Glob, Grep, Write---@@ -84,6 +84,8 @@ Provide a structured report with:## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/maps.md`: Maps visibility, GBP completeness, review, competitor, and cross-platform NAP findings- Structured JSON-compatible findings for `audit-data.json` under the Maps Visibility categorydiff --git a/agents/seo-performance.md b/agents/seo-performance.mdindex 863c5a2..0623111 100644--- a/agents/seo-performance.md+++ b/agents/seo-performance.md@@ -2,7 +2,7 @@name: seo-performancedescription: Performance analyzer. Measures and evaluates Core Web Vitals and page load performance.model: sonnet-maxTurns: 15+maxTurns: 35tools: Read, Bash, Write---@@ -99,7 +99,9 @@ Provide:## Persistence Contract-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/performance.md`: evidence, scores, bottlenecks, and recommendations- Structured JSON-compatible findings for `audit-data.json` under the Performance categorydiff --git a/agents/seo-schema.md b/agents/seo-schema.mdindex 2efe162..905cb0a 100644--- a/agents/seo-schema.md+++ b/agents/seo-schema.md@@ -2,7 +2,7 @@name: seo-schemadescription: Schema markup expert. Detects, validates, and generates Schema.org structured data in JSON-LD format.model: sonnet-maxTurns: 15+maxTurns: 35tools: Read, Bash, Write---@@ -78,7 +78,9 @@ Use the JSON response's `structured_data` summary for routine JSON-LD detection.## Persistence Contract-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/schema.md`: detected schema, validation errors, missing opportunities, and generated recommendations- Structured JSON-compatible findings for `audit-data.json` under the Schema / Structured Data categorydiff --git a/agents/seo-sitemap.md b/agents/seo-sitemap.mdindex 863ac18..2366d18 100644--- a/agents/seo-sitemap.md+++ b/agents/seo-sitemap.md@@ -2,7 +2,7 @@name: seo-sitemapdescription: Sitemap architect. Validates XML sitemaps, generates new ones with industry templates, and enforces quality gates for location pages.model: sonnet-maxTurns: 15+maxTurns: 30tools: Read, Bash, Write, Glob---@@ -75,6 +75,8 @@ Provide:## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/sitemap.md`: sitemap coverage, XML validity, URL status, and quality gate findings- Structured JSON-compatible findings for `audit-data.json` under the Sitemap categorydiff --git a/agents/seo-sxo.md b/agents/seo-sxo.mdindex db0da2d..186076e 100644--- a/agents/seo-sxo.md+++ b/agents/seo-sxo.md@@ -5,7 +5,7 @@ description: >page-type mismatches, derives user stories from intent signals, and scores pagesfrom multiple persona perspectives. Identifies why well-optimized content fails to rank.model: sonnet-maxTurns: 20+maxTurns: 35tools: Read, Bash, WebFetch, WebSearch, Glob, Grep, Write---@@ -105,6 +105,8 @@ Search experience scoring needs the *rendered* DOM because users see what JS pro## Audit Persistence-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/sxo.md`: SERP intent, page-type mismatch, user-story, persona, and UX gap findings- Structured JSON-compatible findings for `audit-data.json` under the Search Experience categorydiff --git a/agents/seo-technical.md b/agents/seo-technical.mdindex a8713c0..765c5d4 100644--- a/agents/seo-technical.md+++ b/agents/seo-technical.md@@ -2,7 +2,7 @@name: seo-technicaldescription: Technical SEO specialist. Analyzes crawlability, indexability, security, URL structure, mobile optimization, Core Web Vitals, and JavaScript rendering.model: sonnet-maxTurns: 20+maxTurns: 45tools: Read, Bash, Write, Glob, Grep # Write needed for report/data file output---@@ -63,7 +63,9 @@ Use `"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run render_page.py <URL> --mode## Persistence Contract-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/findings/technical.md`: crawlability, indexability, security, URL, mobile, rendering, and agent-UX findings- Structured JSON-compatible findings for `audit-data.json` under the Technical SEO categorydiff --git a/agents/seo-visual.md b/agents/seo-visual.mdindex d3f18f7..e68e0c9 100644--- a/agents/seo-visual.md+++ b/agents/seo-visual.md@@ -2,7 +2,7 @@name: seo-visualdescription: Visual analyzer. Captures screenshots, tests mobile rendering, and analyzes above-the-fold content using Playwright.model: sonnet-maxTurns: 15+maxTurns: 35tools: Read, Bash, Write---@@ -77,7 +77,9 @@ Provide:## Persistence Contract-If `output_dir` is provided by the audit orchestrator, write:+If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:- `output_dir/screenshots/desktop.png` and `output_dir/screenshots/mobile.png` when capture succeeds- `output_dir/findings/visual.md`: above-the-fold, mobile, layout, and accessibility-tree findingsdiff --git a/extensions/dataforseo/agents/seo-dataforseo.md b/extensions/dataforseo/agents/seo-dataforseo.mdindex 700cd85..082d5a6 100644--- a/extensions/dataforseo/agents/seo-dataforseo.md+++ b/extensions/dataforseo/agents/seo-dataforseo.md@@ -34,3 +34,11 @@ Match existing claude-seo patterns:- Priority: Critical > High > Medium > Low- Note data source as "DataForSEO (live)" to distinguish from static HTML analysis- Include timestamps for time-sensitive data (SERP positions, backlink counts)++## Audit Persistence++If `output_dir` is provided by the audit orchestrator, write a partial findings+file after the first analysis pass and overwrite it with the complete findings+before finishing, so a turn-budget stop never loses completed work:+- `output_dir/findings/dataforseo.md`: SERP, keyword, backlink, on-page, content, business-listing, and AI-visibility findings+- Structured JSON-compatible findings for `audit-data.json` under the DataForSEO Live Data categorydiff --git a/skills/seo-audit/SKILL.md b/skills/seo-audit/SKILL.mdindex 76f4d73..2270b64 100644--- a/skills/seo-audit/SKILL.md+++ b/skills/seo-audit/SKILL.md@@ -180,3 +180,4 @@ If Google API credentials are configured (`"${CLAUDE_PLUGIN_ROOT}/scripts/claude| robots.txt blocks crawling | Report which paths are blocked. Analyze only accessible pages and note the limitation in the report. || Rate limiting (429 responses) | Back off and reduce concurrent requests. Report partial results with a note on which sections could not be completed. || Timeout on large sites (500+ pages) | Cap the crawl at the timeout limit. Report findings for pages crawled and estimate total site scope. |+| Subagent hits its `maxTurns` budget on a large site | Findings are not lost: every audit subagent writes a partial `output_dir/findings/*.md` after its first analysis pass and overwrites it with the complete findings before finishing. Read whatever findings file exists and merge it into the report, noting it may be partial. |diff --git a/tests/test_audit_agent_turn_budget.py b/tests/test_audit_agent_turn_budget.pynew file mode 100644index 0000000..96ca4b7--- /dev/null+++ b/tests/test_audit_agent_turn_budget.py@@ -0,0 +1,87 @@+"""Audit subagent turn-budget and early-write regressions (issues #177, #272).++Reporters found that seo-audit subagents were hitting their `maxTurns` cap on+large sites before ever writing a findings file, so a turn-budget stop threw+away all completed work. The fix has two parts for every subagent+`skills/seo-audit/SKILL.md` can spawn:++1. `maxTurns` raised well above the old defaults (seo-technical was 20,+ seo-content was 15; both need real headroom for a 500-page crawl).+2. An explicit instruction to write a partial findings file after the first+ analysis pass and overwrite it with the complete findings at the end, so+ a maxTurns stop mid-audit still leaves usable output on disk.+"""++from __future__ import annotations++import re+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+AUDIT_SKILL = ROOT / "skills" / "seo-audit" / "SKILL.md"+AGENTS_DIR = ROOT / "agents"++EARLY_WRITE_SENTENCE = (+ "write a partial findings\nfile after the first analysis pass and overwrite it with the complete findings\nbefore finishing, so a turn-budget stop never loses completed work"+)++MIN_MAX_TURNS = 30+NAMED_HIGH_BUDGET_AGENTS = {"seo-technical": 40, "seo-content": 40}+++def _discover_audit_agents() -> set[str]:+ text = AUDIT_SKILL.read_text(encoding="utf-8")+ return set(re.findall(r"`(seo-[a-z-]+)`", text))+++def test_audit_skill_still_names_the_known_subagent_set():+ # Locks the known set so a future addition/removal to seo-audit's+ # delegation list is a deliberate, reviewed change.+ assert _discover_audit_agents() == {+ "seo-technical", "seo-content", "seo-schema", "seo-sitemap",+ "seo-performance", "seo-visual", "seo-geo", "seo-local", "seo-maps",+ "seo-google", "seo-backlinks", "seo-cluster", "seo-sxo", "seo-drift",+ "seo-ecommerce", "seo-dataforseo",+ }+++def _max_turns(text: str) -> int | None:+ match = re.search(r"^maxTurns:\s*(\d+)", text, re.MULTILINE)+ return int(match.group(1)) if match else None+++def test_every_audit_agent_has_a_turn_budget_at_least_30():+ agents = _discover_audit_agents()+ assert agents, "expected at least one audit subagent"+ failures = []+ for name in sorted(agents):+ path = AGENTS_DIR / f"{name}.md"+ assert path.is_file(), f"missing agent file for {name}"+ turns = _max_turns(path.read_text(encoding="utf-8"))+ if turns is None or turns < MIN_MAX_TURNS:+ failures.append((name, turns))+ assert not failures, f"agents below maxTurns={MIN_MAX_TURNS}: {failures}"+++def test_named_reporters_agents_have_at_least_40_turns():+ for name, minimum in NAMED_HIGH_BUDGET_AGENTS.items():+ path = AGENTS_DIR / f"{name}.md"+ turns = _max_turns(path.read_text(encoding="utf-8"))+ assert turns is not None and turns >= minimum, (+ f"{name} maxTurns={turns} is below the required {minimum}"+ )+++def test_every_audit_agent_has_the_early_write_instruction():+ missing = []+ for name in sorted(_discover_audit_agents()):+ text = (AGENTS_DIR / f"{name}.md").read_text(encoding="utf-8")+ if EARLY_WRITE_SENTENCE not in text:+ missing.append(name)+ assert not missing, f"agents missing the early-write instruction: {missing}"+++def test_dataforseo_extension_mirror_also_has_the_early_write_instruction():+ mirror = ROOT / "extensions" / "dataforseo" / "agents" / "seo-dataforseo.md"+ text = mirror.read_text(encoding="utf-8")+ assert EARLY_WRITE_SENTENCE in text