Content
Keyword clustering: group and map to URLs
The keyword-cluster skill turns a keyword list into a content map: it groups keywords by topic and search intent, defines each group's pillar and cross-checks them against the site's pages to mark every cluster as covered, partial, gap or cannibalization. With no list, it pulls terms from the site or generates them from a seed topic. It delivers the URL map with the action per cluster and adds it to the report.
---
name: keyword-cluster
description: >
Groups keywords into clusters by topic and search intent, defines the pillar of each group and
cross-checks them against the site's pages (covered / partial / gap / cannibalization) or, if the
site has no content yet, proposes the page architecture to build. A keyword list is not required: if there is none, it extracts terms from the site and expands them with the LLM. Use it when the user asks
for "group keywords", "keyword clustering", "topic clusters", "what content am I missing",
"map keywords to URLs", "keyword cannibalization", "content plan" or shares a list
of keywords (CSV/Excel/text), or a topic or site to pull the keywords from.
---
# Keyword clustering
Turn a keyword list into a content map: which pages exist, which are missing and which compete with each other.
References: [Semrush](https://www.semrush.com/blog/keyword-clustering/) · [SEOcrawl](https://seocrawl.ai/blog/keyword-clustering) · [OpenSEO](https://openseo.so/docs/skills/keyword-clustering).
## When to use
- You want to map keywords to pages, see what content is missing or detect cannibalization.
- **There is a list** (GSC, Semrush, Ahrefs, Keyword Planner, by hand) → ideal: it brings real volume and KD.
- **There is no list** → the skill builds one: it extracts terms from the site (crawler) and/or generates them with the LLM from a seed topic.
- The site **does not exist or the keyword is not in it** → every cluster comes out as "gap" and the deliverable is the architecture of pages to create.
It does not optimize the title/description of a specific page (use `title-generator` / `description-generator`) or audit a site (`basic-audit`).
## Inputs
Ask only for what is missing. Required: **domain** and **a keyword source** (any of the three):
1. **List** CSV/TXT. Recognized columns: `keyword/palabra clave/query`, `volume/volumen/impressions`, `kd/dificultad`.
2. **Site** (URL): candidates are extracted from its titles and H1s.
3. **Seed topic** (e.g. "medicines for erectile dysfunction"): the LLM proposes the keywords.
Useful: market and language (Colombian Spanish by default), audience, goal (traffic, leads, sales) and competitors.
## Flow
### 1. Data
**Site pages** (if the site exists): rendered HTML with `crawler/SKILL.md` (JS sites) or plain HTTP:
```bash
python3 shared/seo_extract.py --sitemap https://example.com/sitemap.xml --limit 50 -o crawler/output/<domain>/_pages.json
```
Take pages from each template (categories, products, articles); the home page alone is not enough.
**Keywords**, depending on what is available:
- *User list* → use it as is.
- *No list* → in `keywords.txt` (one per line) gather:
- site candidates: titles and H1s from `_pages.json` (the script extracts them on its own if you pass no list);
- terms the LLM generates from the seed topic and what it sees on the pages: synonyms, questions (what is, how, what is it for),
comparisons (best, vs, alternatives), transactional (buy, price) and variants by audience or use;
- optional, with a browser: Google autocomplete and People Also Ask, and competitors (their title/H1 with `shared/seo_extract.py --url`).
- Generated ones **come with no volume or KD**: mark them as "LLM-generated, no volume" in the `summary` and do not invent figures.
If the user can, suggest validating them with Keyword Planner or GSC.
### 2. Script → report
```bash
python3 keyword-cluster/scripts/cluster_keywords.py [keywords.csv|keywords.txt] --site <domain> [--pages crawler/output/<domain>/_pages.json] [--threshold 0.5]
```
The script cleans the terms (lowercase, accents, stopwords, plurals), groups them
lexically (pillar = highest volume; merges by contained tokens or Jaccard ≥ threshold), classifies intent by patterns and,
with `--pages`, measures the pillar's coverage against slug/title/H1. It writes:
- `crawler/output/<domain>/_keyword_clusters.json` → full clusters to refine.
- `report/data/<domain>/keyword-cluster.json` → KPIs, top-clusters chart and tables.
### 3. Analysis (Claude)
Lexical grouping does not understand meaning. Read `_keyword_clusters.json` and fix:
1. **Merge** synonyms and variants the script split (`sildenafil` / `sildenafilo`, `tenis` / `zapatillas`).
2. **Split** false friends and clusters with mixed intents (`mixed_intents` with more than one class): *buy X* and *what is X* do not belong on the same page.
3. **Intent**: confirm each cluster's intent (informational, commercial, transactional, navigational). "Generic" ones are usually head terms: decide from the business context.
4. **Pillar and support**: pillar = the broadest, highest-volume term; the rest are subtopics or sections of the same page. One page per intent, not per keyword.
5. **URL map**: for each cluster, define the action:
- *covered* → optimize the existing page (title/H1/sections for the supporting terms).
- *partial* → expand the content or rebuild the page that almost fits.
- *gap* → create a new page (type: category, product, guide, comparison, landing; proposed slug).
- *cannibalization* (several pages cover the pillar) → pick a canonical, consolidate or differentiate by intent.
6. **Priority** only with real data: high volume + low KD + intent aligned with the goal + current position 8–20 (quick win). Without volume/KD → order by intent and coverage, and say so.
7. If the user provides the SERP top 10 for each keyword, also merge those that **share ≥3–4 URLs** in the top 10 (the Semrush/SEOcrawl SERP criterion, more reliable than lexical similarity). Without that data, do not simulate it.
Fill in the JSON: `score` (only if it follows the scoring below, otherwise `null`), `summary`, `findings`, `actions`, and add to `tables`
the **content map** with your corrections:
```json
{"title": "Content map", "columns": ["Cluster (pillar)", "Intent", "Action", "Current / proposed URL", "Support keywords"],
"rows": [["tadalafil", "Transactional", "Optimize", "/tadalafil", "tadalafil 20 mg, tadalafil price"],
["semaglutide", "Informational", "Create guide", "/blog/what-is-semaglutide (new)", "what is semaglutide used for"]]}
```
If you need to write titles or descriptions for the new pages or the ones being optimized, invoke `title-generator` and `description-generator`; do not write them by hand.
### 4. Report
`python3 report/build_report.py <domain> --open`
## What to evaluate / Scoring
The skill diagnoses demand **coverage**; it only scores with a site cross-check (`--pages`) and volume. If either is missing → `score: null`.
| Criterion | Weight | What to look at |
|-----------|--------|-----------------|
| Coverage | 50% | % of total volume in *covered* clusters (partial counts 0.5) |
| Cannibalization | 25% | 100 − 25 for each cluster with several competing pages (min. 0), weighted by volume |
| Intent alignment | 25% | % of volume whose existing page matches the cluster's intent (manual review by Claude) |
Bands: 90+ excellent · 75–89 good · 60–74 needs work · 40–59 poor · <40 critical.
Typical findings: high-volume cluster with no page, a transactional page serving an informational query, two URLs fighting for the same pillar, 1-keyword clusters with no potential (discard or merge).
Actions: create > consolidate > optimize, ordered by volume × intent × effort.
## Rules
- **Never WebFetch for the `<head>`** of the site's pages: use `shared/seo_extract.py`.
- Do not invent volume, KD, positions or traffic. No data → "not evaluated" / `—`.
- One cluster = one intent = one main page. If you doubt whether to merge or split, split and note it.
- No site (or a keyword that is not on it) is not an error: coverage comes out as "gap" and the deliverable is the proposed page architecture; explain it in the `summary`.
- Do not generate more than ~50 clusters in the map; group the rest as "long tail" with a note.
- Re-running the script keeps `summary`, `findings`, `actions` and hand-added tables/charts, but **regenerates the clusters**: copy your corrections into the content map before running it again with other parameters.