Phiên bản
Ngôn ngữ

name: seo-code description: > Static code analysis and automatic code fixes for SEO compliance. Scans workspace directory (default: ./sourcecode) for HTML structures, template files, and dynamic framework code (WordPress, Next.js, Nuxt, Laravel, vanilla HTML) to ensure they adhere to core SEO guidelines. Generates patches for auto-fixes. Related: seo-technical (live site crawl), seo-fix (JSON/redirect fixes) triggers: "seo code audit, static code seo, source code analysis, code auto-fix, wordpress theme audit, nextjs seo check, scan code"

SEO Code: Static Code SEO Audit & Auto-Fix

This skill provides the intelligence to inspect the raw website source code files, detect SEO anti-patterns, and generate/apply safe patches.

Supported Frameworks & Checks

1. WordPress Themes & Templates

  • Header/Footer Hooks: Verifies presence of wp_head() inside header.php (before </head>) and wp_footer() inside footer.php (before </body>). Missing hooks prevent SEO and tracking scripts from executing.
  • Hardcoded Assets / URLs: Scans for hardcoded domain URLs (e.g. href="https://mywebsite.com/about") which break staging environments. Suggests dynamic path functions like home_url() or get_theme_file_uri().
  • Nested Query Loops (Level 2): Detects raw query_posts() or nesting WP_Query inside another template loop without resetting (wp_reset_postdata()), which causes massive DB query redundancies (N+1 query problem).
  • Missing Alt tags: Scans .php files inside theme folders for static <img src="..."> tags lacking alt="...".

2. Next.js / React

  • Head Component / Metadata: Checks if pages define proper layouts, Page metadata (generateMetadata in app router, or <Head> component in pages router).
  • Image Optimization: Identifies raw <img> HTML tags and warns to replace them with Next.js optimized <Image> component (@next/next/no-img-element).
  • Hydration / CSR Check (Level 2): Warns if page layout is entirely wrapped with "use client" and loads critical indexable text from useEffect (CSR), making it invisible to non-JS executing AI bots.

3. General Static HTML

  • Alt Tag Parity: Validates that all static images have an alt attribute.
  • Heading Hierarchy: Checks if templates output multiple <h1> tags or jump levels (e.g., <h1> directly to <h3>).
  • Responsive Touch Targets: Warns if layout classes do not specify responsive viewports (missing <meta name="viewport">).

Safety Protocol (Suggest & Approve)

  1. Scanner Phase: code_scanner.py generates standard unified diff blocks (patches) for detected issues.
  2. Staging: Patches are saved to .seo/fixes/{date}/ for human review.
  3. Application Phase: code_fixer.py copies the target file to <filepath>.<ext>.bak and writes the verified patch safely.