/nexity-marketing-skills:internal-linksfrom nexity-marketing-skills
Finds missing internal links across a site's articles, proposes exact anchors, and produces an approval review page; optionally writes approved links to Sanity drafts.
Ships in nexity-marketing-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Flow: check → catalogue → scan → answer each task → review (the user approves) → handoff (the list for the editor) → the editor adds the links in the CMS → verify. The skill reads the published site and writes only to its own working folder: a person adds the links.
Optional, Sanity only, only on request: when the site runs on Sanity and the user asks for it and gives access, the approved links can go into drafts instead of a list (Step 7). The published content never changes until an editor publishes the draft. Do not offer this as the default and never set it up unasked.
The script does the crawling, the bookkeeping, every deterministic match and every check. You answer the two questions it cannot answer itself: which of its candidates read naturally where they sit, and which page a given sentence genuinely belongs to.
The public HTML of the site, like a search engine without JavaScript. For each page: the
title (the <h1>), the <title>, the meta description, the canonical URL, noindex, and the
content: the <article> that holds most of <main>, else <main>, else <body>, minus
nav, aside, footer, forms and hidden parts. Links in navigation, sidebars and footers are
not editorial links: they never count as "already linked" and never make a page a non-orphan.
Pages are identified by their path (/blog/headless-cms); www. and a trailing slash do not
matter. A page whose canonical URL points to another page is a duplicate and left out.
Limits: a site that renders its articles with client-side JavaScript has no text to read
here (check warns); pages behind a login are out of reach; unpublished drafts are not seen,
so the editor's open drafts may already hold a proposed link.
scripts/internal-links.mjs (logic in scripts/lib.mjs, the HTML reader in
scripts/html.mjs, the page in scripts/report.mjs, the optional Sanity write in
scripts/sanity.mjs, tests in scripts/lib.test.mjs): plain Node 20.12+, no packages, no
keys for the crawl. Run it from the folder where the working folder
.internal-links/ should live (usually the project root). <skill> is the folder this
SKILL.md was loaded from (.agents/skills/internal-links in a clone of the repository,
elsewhere when installed as a plugin or with npx skills; use the absolute path):
IL="<skill>/scripts/internal-links.mjs"
node $IL check --site=https://www.example.com
check reads robots.txt and the sitemap, counts the URLs in scope, and reads one sample
article: it prints which element the content came from, the first blocks, words and links.
Read the sample with the user: if the first blocks are navigation or a cookie banner, or
the text is very short, point the script at the article element with --content= (a tag,
.class, #id or [attr=value]). Other settings, all saved in .internal-links/config.json:
| Option | When |
|---|---|
--sitemap=<url> | The sitemap is not in robots.txt or at /sitemap.xml |
--urls=<file> | No sitemap: a text file with one URL per line. Without either, catalogue follows links from the home page |
--include=/blog/,/services/ / --exclude=/tag/,/author/ | Keep the crawl to the pages that matter |
--max-pages=<n> | Default 1000 |
The crawl respects robots.txt, reads four pages at a time with a pause, and identifies
itself. Ask before crawling a site the user does not own. A staging site behind basic auth or
an IP allowlist cannot be read; use the production URL or a URL list.
.internal-links/ is local working state: add /.internal-links/ to the project's
.gitignore if it is missing (keep rules.json elsewhere if it should be versioned).
.internal-links/rules.json (or --rules=<file>). Without it the run is driven by page names
and the shortlist alone.
{
"maxNewLinksPerArticle": 8,
"phrases": [
{ "phrases": ["Next.js development", "Next.js development services"], "target": "/services/nextjs-development", "cluster": "nextjs" }
],
"excludeTargets": ["/legal/privacy"]
}
phrases: commercially decisive phrases that must always go to one page, never decided by
judgement. Matched longest first; a governed phrase is never matched to another page by name.cluster: one link per cluster per article. Without it each page is its own cluster. Use it
when two pages compete for one topic (/blog/what-is-nextjs and /services/nextjs-development)
so one article does not link both.target: a path or a full URL. catalogue lists rules pointing at pages that are not in the
crawl: a dead rule silently produces nothing, so ask whether to fix it.node $IL catalogue
Crawls the site into .internal-links/pages.json and writes catalogue.json: every page that
can be linked to, with its names (from the title, the <title> and the slug, generic words like
"what is", "guide" or a year stripped), headings and description. Report in two or three
lines: pages by section, pages that could not be read, how many names, thin pages, and the
orphans (pages no other page links to in its content). Orphans are often the most useful
thing the run finds. A listing page (mostly links, like a blog index) links to its items in
code, so it does not count as a link to them.
node $IL scan --sources=/blog/first-post # one article first
node $IL scan --prefix=/blog/ [--limit=20] # or a whole section (/blog/ is the default)
The source set is what the run proposes links in; the catalogue is everything that can be
linked to. On a first run, take one article the user can check by hand, and widen it only
after they have seen the whole loop once. --fresh reads the sources again instead of using
the crawl (after an edit).
Each source gets .internal-links/tasks/<path>.json: its blocks (id, kind, text, the ranges
already linked, excluded), the ledger (pages, anchor texts and clusters the article has
already spent, including the links it had before this run), the deterministic candidates,
and a shortlist of up to 25 pages ranked by rare-word overlap. Report the name matches per
article: they are free and show what shape the work is in.
Read the task and write the answer to the path in its answerFile (.internal-links/answers/,
same file name):
{
"select": [
{ "candidate": "c1", "accept": true, "reason": "the sentence is about what a headless CMS is" },
{ "candidate": "c2", "accept": false, "reason": "names the vendor's product, not our service" }
],
"proposals": [
{ "block": "b7", "start": 112, "end": 131, "anchor": "pipeline review ritual", "target": "/blog/pipeline-reviews", "reason": "…" }
],
"note": "why nothing was proposed, when nothing was"
}
select: you are a filter, not a generator. Every candidate is a page the article names
by that page's own name, or a rules phrase. Decide whether the sentence means that page's
subject the way the page does; decline the rest with a reason. Do not change an anchor or
retarget a candidate. Declining everything is a valid answer.
proposals: links to pages on the shortlist. target is the page's id (its path).
anchor must be exactly text.slice(start, end) of that block. Do
not fix a typo, change a quote mark or trim a word. The check compares and tells you what is
actually at those offsets.maxNewLinks new links. A target not on the
shortlist is invalid. An empty proposals array is a normal, good answer.reason.With many articles and subagents available, hand out tasks in parallel, one task file per subagent, each returning the answer JSON.
node $IL review
Validates every answer, writes .internal-links/report.html (each proposal as its whole
sentence with the anchor highlighted, the target, the reason and an Approve box), and two
tables: proposals.tsv (Source url, Target anchor, Target url, link_id) and
sources.tsv (Source url, Success/Failed). Present both tables as Markdown and as TSV
the user can paste into a spreadsheet, copied from the files, with one line per Failed
article on why (everything it names is already linked, no page fits, no answer).
Rejections are normal: "7 of 9 proposals passed, 2 dropped because the article already links that page" is a working run. Report the causes.
Give the user the path of the page and wait. A link can point at the right page and sit in
the wrong clause; that is only visible in the sentence. The user ticks what they want and
clicks Download approved.json. Approval is theirs: never build approved.json yourself.
node $IL handoff --file=<approved.json>
Writes links-to-add.md (per article: the sentence with the words to link in bold, and the URL)
and links-to-add.tsv for a spreadsheet or a ticket. Show the list. The editor adds the links
in their CMS, as an internal link or reference when the CMS has one (it survives slug changes),
and publishes through their usual review. On a Sanity site where the user wants the links
written for them, go to Step 7 instead.
After the editor has published:
node $IL verify --file=<approved.json>
Reads each article again and reports per link: present, missing (the sentence is there,
the link is not), changed (the sentence is gone: the article was rewritten) or unreadable.
A cached page can lag behind a publish; re-run before calling a link missing. Run catalogue
again afterwards: orphans that got a link drop off the list.
Only when the user asks for it on a Sanity site and gives access. Two routes; let them choose:
| Route | What the user gives | How it writes |
|---|---|---|
| API | SANITY_PROJECT_ID, SANITY_DATASET and a Viewer token (SANITY_API_READ_TOKEN), plus an Editor token (SANITY_API_WRITE_TOKEN) for the write. In the shell or in .env.local / .env (also read from web/; the starter's NEXT_PUBLIC_SANITY_* names work) | The script writes, with a backup and a read-back |
| Sanity MCP | A Sanity MCP server connected to the agent, with access to the project | The script plans the exact patches; you apply them with the MCP server's tools |
Tokens and keys never go into the chat; never read or print an .env file.
1. Check the access and the link shape:
node $IL sanity-check # API route
node $IL sanity-check --documents=<file> # MCP route: documents read through MCP (any sample with links)
Prints what the dataset's link annotations look like and saves the shape new links take:
reference ({_type: "link", type: "internal", internal: {_ref}}, a Nexity project's
link) or href ({_type: "link", href: "/path"}, Sanity's default), or
--link='<JSON with $id, $path or $url>' for a custom schema. A shape the schema does not
know makes an invalid draft: show the user the shapes found and confirm the choice. It
also reports which catalogue pages map to a document by slug. When two documents share a slug
(a post and a page both called pricing), pass --routes=post:/blog/,page:/ so the type
decides the path.
2. Plan (always a dry run first):
node $IL sanity-apply --file=<approved.json> # API: reads the documents itself
node $IL sanity-query --file=<approved.json> # MCP: the GROQ query to run
node $IL sanity-apply --file=<approved.json> --documents=<result> # MCP: plan from what MCP returned
The script finds each link's place by text, not by offsets: the block holding the approved
sentence, then the anchor inside it (headings and quotes are skipped). It plans one
transaction per article: the open draft is patched (guarded by its revision), or a draft is
created from the published document. Bold or italics inside the anchor stay. Anything it cannot
place is skipped with the reason: the sentence is not in the CMS text (the live page and the
CMS differ, or the article changed), the anchor is already linked, or the target has no
document while the shape needs its id. Show the dry run and read it back to the user. The
mutations are in .internal-links/sanity-plan.json.
3. Write, only after the user says go (ask: run it yourself, or should I?):
node $IL sanity-apply --file=<approved.json> --apply. Saves the documents as read
to .internal-links/backups/, writes each transaction, reads the draft back and checks the
link. Report applied, guard_rejected, write_failed and verify_failed separately;
verify_failed means stop and look, not retry.sanity-plan.json with the MCP server's write tools: the
createIfNotExists (when there is one) first, then the patch with its set paths and the
ifRevisionID guard. Do not edit the mutations; if a tool cannot take a keyed path
(body[_key=="…"]) or the revision guard, stop and tell the user rather than writing the
whole body.4. Check: node $IL sanity-verify --file=<approved.json> (add --documents=<file> with the
drafts read again through MCP). Then the editor opens each draft in the Studio, looks at the
links in place and publishes; after that, verify checks the live pages as in Step 6. Never
publish for them.
| Symptom | Likely cause | What to do |
|---|---|---|
| The sample's first blocks are a menu or a banner, or almost no text | The content element was guessed wrong, or the article is rendered by JavaScript | check --content=<selector>; for a JavaScript-only site, there is nothing to read |
| Many pages could not be read (403, 429) | A firewall or rate limit | Ask the site owner to allowlist the crawl, or narrow it with --include |
| Every page is an orphan | Articles link to each other only in a "related posts" block the reader strips | Normal: those are not editorial links. Say so in the report |
| No name matches anywhere | Titles are generic ("Pricing"), or the content language is not English | Normal: the shortlist and your proposals carry the run. Add rules for the phrases that matter |
After editing scripts/lib.mjs or scripts/html.mjs, run node --test scripts/lib.test.mjs
from the skill folder. html.mjs is the same file in blog-post-update: change both.
review; re-run the command.approved.json for the user, or hand off links they have not approved.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub pagepro/nexity --plugin nexity-marketing-skills8 skills in this plugin
/blog-post-quality-reviewA critical, read-only quality review of one blog post or draft. Checks whether the body delivers what the title promises, the logic, every heading against its section, a technical and a marketing read, and ends with a weighted 0-10 scorecard and the three fixes with the most impact, always in the same format so posts can be compared. Use when the user asks to "review this post", "score this article", "is this draft good", "check the quality of the blog post", or gives a post URL, file or pasted text to judge. Never edits the post./blog-post-updateReview one published blog post the user picked, on any site and any CMS, and propose the update without writing anything. Snapshot the post from its public URL (or an export), agree the scope, diagnose the drop proportionately from Search Console and GA4 (through an MCP server, the script's own Google access, or exports; none is required to start), audit the article as published, propose an intervention (no change / technical / consolidation / content), get the editor's approval at named gates, rewrite it in Markdown, render the images it needs (screenshots and HTML-built graphics through the installed Chrome), validate (links, protected passages, metadata, headings), show the whole change on an HTML review page, and hand the editor an approved change list to make in their CMS; `verify` then checks the live page. Not always a rewrite. Use when asked to "update a blog post", "refresh this article", "should we update this post", "why did this post drop", "which posts should we refresh", or given a published article URL to look at./brand-kitUse when asked to build, generate, refresh or reverse-engineer a brand kit, a `BRAND.md`, brand foundations or a brand voice profile for a company from its website URL — "zrób brand kit", "brand kit for <company>", "fill in BRAND.md", "what does our site actually say about us", or when preparing a company's site for AI content production. Reads the public site and its listings, writes a short `BRAND.md` that people and AI agents work from, and a report of what the site contradicts or cannot prove. Written for the team that owns the site; works on any company's site. Needs only a public URL to start./marketing-setupWalk a marketer with no terminal experience through setting up the marketing skills (brand-kit, site-contradictions, blog-post-quality-review, internal-links, blog-post-update, and source-review, which blog-post-update uses) step by step, by their preferences, whether they came as the Claude Code plugin `nexity-marketing-skills`, through `npx skills add Pagepro/nexity`, or in a downloaded ZIP of the repository. Checks where the skills are, says what to install and how (click by click), installs and builds what it can itself with permission, runs a short test of each chosen skill, and ends with what the person can now ask for. Use when someone says "Help me setup these skills for marketers", "set up the marketing skills", "skonfiguruj skille marketingowe", "pomóż mi to uruchomić", or has just installed the marketing skills and asks how to start./site-contradictionsFind the places where a website contradicts itself, on any site and any CMS. Reads the site's pages, collects every checkable claim with its verbatim quote and URL (prices, plans and seats, trials, setup times, customer counts, integration counts, statistics, names and titles of people and customers, product capabilities, guarantees, legal and company facts), compares claims about the same thing across pages, and reports each contradiction with both quotes, how much it matters, and either a concrete fix or a question for whoever owns the fact. Written for the team that owns the site. Read-only. Use when asked to "find contradictions on <site>", "where does our site contradict itself", "are our prices and numbers the same everywhere", "check the site for inconsistent claims", "what would a buyer notice doesn't add up", or before a relaunch, a migration or a pricing change./source-reviewReview the claims of an article and find a verified source for each one. Use when a person asks to check the sources of an article, to verify the facts of a draft, or to find a citation for a claim. The skill reads the article, proposes the claims, searches the web, reads each page, and writes a report with a PASS, PASS_WITH_WARNINGS, or BLOCKED verdict. Uses the agent's own web search; needs Node 20+ and no API key. Never writes to the CMS.Other plugins' skills for the same job