Skip to main content
Glama
README.md
# shipcard

Check how your site's links will look when they're shared, and whether search engines and AI assistants can find
it, before you deploy.

shipcard reads your built HTML and checks the Open Graph and X/Twitter card tags on every page. It loads the
images, simulates the preview on eleven platforms, and scores each page out of 100. It also checks robots.txt,
the sitemap, llms.txt, meta robots and JSON-LD. Every problem comes with the fix, usually a tag you can paste
into `<head>`.

```bash
npx @otterolie/shipcard ./dist
```

It works on a build folder, a single HTML file, stdin, a live URL or a sitemap. Nothing is uploaded anywhere, and
it doesn't need a browser.

## Quick start

```bash
# Before deploying: check the build, using images from the folder and skipping remote fetches
npx @otterolie/shipcard ./dist --offline

# After deploying: check the live site from its sitemap
npx @otterolie/shipcard https://example.com/sitemap.xml

# Install it as a dev dependency instead
npm i -D @otterolie/shipcard
```

Requires Node 22 or newer.

## What the output looks like

```text
$ npx @otterolie/shipcard ./dist --offline

Pages: 3 (2 pass, 0 warn, 1 fail)
Score: 83/100 (min 48) (Warn)

Pages:
✕ /blog/launch.html  48    Fail
✓ /index.html        100   Pass
✓ /pricing.html      100   Pass

Site issues:
  • 2 pages share the same title: "Acme: project boards for small teams"
    /index.html, /pricing.html

/blog/launch.html
Issues:
  • og:title is missing.
  • The title "Vite App" looks like template text.
  • og:image is relative ("/blog/cover.png"). Use an absolute https:// URL in production.
  • og:image is 800x400. Recommended: 1200x630.
Fixes (48 → 100, +52):
  +10  Add og:description                      <meta property="og:description" content="[What this page offers, 50-2…
  +10  Resize og:image to at least 1200x630    Meta, LinkedIn, and X expect at least 1200x630 (1.91:1) for large car…
  +10  Use an absolute URL for og:image        <meta property="og:image" content="https://acme.dev/blog/cover.png">
   +7  Add og:title                            <meta property="og:title" content="[Page title, 10-70 characters]">
   +5  Add twitter:card                        <meta name="twitter:card" content="summary_large_image">

Discoverability (search and AI):
  ✓ robots.txt   ✓ sitemap   ✕ llms.txt   ✕ search and AI crawlers allowed
  •  robots.txt blocks OAI-SearchBot (OpenAI), so the site can't appear in ChatGPT search results.
      Allow these crawlers in robots.txt if the site should appear in their answers.
  •  No /llms.txt was found.
```

Add `--preview` to get an HTML page that mocks up the card on every platform.

## What it checks

### Social cards

For every page shipcard reads `<title>`, the meta description, `og:*` and `twitter:*` tags, and the canonical link,
then checks:

- Missing `og:title`, `og:description`, `og:image`, `twitter:card` or canonical, and duplicates of any of them
- Template text left in titles and descriptions ("Vite App", "Home", "Untitled"), and text too short or too long
  for a card
- `og:url`, canonical and image URLs that are relative, `localhost`, `http://` or `data:`
- Images that are missing, can't be decoded, are SVG or AVIF, smaller than 1200x630, far from the 1.91:1 shape, or
  over 5 MB
- `og:image:width`/`height` that don't match the real file
- Images missing from the scanned folder but present in a sibling folder (a sign you scanned the wrong build
  output)
- Social tags more than 50 KB into the HTML, past where some crawlers stop reading
- The same title or description used on several pages

Folder scans find the usual build folders (`dist`, `out`, `build`, `public`, `.output`, `export`) when run from a
project root, look inside split client/server output, skip `<meta http-equiv="refresh">` redirect stubs, and group
issues that repeat across pages.

### Search and AI discoverability

Links in ChatGPT, Claude, Perplexity and Google answers use the same tags, but only if the crawlers may read the
site. shipcard checks:

- **robots.txt**, read with an RFC 9309 parser. Each search and AI crawler is tested against your rules. Blocking
  one that shows or cites pages (Googlebot, Bingbot, OAI-SearchBot, ChatGPT-User, Claude-SearchBot, PerplexityBot,
  ...) is a warning. Blocking one that only collects training data (GPTBot, ClaudeBot, Google-Extended, CCBot, ...)
  is noted as information, since that is a reasonable choice and doesn't hide the site.
- **A sitemap**, from robots.txt `Sitemap:` lines or `/sitemap.xml`.
- **llms.txt**: whether it exists and follows the [llms.txt format](https://llmstxt.org).
- **Each page**: `noindex` and `nosnippet` in meta robots, JSON-LD that isn't valid JSON, no JSON-LD at all, and a
  missing `<html lang>`.

Folder audits read these files from the build folder, so this works before you deploy. URL audits fetch them from
the live site. These checks don't change the card score. Turn them off with `--no-discovery`.

## Using it with AI agents

When a link shares with no image or the wrong title, a coding agent shouldn't have to guess which tag broke or grep
the whole repo for `<head>`. shipcard tells it which pages fail, which source file owns the tags, and what to put
there.

### Set up a repo in one command

```bash
# Adds .mcp.json + .agents/skills/shipcard/SKILL.md (+ AGENTS.md with --all)
npx @otterolie/shipcard init --all

# Or install the skill directly via the Agent Skills CLI
npx skills add otterolie/shipcard
```

### Connect the built-in MCP server

shipcard ships a stdio MCP server with no extra dependencies. Add it to `.mcp.json`, Claude Code, Cursor, or
Antigravity:

```json
{
  "mcpServers": {
    "shipcard": {
      "command": "npx",
      "args": ["-y", "@otterolie/shipcard", "mcp"]
    }
  }
}
```

Tools: `audit_site`, `audit_url`, `check_image`, `explain_code`, and `compare_reports`.

### Or call the CLI with `--brief`

```bash
# Built static or SSG site (finds dist/, out/, build/, public/, .output/ from ".")
npx @otterolie/shipcard . --offline --brief --failures-only

# SSR app running locally (for example Next.js App Router)
npx @otterolie/shipcard http://localhost:3000 --site-url https://acme.dev --brief

# Check a single OG image right after creating or resizing it
npx @otterolie/shipcard check-image public/og.png --json

# Look up any warning code on demand
npx @otterolie/shipcard explain og-image-too-small --json

# Compare before and after fixing
npx @otterolie/shipcard . --offline --brief --failures-only --compare before.json
```

- Every issue has a stable `code` and a one-line `hint` ([docs/warning-codes.md](docs/warning-codes.md)).
- `--brief` returns `schemaVersion`, detected `framework` and matching `sourceFiles`, grouped `actions` sorted by
  score gain, and `imageSpec` when an OG image is missing or invalid.
- Exit codes: `0` ran fine, `1` a `--fail-below`/`--fail-on` gate failed (or `check-image` found an error), `2`
  shipcard couldn't run (prints a JSON error object with `code`, `message` and `hint`).
- Placeholders in snippets are bracketed (`[Page title, 10-70 characters]`, `[your-domain.com]`). shipcard fails any
  page that ships a bracketed placeholder or fake domain like `your-site.com`, so an agent can't publish them by
  accident.

The package ships an agent skill ([skills/shipcard/SKILL.md](skills/shipcard/SKILL.md)), a Claude Code plugin
([.claude-plugin/plugin.json](.claude-plugin/plugin.json)), an Official MCP Registry manifest
([server.json](server.json)), [llms.txt](llms.txt), and the field reference ([docs/json-output.md](docs/json-output.md)).

## Using it in CI

```bash
# Fail the build if any page fails, without fetching remote images
npx @otterolie/shipcard ./dist --offline --fail-on fail

# Or set a minimum average score
npx @otterolie/shipcard ./dist --offline --fail-below 85

# Keep the report as an artifact
npx @otterolie/shipcard ./dist --offline --json --output shipcard-report.json
```

`--fail-on fail` (or `warn`) is usually the better gate: an average can hide one broken page.

### Before the site is live

If your HTML already uses production image URLs like `https://example.com/og.png`, shipcard looks for the same path
in your build folder and checks that file instead. Images that aren't in the folder would 404 on a live fetch,
so before deploying pass:

- `--offline` to check local files only and skip remote fetches, or
- `--no-images` to skip image checks entirely.

After deploying, run it again without `--offline` to check the live URLs.

## Scoring

Each page starts with 100 points spread over these checks:

| Check | Points |
| --- | ---: |
| `og:title` (partial credit if only `<title>` exists) | 15 |
| `og:description` (partial credit if only the meta description exists) | 10 |
| `og:image` present | 15 |
| Image loads as PNG, JPEG or WebP (partial credit for AVIF) | 15 |
| Image at least 1200x630 | 10 |
| Image aspect ratio near 1.91:1 | 5 |
| `og:url`, canonical and image URLs are absolute `https://` (not localhost, relative or `data:`) | 10 |
| Valid `twitter:card` (partial credit for `summary` when the image suits `summary_large_image`) | 5 |
| Title and description read well (template text fails; odd lengths get partial credit) | 5 |
| Canonical link | 5 |
| No duplicate core tags | 5 |

- `90-100` is a pass, `70-89` a warning, below `70` a fail. An error-level issue, such as a broken `twitter:image`,
  stops a page from passing whatever its score.
- Checks that can't run are left out of the total, not counted as failures. Image checks are skipped under
  `--no-images` or for remote images under `--offline`. URL checks are skipped when a page has no URLs at all. The
  report's `coverage` says how much of the 100 was checked, and the terminal prints "70% of checks ran" when it
  wasn't all of it.
- Multi-page reports give the average `score` and the worst page's `minScore`.

## Platforms

shipcard simulates each platform's fallback order, text truncation and image size rules for Meta (Facebook and
Instagram), LinkedIn, X, Pinterest, Slack, Discord, WhatsApp, Telegram, Bluesky, Mastodon and iMessage.

Things worth knowing:

- **X** needs `twitter:card` (`summary_large_image` for the big card).
- **LinkedIn** reads Open Graph only and caches previews for about 7 days. Refresh with Post Inspector.
- **WhatsApp** often skips images over 600 KB.
- **Pinterest** prefers tall 2:3 images (around 1000x1500).
- **Discord** shows a full-width image only with `twitter:card="summary_large_image"`.

## Options

| Flag | Description |
| --- | --- |
| `--json` | Print the full report as JSON, with fixes and grouped `actions` |
| `--brief` | Print compact JSON for agents: `framework` + `sourceFiles`, issues with hints, `imageSpec`, and grouped `actions` |
| `--site-url <url>` | Intended production origin (used for host inference and mapping production OG images on `localhost` dev servers) |
| `--compare <file>` | Compare the current run against a previous `--json` or `--brief` report file |
| `--fail-below <n>` | Exit 1 if the average score is below `n` (0-100) |
| `--fail-on <warn\|fail>` | Exit 1 if any page has status `warn` or `fail` |
| `--offline` | Check local files only; never fetch remote images or remote discovery files |
| `--no-images` | Skip image loading and size checks |
| `--no-discovery` | Skip the robots.txt, sitemap, llms.txt, meta robots and JSON-LD checks |
| `--ignore <pattern>` | Skip matching paths or file names (repeatable, e.g. `--ignore 404.html --ignore "/admin/**"`) |
| `--include-redirects` | Include `<meta http-equiv="refresh">` redirect stubs |
| `--failures-only` | Hide passing pages in terminal, `--brief`, and `--json` output |
| `--sitemap` | Treat a URL as an XML sitemap even if it doesn't end in `.xml` |
| `--max-pages <n>` | Maximum pages to audit (default `50` for sitemaps, unlimited for folders) |
| `--timeout <ms>` | Network timeout in milliseconds |
| `--preview [file]` | Write an HTML page mocking up every platform's card (default `shipcard-preview.html`) |
| `--embed` | With `--preview`, inline local images so the file works on its own |
| `--output <file>` | Also write the report (JSON or plain text) to a file |
| `--watch` | Re-run when files in a local folder change |
| `-h, --help` | Show help |
| `-V, --version` | Show the version |

Subcommands: `shipcard mcp`, `shipcard init [dir]`, `shipcard explain [code]`, `shipcard check-image <path|url>`.

## Library API

```ts
import fs from "node:fs/promises";
import { audit, applyFixes, fixesForPage, renderTerminal, toBriefReport } from "@otterolie/shipcard";

const report = await audit("./dist", { offline: true, ignore: ["404.html"] });
console.log(renderTerminal(report, { failuresOnly: true }));

// The compact report agents get from --brief
const brief = toBriefReport(report);

// Apply the suggested tag fixes to a page
const page = report.pages[0];
const html = await fs.readFile(page.source, "utf8");
await fs.writeFile(page.source, applyFixes(html, fixesForPage(page, report)));
```

Also exported:

- `auditHtml`, `auditUrl`, `auditFolder`, `auditSitemap`, `parseSitemapXml`
- `extractMeta`, `scorePage`, `validateImage`, `platformPreviews`
- `toJsonReport`, `renderPreviewHtml`
- `parseRobotsTxt`, `isAllowed`, `checkSite`, `checkPageSignals`
- `CODES` (the warning catalogue), `CRAWLERS`
- The TypeScript types for every report object

## Limits

- It reads static HTML. Tags that only appear after JavaScript runs are not seen.
- Platform previews follow each platform's documented rules, which change from time to time.
- The discoverability checks test the site root against robots.txt, not every individual URL.

## Contributing

[AGENTS.md](AGENTS.md) explains the layout and how to add a check, warning, platform or crawler.
[ROADMAP.md](ROADMAP.md) lists what's planned and [CHANGELOG.md](CHANGELOG.md) what's changed.

## License

MIT