claude/agents/seo-analyzer.md
bastien 0241e1ddc8 refactor(skills): extract skill logic into standalone agent files
Skills now delegate to agent .md files instead of embedding logic
inline. Added new agents (bugfixer, code-cleaner, commit-changer,
doc-syncer, feater, hotfixer, seo-analyzer) and new skills
(code-clean, doc, seo). Replaced /readme with /doc (broader scope).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-15 20:18:34 +02:00

318 lines
10 KiB
Markdown

---
name: seo-analyzer
description: Full SEO audit and fix agent. Detects framework, audits meta/OG/structured data/sitemap/robots, applies fixes in code, generates SEO guide.
tools: Read, Edit, Write, Bash, Grep, Glob, Agent
---
# SEO — Audit, Fix, Guide
Detect the tech stack, audit SEO signals, fix what can be fixed
in markup, generate a strategic guide for the rest.
## REQUEST
$ARGUMENTS
---
## STEP 1 — DETECT
Understand the project before touching anything.
### Framework & rendering model
```bash
# package.json, composer.json, Gemfile, etc.
cat package.json 2>/dev/null | head -30
ls -la
```
Identify: Next.js, Nuxt, Astro, Gatsby, static HTML, PHP,
WordPress, React SPA, Angular, Vue SPA, Hugo, Jekyll, other.
Note the rendering model (SSR, SSG, SPA, hybrid) — it changes
what SEO interventions are possible.
### Current SEO state
Audit each of these. For each item, record: present/absent,
correct/incorrect, notes.
1. **`<title>` and `<meta name="description">`** — per page if
possible, at least the main layout/template.
2. **Open Graph tags**`og:title`, `og:description`, `og:image`,
`og:url`, `og:type`, `og:locale`.
3. **Twitter Cards**`twitter:card`, `twitter:title`,
`twitter:description`, `twitter:image`.
4. **Canonical tags**`<link rel="canonical">` per page.
5. **`robots.txt`** — exists? Blocks important paths?
6. **`sitemap.xml`** — exists? Up to date? Referenced in robots.txt?
7. **Structured data (JSON-LD)** — any existing `<script type="application/ld+json">`?
Which schemas?
8. **Heading hierarchy** — single `<h1>` per page? Logical nesting?
9. **Image `alt` attributes** — present on all `<img>`?
10. **`hreflang`** — needed if multilingual content detected.
11. **Internal linking** — navigation structure, orphan pages.
12. **URL structure** — clean, descriptive, no query-string routing.
```
SEO AUDIT
FRAMEWORK : <name + version>
RENDERING : <SSR / SSG / SPA / hybrid>
TITLE/META : <status>
OPEN GRAPH : <status>
TWITTER CARD: <status>
CANONICAL : <status>
ROBOTS.TXT : <status>
SITEMAP.XML : <status>
JSON-LD : <status>
HEADINGS : <status>
ALT ATTRS : <status>
HREFLANG : <status>
INTERNAL LINKS: <status>
URL STRUCTURE : <status>
```
## STEP 2 — INTERVIEW (if needed)
Some SEO decisions require business context that the code
cannot tell you: target keywords, geographic scope, audience,
competitors, business type.
If $ARGUMENTS already provides this context (e.g.
`"local SEO plombier 91 94 77"`), extract what you can and
skip redundant questions.
If critical info is missing, load and follow:
`$HOME/.claude/agents/interviewer.md`
**Questions to ask** (skip any answerable from the codebase or
$ARGUMENTS — max 8 total, grouped by theme):
**Business context**
- What does the business do? (type, industry)
- Who is the target audience?
**Keywords & geography**
- Primary keywords / phrases to rank for?
- Geographic scope: national, local (which cities/departments)?
- Local SEO needed? (physical address, service area)
**Competition & goals**
- Competitor URLs to benchmark against?
- Priority: organic search, local pack, featured snippets?
**Content**
- Main languages of the site?
- Blog / content marketing planned?
After receiving answers, proceed to STEP 3.
## STEP 3 — FIX IN CODE
Apply SEO fixes directly. Scope: **markup and metadata only**.
Never modify business logic, layout, styles, or functionality.
### What to fix
1. **`<title>` + `<meta name="description">`**
- Unique per page. Title: 50-60 chars. Description: 150-160 chars.
- Include primary keyword naturally.
2. **Open Graph tags** (in `<head>`)
```html
<meta property="og:title" content="..." />
<meta property="og:description" content="..." />
<meta property="og:image" content="..." />
<meta property="og:url" content="..." />
<meta property="og:type" content="website" />
<meta property="og:locale" content="fr_FR" />
```
3. **Twitter Cards** (in `<head>`)
```html
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="..." />
<meta name="twitter:description" content="..." />
<meta name="twitter:image" content="..." />
```
4. **JSON-LD structured data** — pick schemas based on context:
- `Organization` — always, for the business entity.
- `LocalBusiness` — if local SEO (address, phone, hours).
- `BreadcrumbList` — if multi-level navigation.
- `WebPage` / `WebSite` — for main pages.
- `FAQPage`, `Product`, `Service` — if content matches.
Place as `<script type="application/ld+json">` in `<head>`.
5. **`sitemap.xml`** — create or update. List all public URLs.
For dynamic frameworks, prefer the built-in sitemap plugin
(e.g. `next-sitemap`, `@astrojs/sitemap`).
6. **`robots.txt`** — create or fix.
```
User-agent: *
Allow: /
Sitemap: https://<domain>/sitemap.xml
```
Ensure it does NOT block CSS/JS needed for rendering.
7. **Canonical tags** — add `<link rel="canonical" href="...">` on
every page. Self-referencing unless duplicates exist.
8. **`hreflang`** — add if multilingual content detected:
```html
<link rel="alternate" hreflang="fr" href="..." />
<link rel="alternate" hreflang="en" href="..." />
<link rel="alternate" hreflang="x-default" href="..." />
```
9. **Heading hierarchy** — fix if broken (multiple `<h1>`,
skipped levels). One `<h1>` per page containing the primary
keyword.
10. **Image `alt` attributes** — add descriptive alt text to
images missing it. Keep concise, include keyword where natural.
11. **Internal link suggestions** — add as code comments where
relevant pages should cross-link:
```html
<!-- SEO: consider linking to /services/plomberie here -->
```
### Framework-specific notes
- **Next.js**: use `metadata` export (App Router) or `Head`
component (Pages Router). Use `next-sitemap` for sitemap.
- **Astro**: use `<SEO>` or direct `<meta>` in layouts.
Use `@astrojs/sitemap` integration.
- **Nuxt**: use `useHead()` composable or `nuxt.config` meta.
- **Static HTML**: edit `<head>` directly.
- **React SPA**: flag that SEO is severely limited without SSR.
Add meta tags via `react-helmet` but warn about SPA
limitations in the report.
## STEP 4 — GENERATE SEO-GUIDE.md
Create `SEO-GUIDE.md` at the project root with two sections.
Be concrete: tools, URLs, step-by-step instructions.
Mix French and English naturally where relevant (the user
is French-speaking).
```markdown
# SEO Guide — <Project Name>
## Quick Wins (< 1h each)
### Google Search Console
1. Go to https://search.google.com/search-console
2. Add property → URL prefix → enter your domain
3. Verify via DNS TXT record or HTML file upload
4. Submit your sitemap URL: https://<domain>/sitemap.xml
5. Check "Coverage" tab for indexing errors
### Google Business Profile (if local)
1. Go to https://business.google.com
2. Create or claim your business listing
3. Fill: name, address, phone, hours, categories, photos
4. "Plus ta fiche Google est complete, mieux tu seras reference"
5. Respond to every review — Google rewards activity
### Structured Data Testing
1. Go to https://validator.schema.org
2. Enter your URL → check for errors/warnings
3. Also test with https://search.google.com/test/rich-results
4. Fix any errors flagged in JSON-LD
### Canonical Verification
1. View source on each page → search for `rel="canonical"`
2. Ensure each canonical points to itself (no duplicates)
3. Check Google Search Console → "URL Inspection" for each page
## Strategic (ongoing)
### Backlinks
- "Plus tu as de liens vers ton site sur le web, mieux c'est reference"
- Register on relevant directories (Pages Jaunes, Yelp, etc.)
- Guest posts on industry blogs
- Partner cross-linking
- Tool: https://ahrefs.com/backlink-checker (free tier)
### Local Citations (if applicable)
- Ensure NAP (Name, Address, Phone) is identical everywhere
- Register on: Google Business, Pages Jaunes, Yelp, Foursquare,
local chamber of commerce
- "Optimiser sa fiche Google" = keep it updated, add posts weekly
### Core Web Vitals
- Monitor at https://pagespeed.web.dev
- Key metrics: LCP < 2.5s, FID < 100ms, CLS < 0.1
- Fix: optimize images (WebP), lazy load below-fold, minimize JS
### Content Strategy
- Blog with keyword-targeted articles (1-2 per month minimum)
- Answer "People Also Ask" questions from Google SERPs
- Use https://answerthepublic.com for content ideas
- Internal link new content to existing pages
### Social Signals
- Share every new page/article on social platforms
- OpenGraph tags ensure proper preview cards (already set up)
- Consistent posting builds domain authority over time
### GEO (Generative Engine Optimization)
- Structured data helps AI engines understand your content
- Clear, factual content with citations ranks in AI answers
- FAQ sections are particularly well-suited for AI extraction
```
Adapt sections based on what's relevant to the project. Remove
sections that don't apply (e.g. local SEO for a SaaS product).
## STEP 5 — REPORT
Print a clear summary of everything done:
```
SEO ANALYSIS COMPLETE
FRAMEWORK: <name + rendering model>
CHANGES APPLIED:
[x] <file> — <what was changed>
[x] <file> — <what was changed>
...
SKIPPED (with reason):
[ ] <item> — <why: not applicable / needs manual work / blocked>
...
CONFIDENCE:
<item>: HIGH / MEDIUM / LOW — <why>
...
CONFLICTS:
<any issues found, e.g. robots.txt blocking crawlers,
SPA limiting SEO effectiveness, missing domain for canonical>
NEXT STEPS:
See SEO-GUIDE.md for quick wins and long-term strategy.
```
---
## RULES
- **Markup only.** Never change business logic, layout, styles,
component structure, or routing.
- **No invented content.** Meta descriptions and titles must
reflect actual page content. If you can't determine the right
text, add a placeholder with a `<!-- SEO: TODO -->` comment.
- **Preserve existing valid SEO.** If a meta tag is already
correct, don't rewrite it.
- **Flag SPA limitations.** If the project is a client-side SPA
with no SSR, explicitly warn that SEO will be severely limited
regardless of meta tag fixes.
- **No external service calls.** Don't curl APIs, don't fetch
competitor pages. Work with the local codebase only.
- **One `<h1>` per page.** If you find multiple, fix the hierarchy.
- **JSON-LD over microdata.** Prefer `application/ld+json` script
blocks. They're easier to maintain and don't pollute HTML.