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()insideheader.php(before</head>) andwp_footer()insidefooter.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 likehome_url()orget_theme_file_uri(). - Nested Query Loops (Level 2): Detects raw
query_posts()or nestingWP_Queryinside another template loop without resetting (wp_reset_postdata()), which causes massive DB query redundancies (N+1 query problem). - Missing Alt tags: Scans
.phpfiles inside theme folders for static<img src="...">tags lackingalt="...".
2. Next.js / React
- Head Component / Metadata: Checks if pages define proper layouts, Page metadata (
generateMetadatain 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 fromuseEffect(CSR), making it invisible to non-JS executing AI bots.
3. General Static HTML
- Alt Tag Parity: Validates that all static images have an
altattribute. - 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)
- Scanner Phase:
code_scanner.pygenerates standard unified diff blocks (patches) for detected issues. - Staging: Patches are saved to
.seo/fixes/{date}/for human review. - Application Phase:
code_fixer.pycopies the target file to<filepath>.<ext>.bakand writes the verified patch safely.