SLOPSHOPPER

link-check

Checks the external links Claude adds to pages, posts and templates. Broken ones go back to Claude so it can fix them, and show above the prompt. /links lists…

newbandguardcommandtoastnetwork
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · link-check
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /links ⎿ link-check: No broken links. 0 checked this session. ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

Claude Code mods by krysmalskipl

Mods for Claude Code, built for SEO and content work. Install only the ones you want.

Install

Every mod installs on its own. The quick version:

claude plugin marketplace add krysmalskipl/claude-code-mods
claude plugin install <mod>@krysmalskipl

Then restart Claude Code. Each mod below has the full steps, including any key it needs.

Needs Claude Code 2.1.287+ in the terminal, or the Claude desktop app's Code tab. Plugins installed from the terminal show up in both.

Mods

ModWhat it doesCommand
🪙openrouter-balanceYour OpenRouter credit: the real balance with a gauge, today's spend and the model the money mostly went to. A regular API key shows its own spend and limit instead/openrouter-balance
📏meta-lintThe SEO basics of the page or post Claude just edited: title and meta description length, H1 count, images without alt, word count. Markdown, MDX, Astro and HTML/meta-lint [file]
🔗link-checkChecks the external links Claude adds. Broken ones go back to Claude so it can fix them, and show above the prompt/links [file]
🪧share-previewHow the page looks in Google (desktop and mobile, cut by pixel width) and as a shared link on LinkedIn, Facebook, Slack and X, with what would cost you clicks. Live while Claude edits`/preview [url \file]`
⏱️cache-statsYour prompt cache above the prompt: hit rate, how long it stays warm, what a cold restart re-caches, and how long the session has run. /cache lists every miss and why`/cache [hide\show]`

📏 meta-lint

meta-lint and link-check in Claude Code: /meta-lint details with a search snippet preview, /links, and the SEO line above the prompt

One line above the prompt after Claude edits a page or post:

◆ SEO  post.md  title 58/60 ✓ · description 186/160 ✗ · H1 1 ✓ · 2 images without alt · 2,726 words
Install
claude plugin marketplace add krysmalskipl/claude-code-mods   # once per machine
claude plugin install meta-lint@krysmalskipl

Restart Claude Code or type /reload-plugins. No key, no setup: it reads files on your machine and sends nothing anywhere. The line appears after Claude's first Write or Edit of a .md, .mdx, .markdown, .astro, .html or .htm file.

What it checks
CheckWhere it looksGreenYellowRed
TitleFrontmatter seo_title, meta_title or title (the first one set), else <title>, else the first # H130 to 60 charactersunder 30over 60, or missing
DescriptionFrontmatter seo_description, meta_description, description or excerpt, else <meta name="description">70 to 160 charactersunder 70over 160, or missing
H1# lines and <h1> tags in the body, outside code blocksone, or none when the frontmatter has a title (templates usually render it as the H1)more than one, or none at all
Images without alt and <img> without altany
Wordsthe body, without codeshown, not judged
Commands
  • /meta-lint shows the details of the last page: each value, where it came from, how far over or under it is, and a search snippet preview cut where Google would likely cut it
  • /meta-lint path/to/file.md checks any file, edited or not

Limits are in characters. Google cuts titles by pixel width (about 600 px), so a title of wide letters can be cut sooner: treat the numbers as a guide.

🔗 link-check

Checks every external link Claude adds to a page, post or template, while Claude is still working.

◆ Links  2 not working · https://gone.dev/page (404) in post.md and 1 more · /links
Install
claude plugin marketplace add krysmalskipl/claude-code-mods   # once per machine
claude plugin install link-check@krysmalskipl

Restart Claude Code or type /reload-plugins. No key, no setup.

How it works
  • After each Write or Edit of a .md, .mdx, .astro, .html, .tsx, .jsx, .vue, .svelte, .php, .njk, .liquid or .twig file, it finds the http(s) links new in that edit and asks each one (a HEAD, or a GET when the host refuses HEAD)
  • Claude is told: links that answer 4xx or 5xx, or don't answer at all, go back to Claude with the edit's result, so it can fix or remove them in the same turn
  • You see them above the prompt until they're gone from the file. /links lists them
  • An edit waits at most 6 seconds for its links. A slower host's answer comes later as a toast
  • 401, 403 and 429 count as working: they're usually bot walls or rate limits, and the page opens in a browser
  • Skipped: localhost, 127.0.0.1, example.com, .local, .test and links with template placeholders (${…}, {{…}})
  • Each URL is asked once per session, at most 25 per edit and 6 at a time. Requests go from your machine straight to each link's host, nowhere else
Commands
  • /links lists the links that don't work, and where
  • /links path/to/file.md checks every link in a file now (up to 100), with ✓ working, ↪ redirect, ~ blocks bots and ✗ broken

🪧 share-preview

See the page you're building the way people will meet it: as a Google result and as a link someone shares. A pane next to the chat, updated while Claude edits.

✗ og:image "/og.png" is relative: platforms need a full https:// URL
! Title is 668px wide, Google shows about 600px: the end is cut
! No twitter:card: X shows a small thumbnail, add summary_large_image for the big card
✓ Description fits desktop and mobile (512px)
Install
claude plugin marketplace add krysmalskipl/claude-code-mods   # once per machine
claude plugin install share-preview@krysmalskipl

Restart Claude Code or type /reload-plugins. No key, no setup.

Use it
  • /preview shows the page Claude edited last: HTML, Astro, Vue, Svelte, JSX with <Head>, a Next.js metadata export or Markdown frontmatter. The pane follows every later edit of that file
  • /preview localhost:3000/pricing reads the page your dev server renders, the most accurate view. It refreshes after each of Claude's turns
  • /preview https://example.com checks a live page
  • In the pane: g Google, s shared link, r refresh
What it shows
  • Google: the desktop and mobile result, the title cut at about 600 px and the description at about 920 px (desktop) and 680 px (mobile), measured in Arial glyph widths the way Google draws them, not in characters
  • Shared link: the LinkedIn and Facebook card, Slack's unfurl and X's card (large, small or none, from twitter:card), with the fallbacks each platform uses when a tag is missing
  • Checks, worst first: noindex, a missing title, a missing or relative or local og:image, an og:image that doesn't load (it asks the URL, or looks in public/ and static/ for a local file), a canonical pointing at localhost, titles and descriptions too long or too short, a missing twitter:card, og:image:alt or <html lang>
  • Tags set in code ({post.title}, generateMetadata) are marked as such: /preview <url> reads them rendered

The findings also go to Claude as context, so "fix these" just works. Pages and images are fetched from your machine; nothing is sent anywhere else.

Google publishes no snippet limits: the pixel widths are the ones SEO tools have measured for years. Treat them as a close guide, not a promise.

⏱️ cache-stats

Claude Code resends the whole conversation with every request, and the prompt cache is what keeps that cheap and fast. This shows what the cache is doing, live.

◆ Cache  █████████░ 96% hit · warm 58m · 133k cached · session 1h 12m (23m working) · avg 94% · 38 requests
◆ Cache  ░░░░░░░░░░ 0% hit · cold, next message re-caches 133k · session 2h 05m (31m working)
Install
claude plugin marketplace add krysmalskipl/claude-code-mods   # once per machine
claude plugin install cache-stats@krysmalskipl

Restart Claude Code or type /reload-plugins. The line appears after Claude's first reply. It reads Claude Code's own usage figures and sends nothing anywhere.

Set the cache lifetime

The hit rate is measured, but the warm countdown needs to know how long your cache lives: 1h on a Claude subscription (the default) or 5m on an API key. On an API key, set it in /config → cache-stats, or from a shell:

echo '{"ttl":"5m"}' | claude plugin configure cache-stats@krysmalskipl --values-stdin

Not sure which you have? Look at your session transcript: ephemeral_1h_input_tokens in the usage rows means a 1h cache.

What the line shows
  • Hit rate of the last request: how much of the prompt the cache served. Green from 80%, yellow from 50%, red under
  • Warm 3m: time left before the cache lapses, counted from the last reply. Once it has, the line says what the next message re-caches
  • Cached: tokens in the cache now, the size of the last prompt
  • Session time since the session started, and how much of it the model spent working
  • avg and requests: the hit rate over the whole session and the number of requests to the model

On a narrow terminal the right-hand parts drop out first.

Commands
  • /cache shows the details: state, session totals (read from cache, written, sent uncached, generated), every miss with the reason, and the last requests
  • /cache hide and /cache show take the line away and bring it back

A miss is a large prompt (5,000+ tokens) the cache mostly did not serve. The reason is told by the gap before it: idle longer than the cache lives means it simply expired; soon after the last request means something under the cache changed, such as /model, /compact, an edited CLAUDE.md or a new MCP tool. That second kind is the one worth hunting down, since each costs a full re-cache.

Subagents run on caches of their own and are not counted.

🪙 openrouter-balance

openrouter-balance: OpenRouter key limit and today's spend above the Claude Code prompt

Your OpenRouter credit in one line above the prompt, refreshed every 5 minutes and after each turn.

1. Check your Claude Code version
claude --version

You need 2.1.287 or newer. Older? Update with claude update (or npm install -g @anthropic-ai/claude-code). In the desktop app, type /status in a Code tab session.

2. Add this marketplace

Once per machine, in a terminal:

claude plugin marketplace add krysmalskipl/claude-code-mods

Or inside a Claude Code session: /plugin marketplace add krysmalskipl/claude-code-mods.

3. Install the mod
claude plugin install openrouter-balance@krysmalskipl

Or inside a session: /plugin install openrouter-balance@krysmalskipl.

It ends with "1 userConfig option not yet set". That's the optional key from step 4. If your key is already in your environment or Keychain, ignore it.

4. Give it an OpenRouter key

Pick the kind of key first:

KeyWhat the line showsWhere to make one
Management key (recommended)The account's real balance, today's spend and the model the money mostly went toopenrouter.ai/settings/management-keys. It can't call models, so it's safe to keep around
Regular API keyOnly that key's own spend today and this month, and what its limit leavesopenrouter.ai/settings/keys. The OPENROUTER_API_KEY you already use works

Then put it in one place. The mod looks in this order and takes the first it finds:

  1. /config → openrouter-balance in an interactive claude terminal session, or from a shell:
   echo '{"apiKey":"sk-or-v1-..."}' | claude plugin configure openrouter-balance@krysmalskipl --values-stdin

That line lands in your shell history; the Keychain (3) keeps the key out of it.

  1. An environment variable: OPENROUTER_MANAGEMENT_KEY for a management key, OPENROUTER_API_KEY for a regular one. Add it to ~/.zshrc (or your shell's startup file):
   export OPENROUTER_MANAGEMENT_KEY="sk-or-v1-..."
  1. The macOS Keychain (no key in any file). Paste the key when asked:
   security add-generic-password -a "$USER" -s openrouter-key -w
  1. Your login shell: when Claude Code doesn't see the variables itself (the desktop app started from the Dock never reads ~/.zshrc), the mod asks your shell for OPENROUTER_MANAGEMENT_KEY and OPENROUTER_API_KEY. So a key exported in ~/.zshrc works there too.

The key is kept in memory only and sent only to openrouter.ai.

5. Restart and check

Start a new Claude Code session (or type /reload-plugins in an open one). Within a few seconds a line appears above the prompt:

◆ OpenRouter  █████████▁ $2.67 of $3.00 key limit left · $0.33 today

Type /openrouter-balance for the breakdown: balance, today, yesterday, last 30 days and spend, requests and tokens by model. With a regular key: today, this week, this month, all time, its limit and budget.

Update or remove
claude plugin marketplace update krysmalskipl
claude plugin update openrouter-balance@krysmalskipl

claude plugin uninstall openrouter-balance@krysmalskipl
If something's off
The line saysWhyFix
Nothing at allThe mod isn't loaded yetStart a new session, or /reload-plugins. Check claude plugin list shows it enabled
no key setNo key in any of the four placesStep 4. In the desktop app, the Keychain is the surest place
key rejectedThe key was revoked or disabledMake a new one, put it where the old one was
can't reach OpenRouter yetNo network, or OpenRouter is downIt retries every minute by itself
$0.42 today · $12.30 this month and no balanceA regular key with no limit: it can't see the accountUse a management key for the balance, or set a limit on the key
… · offlineThe last refresh failedThe numbers are the last good ones; it retries every minute
How it counts
  • Green from $5, yellow under $5, red under $2
  • "Today" is the UTC day. With a management key it's the usage now minus where it stood when the mod first saw the day; a day first seen after 00:15 UTC shows "since HH:MM" (UTC)
  • Spend by model comes from OpenRouter's /activity, which holds completed UTC days only

Develop

claude plugin validate mods/<name>
CLAUDE_CONFIG_DIR=$(mktemp -d) claude plugin test mods/<name>

More mods: hamzafer/claude-code-mods.

License

MIT

Source 2 files
hooks/register.tsx 213 lines
1// Link Check: checks the external links Claude adds to pages, posts and templates.
2// Only links new in an edit are asked for; each URL once per session. Broken ones go back to Claude with the
3// edit's result, so it can fix them, and stay above the prompt until they're gone from the file.
4import { atom, read, update } from 'claude-code'
5import type { EngineInterface, Register } from 'claude-code'
6
7import type { Line, Problem } from '../types'
8
9const CONTENT_FILE = /\.(md|mdx|markdown|astro|html?|tsx|jsx|vue|svelte|php|njk|liquid|twig)$/i
10const EDIT_TOOLS = new Set(['Write', 'Edit', 'MultiEdit'])
11const WAIT_MS = 6_000 // how long an edit may wait for its links; later answers come as a toast
12const FILE_WAIT_MS = 20_000 // /links <file> waits longer: you asked for it
13const PER_EDIT = 25 // links checked per edit at most
14const PER_FILE = 100
15const PARALLEL = 6
16const BRAND = '#60a5fa'
17const AGENT = 'Mozilla/5.0 (compatible; link-check; +https://github.com/krysmalskipl/claude-code-mods)'
18// Hosts that are never real pages: local servers, examples and reserved names.
19const SKIP_HOST = /^(localhost|127\.\d+\.\d+\.\d+|0\.0\.0\.0|\[::1\]|([\w-]+\.)*(example\.(com|org|net)|local|test|invalid|localhost))$/i
20const EMPTY: Line = { problems: [], checked: 0 }
21
22type Result = { kind: 'ok' | 'redirect' | 'blocked' | 'broken' | 'unreachable'; status: number | null }
23
24// Held by the host, so the band survives a hot reload of this file.
25const line = atom({ plugin: 'link-check', key: 'line' } as const, EMPTY)
26
27const cache = new Map<string, Promise<Result>>() // url → its answer, once per session
28let running = 0
29const queue: (() => void)[] = []
30
31export const register: Register = on => {
32  on('session.start', async ($, e, next) => {
33    const result = await next(e)
34    await $.command
35      .register({ name: 'links', description: 'Broken links Claude added, or check every link in a file', argumentHint: '[file]' })
36      .catch(() => {}) // a name Claude Code already has is refused: start anyway
37    return result
38  })
39
40  on('tool.call', async ($, e, next) => {
41    const path = (e as unknown as { file_path?: unknown }).file_path
42    if (!EDIT_TOOLS.has(e.tool) || typeof path !== 'string' || !CONTENT_FILE.test(path)) return next(e)
43    const before = e.tool === 'Write' ? await $.fs.read(path).then(String, () => '') : ''
44    const ran = await next(e)
45    if (ran.deny !== undefined || ran.isError === true) return ran
46
47    const added = newLinks(e as unknown as Record<string, unknown>, before).slice(0, PER_EDIT)
48    if (added.length === 0) return ran
49    const checks = added.map(url => ({ url, answer: check($, url) }))
50    const timeUp = $.clock.sleep(WAIT_MS).then(() => null)
51    const inTime = await Promise.all(checks.map(c => Promise.race([c.answer, timeUp]).then(r => ({ url: c.url, r }))))
52    await refresh($, path, added.length)
53
54    const bad = inTime.filter(x => x.r && isProblem(x.r))
55    const late = checks.filter((_, i) => !inTime[i].r)
56    if (late.length > 0) void reportLate($, path, late) // in the background: the edit doesn't wait for slow hosts
57    if (bad.length === 0) return ran
58    const list = bad.map(x => `${x.url} (${label(x.r!)})`).join(', ')
59    const note = `link-check: ${bad.length === 1 ? 'a link' : `${bad.length} links`} just added to ${basename(path)} ${bad.length === 1 ? "doesn't" : "don't"} work: ${list}. Fix or remove ${bad.length === 1 ? 'it' : 'them'} if wrong.`
60    return { ...ran, context: [...(ran.context ?? []), note] }
61  }).catch(($, e, next) => next(e)) // a hook that failed never holds up the edit
62
63  on('command.run', { command: 'links' }, async ($, e) => {
64    const arg = e.args.trim()
65    if (!arg) {
66      const now = await read($, line)
67      if (now.problems.length === 0) return { text: `No broken links. ${now.checked} checked this session.` }
68      return { text: ['## Links that don\'t work', '', ...now.problems.map(p => `- ${p.url} (${label(p)}) in \`${basename(p.file)}\``)].join('\n') }
69    }
70    let text: string
71    try {
72      text = String(await $.fs.read(arg))
73    } catch (err) {
74      return { text: `Couldn't read ${arg}: ${err instanceof Error ? err.message : String(err)}` }
75    }
76    const urls = links(text).slice(0, PER_FILE)
77    if (urls.length === 0) return { text: `No external links in ${basename(arg)}.` }
78    const timeUp = $.clock.sleep(FILE_WAIT_MS).then(() => null)
79    const answers = await Promise.all(urls.map(url => Promise.race([check($, url), timeUp]).then(r => ({ url, r }))))
80    await refresh($, arg, urls.length)
81    const rows = answers.map(({ url, r }) => `- ${r ? icon(r) : '…'} ${url}${r && r.kind !== 'ok' ? ` (${label(r)})` : r ? '' : ' (still waiting)'}`)
82    const bad = answers.filter(a => a.r && isProblem(a.r)).length
83    return { text: [`## Links in ${basename(arg)}: ${urls.length} checked, ${bad} not working`, '', ...rows].join('\n') }
84  })
85
86  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
87    const rest = await next(e) // what other mods and Claude Code draw here stays
88    const now = { ...EMPTY, ...(await read($, line)) }
89    if (e.props.hasSurvey || now.problems.length === 0) return rest
90
91    const { Box, Text } = $.ui.resolve(e)
92    const first = now.problems[0]
93    const n = now.problems.length
94    return (
95      <Box flexDirection="column">
96        <Box paddingX={1}>
97          <Text wrap="truncate-end">
98            <Text color={BRAND} bold>{'◆ Links  '}</Text>
99            <Text color="red" bold>{`${n} not working`}</Text>
100            <Text dimColor>{` · ${first.url} (${label(first)}) in ${basename(first.file)}`}</Text>
101            {n > 1 && <Text dimColor>{` and ${n - 1} more`}</Text>}
102            <Text dimColor>{' · /links'}</Text>
103          </Text>
104        </Box>
105        {rest}
106      </Box>
107    )
108  })
109}
110
111// The file's problems are the known-bad links still in it, so a link Claude fixed drops off the band.
112async function refresh($: EngineInterface, path: string, checkedNow: number) {
113  const text = await $.fs.read(path).then(String, () => '')
114  const inFile = new Set(links(text))
115  const mine: Problem[] = []
116  for (const url of inFile) {
117    const r = await settled(url)
118    if (r && isProblem(r)) mine.push({ url, file: path, kind: r.kind as Problem['kind'], status: r.status })
119  }
120  await update($, line, l => ({ checked: l.checked + checkedNow, problems: [...l.problems.filter(p => p.file !== path), ...mine] }))
121}
122
123async function reportLate($: EngineInterface, path: string, late: { url: string; answer: Promise<Result> }[]) {
124  const answers = await Promise.all(late.map(c => c.answer.then(r => ({ url: c.url, r }))))
125  await refresh($, path, 0)
126  const bad = answers.filter(a => isProblem(a.r))
127  if (bad.length > 0) $.ui.toast(`link-check: ${bad.map(a => `${a.url} (${label(a.r)})`).join(', ')} in ${basename(path)}`)
128}
129
130// Links in what the edit wrote that weren't in what it replaced.
131export function newLinks(input: Record<string, unknown>, before: string) {
132  const pairs: [string, string][] = []
133  if (typeof input.content === 'string') pairs.push([input.content, before])
134  if (typeof input.new_string === 'string') pairs.push([input.new_string, String(input.old_string ?? '')])
135  if (Array.isArray(input.edits)) for (const x of input.edits as Record<string, unknown>[]) pairs.push([String(x.new_string ?? ''), String(x.old_string ?? '')])
136  const out = new Set<string>()
137  for (const [now, was] of pairs) {
138    const old = new Set(links(was))
139    for (const url of links(now)) if (!old.has(url)) out.add(url)
140  }
141  return [...out]
142}
143
144// Every external http(s) link in a text, once, without trailing punctuation and template placeholders.
145export function links(text: string) {
146  const out = new Set<string>()
147  for (const m of text.match(/https?:\/\/[^\s<>"'`)\]}|\\]+/g) ?? []) {
148    const url = m.replace(/[.,;:!?*_~]+$/, '')
149    if (/\$\{|\{\{|\.\.\.|…/.test(url)) continue
150    let host: string
151    try {
152      host = new URL(url).hostname
153    } catch {
154      continue
155    }
156    if (!host.includes('.') || SKIP_HOST.test(host)) continue
157    out.add(url)
158  }
159  return [...out]
160}
161
162// HEAD first; a host that refuses HEAD gets a GET. Each URL is asked once per session.
163function check($: EngineInterface, url: string): Promise<Result> {
164  let answer = cache.get(url)
165  if (!answer) {
166    answer = slot(async () => {
167      const ask = (method: string) => $.http.fetch(url, { method, headers: { 'user-agent': AGENT } })
168      let res = await ask('HEAD').catch(() => null)
169      if (!res || [403, 405, 501].includes(res.status)) res = (await ask('GET').catch(() => null)) ?? res
170      return classify(res?.status ?? null)
171    })
172    cache.set(url, answer)
173  }
174  return answer
175}
176
177// An answer that already came, without waiting for one that hasn't.
178async function settled(url: string) {
179  const answer = cache.get(url)
180  if (!answer) return null
181  return Promise.race([answer, Promise.resolve(null)])
182}
183
184// At most PARALLEL requests at once, so a page with many links doesn't flood anyone.
185async function slot<T>(job: () => Promise<T>): Promise<T> {
186  if (running >= PARALLEL) await new Promise<void>(go => queue.push(go))
187  running++
188  try {
189    return await job()
190  } finally {
191    running--
192    queue.shift()?.()
193  }
194}
195
196// 401, 403 and 429 are bot walls and rate limits: the page likely works in a browser, so they don't count.
197export const classify = (status: number | null): Result =>
198  status === null
199    ? { kind: 'unreachable', status }
200    : status < 300
201      ? { kind: 'ok', status }
202      : status < 400
203        ? { kind: 'redirect', status }
204        : [401, 403, 429, 999].includes(status)
205          ? { kind: 'blocked', status }
206          : { kind: 'broken', status }
207
208const isProblem = (r: Result) => r.kind === 'broken' || r.kind === 'unreachable'
209const label = (r: { kind: string; status: number | null }) =>
210  r.kind === 'unreachable' ? 'no answer' : r.kind === 'blocked' ? `${r.status}, blocks bots` : String(r.status)
211const icon = (r: Result) => (r.kind === 'ok' ? '✓' : r.kind === 'redirect' ? '↪' : r.kind === 'blocked' ? '~' : '✗')
212const basename = (p: string) => p.split('/').pop() ?? p
213
types/index.d.ts 20 lines
1// One external link that didn't answer as it should.
2export type Problem = {
3  url: string
4  file: string // the file it's in, as Claude edited it
5  kind: 'broken' | 'unreachable' // 4xx/5xx, or no answer at all
6  status: number | null
7}
8
9// What the band above the prompt draws.
10export type Line = {
11  problems: Problem[] // links still in their files that don't work
12  checked: number // links checked this session
13}
14
15declare module 'claude-code' {
16  interface PluginState {
17    'link-check': { line: Line }
18  }
19}
20