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.
feat: add scripts/sync_flow.py — GitHub API sync for FLOW prompt library (Codex, reviewed)
Daniel2ab83b5df367
diff --git a/scripts/sync_flow.py b/scripts/sync_flow.pynew file mode 100644index 0000000..821ddfe--- /dev/null+++ b/scripts/sync_flow.py@@ -0,0 +1,195 @@+"""Sync Flow operational references from GitHub into the seo-flow skill."""++import argparse+import base64+import datetime+import json+import os+import pathlib+import subprocess+import sys+import urllib.request+++API_ROOT = "https://api.github.com/repos/AgriciDaniel/flow/contents"+PROMPT_STAGES = ["find", "leverage", "optimize", "win", "local"]+STATIC_FILES = [+ ("docs/01-framework/flow-framework.md", "flow-framework.md"),+ ("docs/10-references/bibliography.md", "bibliography.md"),+]+++def script_root():+ script_dir = os.path.dirname(os.path.abspath(__file__))+ return pathlib.Path(script_dir).parent+++def parse_args():+ epilog = (+ "Modes: no flags sync all files to disk; --dry-run reports changes "+ "without writing; --ref <sha> syncs from a specific Flow commit."+ )+ parser = argparse.ArgumentParser(+ description="Sync Flow references into skills/seo-flow/references/.",+ epilog=epilog,+ )+ parser.add_argument("--dry-run", action="store_true", help="Report changes without writing files.")+ parser.add_argument("--ref", metavar="SHA", help="Pin fetches to a Flow commit SHA.")+ return parser.parse_args()+++def github_headers():+ result = subprocess.run(["gh", "auth", "token"], capture_output=True, text=True)+ token = result.stdout.strip()+ return {+ "Authorization": f"Bearer {token}",+ "Accept": "application/vnd.github+json",+ "X-GitHub-Api-Version": "2022-11-28",+ }+++def content_url(path, ref):+ return f"{API_ROOT}/{path}" + (f"?ref={ref}" if ref else "")+++def api_get(path, ref, headers):+ request = urllib.request.Request(content_url(path, ref), headers=headers)+ with urllib.request.urlopen(request) as response:+ return json.loads(response.read().decode("utf-8"))+++def fetch_file(path, ref, headers):+ data = api_get(path, ref, headers)+ content = data.get("content", "")+ return base64.b64decode(content).decode("utf-8")+++def list_markdown_files(path, ref, headers):+ data = api_get(path, ref, headers)+ files = [+ (item["path"], item["name"])+ for item in data+ if item.get("type") == "file" and item.get("name", "").endswith(".md")+ ]+ return sorted(files, key=lambda item: item[1].lower())+++def attribution_header(today):+ return (+ "<!-- Source: github.com/AgriciDaniel/flow | License: CC BY 4.0 | "+ f"Synced: {today} -->"+ )+++def frontmatter_value(lines, key):+ if not lines or lines[0].strip() != "---":+ return ""+ needle = f"{key}:"+ for line in lines[1:]:+ stripped = line.strip()+ if stripped == "---":+ break+ if stripped.lower().startswith(needle):+ value = stripped[len(needle) :].strip()+ return value.strip("\"'")+ return ""+++def body_lines_after_frontmatter(lines):+ if not lines or lines[0].strip() != "---":+ return lines+ for index, line in enumerate(lines[1:], 1):+ if line.strip() == "---":+ return lines[index + 1 :]+ return lines+++def first_h1(lines):+ for line in body_lines_after_frontmatter(lines):+ stripped = line.strip()+ if stripped.startswith("# "):+ return stripped[2:].strip()+ return ""+++def first_description(lines):+ for line in body_lines_after_frontmatter(lines):+ stripped = line.strip()+ if stripped and not stripped.startswith("#"):+ return stripped+ return ""+++def prompt_meta(stage, filename, raw):+ lines = raw.splitlines()+ return {+ "stage": stage,+ "filename": filename,+ "title": frontmatter_value(lines, "title") or first_h1(lines),+ "description": frontmatter_value(lines, "description") or first_description(lines),+ }+++def escape_cell(value):+ return str(value).replace("|", "\\|").replace("\n", " ").strip()+++def prompt_readme(rows):+ lines = ["# Flow Prompt Index", "", "| Stage | Filename | Title | Description |", "|---|---|---|---|"]+ for row in rows:+ lines.append(+ "| {stage} | {filename} | {title} | {description} |".format(+ stage=escape_cell(row["stage"]),+ filename=escape_cell(row["filename"]),+ title=escape_cell(row["title"]),+ description=escape_cell(row["description"]),+ )+ )+ return "\n".join(lines) + "\n"+++def record_write(root, path, content, dry_run, changes):+ rel = path.relative_to(root).as_posix()+ if path.exists():+ current = path.read_text(encoding="utf-8")+ bucket = "unchanged" if current == content else "updated"+ else:+ bucket = "added"+ changes[bucket].append(rel)+ print(f"{bucket}: {rel}", file=sys.stderr)+ if not dry_run and bucket != "unchanged":+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(content, encoding="utf-8")+++def sync(args):+ root = script_root()+ refs = root / "skills" / "seo-flow" / "references"+ today = datetime.date.today().isoformat()+ headers = github_headers()+ changes = {"added": [], "updated": [], "unchanged": []}+ prompt_rows = []++ for source, target in STATIC_FILES:+ print(f"fetch: {source}", file=sys.stderr)+ raw = fetch_file(source, args.ref, headers)+ content = f"{attribution_header(today)}\n{raw}"+ record_write(root, refs / target, content, args.dry_run, changes)++ for stage in PROMPT_STAGES:+ source_dir = f"docs/09-prompts/{stage}"+ print(f"list: {source_dir}", file=sys.stderr)+ for source, filename in list_markdown_files(source_dir, args.ref, headers):+ print(f"fetch: {source}", file=sys.stderr)+ raw = fetch_file(source, args.ref, headers)+ prompt_rows.append(prompt_meta(stage, filename, raw))+ target = refs / "prompts" / stage / filename+ content = f"{attribution_header(today)}\n{raw}"+ record_write(root, target, content, args.dry_run, changes)++ record_write(root, refs / "prompts" / "README.md", prompt_readme(prompt_rows), args.dry_run, changes)+ return changes+++if __name__ == "__main__":+ print(json.dumps(sync(parse_args()), sort_keys=True))