seo-audit-skill
CLAUDE.md451 starsChanged 2 months agoMITView on GitHub
SEOmator is a comprehensive SEO audit tool (@seomator/seo-audit) with 373 rules across 20 categories. It ships as both a CLI tool (published to npm) and an Electron desktop app (local only). It fetches web pages, parses HTML with Cheerio, optionally measures Core Web Vitals via Playwright, and scores pages against SEO best practices. The package.json serves both the npm CLI package and the Electron desktop app. These fields have strict requirements: If you change main to anything other than the…
The file
We split this claude.md into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
dependencies: Only CLI packages (cheerio, commander, playwright, better-sqlite3, etc.). - Very specific: line 32
Verify dependencies contains only CLI packages (no react, zustand, recharts, electron)
- Very specific: line 33
Verify files: ["dist"] — only CLI build ships
- Distinctive: line 87
Run locally after building:
- Distinctive: line 92
Run a single test file:
- Very specific: line 155
Create src/rules/<category>/<rule-name>.ts exporting a const created via defineRule()
- Very specific: line 157
Import and registerRule() in src/rules/<category>/index.ts
- Very specific: line 225
Use null as any for context fields not relevant to the rule under test
- Distinctive: line 226
Import rules directly from their individual files, not via the category index
- Very specific: line 227
Run npm rebuild better-sqlite3 before running CLI tests if you were previously running Electron
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
SEOmator is a comprehensive SEO audit tool (@seomator/seo-audit) with 373 rules across 20 categories. It ships as both a CLI tool (published to npm) and an Electron desktop app (local only). It fetches web pages, parses HTML with Cheerio, optionally measures Core Web Vitals via Playwright, and scores pages against SEO best practices.
Critical Rules (read before making changes)
package.json Dual-Purpose Constraints
The package.json serves both the npm CLI package and the Electron desktop app. These fields have strict requirements:
| Field | Value | Why |
main | ./dist-electron/main/index.js | Electron reads this to find the main process entry. DO NOT change to ./dist/cli.js or Electron will execute Commander CLI instead of launching the app window. |
exports | ./dist/index.js | npm/Node.js consumers use this for programmatic imports (import { Auditor } from '@seomator/seo-audit'). Takes priority over main in modern Node.js. |
bin | ./dist/cli.js | npm CLI users use this (seomator command). |
files | ["dist"] | Only dist/ ships to npm. This is the firewall — electron/, dist-electron/, scripts/ never reach npm users. |
If you change main to anything other than the Electron entry, npm run electron:dev will break — Electron will print Commander help text and exit instead of opening the app window.
Dependency Split: CLI vs Electron
dependencies: Only CLI packages (cheerio, commander, playwright, better-sqlite3, etc.). These are what npm users install.devDependencies: Electron-only packages (react, react-dom, react-router-dom, recharts, zustand, electron, electron-vite, tailwindcss, etc.).- Never move react/zustand/recharts/electron packages into
dependencies— npm users would download ~15MB of unused Electron UI code.
npm Publishing Checklist
- Verify
dependenciescontains only CLI packages (no react, zustand, recharts, electron) - Verify
files: ["dist"]— only CLI build ships npm run build→ builds CLI via tsupnpm pack --dry-run→ confirm onlydist/files + README + package.jsonnpm publish --access public- The
prepublishOnlyscript auto-runsnpm run buildbefore publish
Published as @seomator/seo-audit on npm. Current version: 5.1.0.
better-sqlite3 Native Module ABI
better-sqlite3 is a C++ addon compiled against a specific Node.js ABI. Electron and CLI/Node.js use different ABIs:
npm run rebuild:electron # Before running Electron
npm run rebuild:cli # Before running CLI testsYou must recompile when switching between Electron and CLI. Failure produces
a cryptic NODE_MODULE_VERSION mismatch error.
Use the npm scripts, not electron-rebuild directly. On Apple Silicon the
artifact electron-rebuild restores carries a signature the kernel refuses at
load, even though codesign -v calls it "valid on disk". The Electron main
process then dies inside dlopen before drawing a window:
Exception: EXC_BAD_ACCESS, SIGKILL (Code Signature Invalid)
Termination: CODESIGNING, code 2, "Invalid Page"There is no stdout, no stack trace and no window — the only evidence is a crash
report in ~/Library/Logs/DiagnosticReports/Electron-*.ips. npm run
electron:dev simply appears to do nothing. This cost four sessions of the
desktop app being written off as untestable.
Both scripts run scripts/resign-native.mjs, which re-signs the module ad-hoc
(codesign --force --sign -). Re-signing a good binary is harmless, and the
script is a no-op off macOS.
Zero Modifications to src/
The Electron app is purely additive — all Electron code lives in electron/. The src/ directory is shared by both CLI and Electron through direct imports (via the @core alias in electron-vite config). Never put Electron-specific code in src/.
Build & Development Commands
CLI
npm run build # Build with tsup (ESM, single entry: src/cli.ts)
npm run dev # Build in watch mode
npm run test:run # Run all tests once (vitest)
npm test # Run tests in watch modeRun locally after building:
./dist/cli.js audit https://example.com --no-cwvRun a single test file:
npx vitest run src/rules/core/core.test.tsElectron Desktop App
npx electron-rebuild -f -w better-sqlite3 # Required before first run
npm run electron:dev # Dev mode with Vite HMR + Electron hot reload
npm run electron:build # Production build (main + preload + renderer)
npm run electron:pack # Build + package into distributableLocal Web Dashboard (seomator serve)
npm run web:build # Build the browser bundle into dist/web
npm run web:dev # API (node --watch) + Vite dev server, concurrently
./dist/cli.js serve # Serve stored audits on 127.0.0.1:7360The dashboard and the Electron app render the same React code from ui/.
The only difference is the transport behind getAPI(): Electron supplies the
IPC bridge, the browser gets an HTTP adapter. A change in ui/ affects both —
build and check both before assuming a UI fix is done.
serve mints a per-launch token, sets it as an HttpOnly cookie on every
document response, and writes it to $SEOMATOR_HOME/serve.json (0600) for
scripted access as X-SEOmator-Token. Restarting the server invalidates any
open tab's cookie: the UI detects the 401 and asks for a reload, because
retrying the same fetch can never pick up a new cookie.
Docs and token drift
npm run check:docs # Rule/category totals and version across the docs
npm run check:tokens # ui/styles/tokens.css matches src/design/tokens.tsBoth run in prepublishOnly. src/design/tokens.ts is the single source for
every colour; ui/styles/tokens.css is generated from it by a Vite plugin at
buildStart. Never edit the generated file, and never put a hex literal in
ui/ — a test rejects both.
Architecture
Rule System (the core abstraction)
The entire audit engine is built on a self-registering rule pattern:
defineRule()(src/rules/define-rule.ts) - Creates and validates anAuditRuleobject withid,name,description,category,weight, andrun(context)function.registerRule()(src/rules/registry.ts) - Stores rules in a globalMap<string, AuditRule>. Throws on duplicate IDs.- Category
index.tsfiles (e.g.,src/rules/core/index.ts) - Import individual rule files and callregisterRule()for each. This is the registration point. src/rules/loader.ts- Static-imports all 20 categoryindex.tsfiles. The act of importing triggers side-effect registration.loadAllRules()exists for API compat but rules load at import time.- Result helpers:
pass(ruleId, message, details?),warn(...),fail(...)returnRuleResultwith scores 100/50/0 respectively.
Adding a New Rule
- Create
src/rules/<category>/<rule-name>.tsexporting a const created viadefineRule() - Rule ID convention:
<category>-<descriptive-name>(e.g.,core-canonical-conflicting) - Import and
registerRule()insrc/rules/<category>/index.ts - The
runfunction receivesAuditContextand returnsRuleResult(or Promise)
AuditContext
Defined in src/types.ts. Every rule receives the same context object containing:
- Always available:
url,html,$(CheerioAPI),headers,statusCode,responseTime,cwv,links,images,invalidLinks,specialLinks,figures,inlineSvgs,pictureElements - Tier 2 (network-fetched, optional):
robotsTxtContent,sitemapContent,sitemapUrls,redirectChain - Tier 4 (Playwright, optional):
renderedHtml,rendered$(CheerioAPI of rendered DOM)
Scoring Model
- Rule level:
pass=100,warn=50,fail=0 (src/scoring.ts) - Category score: Weighted average of rule scores within the category
- Overall score: Weighted average of category scores using category weights
- Category weights must sum to exactly 100 (validated by
validateCategoryWeights()insrc/categories/index.ts)
20 Categories & Weights
core(11%), perf(10%), links(8%), images(8%), security(8%), a11y(7%), technical(7%), crawl(5%), schema(5%), content(5%), js(5%), social(3%), eeat(3%), url(3%), redirect(3%), mobile(2%), i18n(2%), htmlval(2%), geo(2%), legal(1%)
Audit Flow
Auditor class (src/auditor.ts) orchestrates:
loadAllRules()→ triggers static importsfetchPage()→ HTTP fetch + Cheerio parse →AuditContext- (Optional)
fetchPageWithPlaywright()→ CWV metrics + rendered DOM enrichContext()→ fetches robots.txt + sitemap once per auditrunAllCategories()→ iterates categories →getRulesByCategory()→ runs each rulebuildAuditResult()→ weighted scoring
Key Directories
src/rules/- 373 audit rules in 20 category subdirectoriessrc/categories/- Category definitions with weightssrc/commands/- CLI command handlers (audit, crawl, init, config, db, etc.)src/crawler/- HTTP fetcher, queue-based crawler, URL normalizationsrc/reporters/- Output formatters (console, json, html, markdown, llm)src/storage/- SQLite persistence (project-db, audits-db, link-cache)src/config/- TOML config loading, validation, presetssrc/dashboard/-seomator serve: HTTP server, routes, SSE, run session, read queriessrc/design/-tokens.ts, the single source for every colour on every surfaceui/- Top level, not underelectron/. The React app rendered by both the desktop app and the web dashboard: pages, components, hooks, stores. Anything changed here ships to both surfaces.electron/- Electron desktop app (does NOT modifysrc/)electron/main/- Main process: BrowserWindow, IPC handlers, audit/db bridgeselectron/preload/- contextBridge exposing typedelectronAPIelectron/shared/- IPC type definitions shared between main and renderer
Electron Desktop App Architecture
The desktop app wraps the existing audit engine without modifying src/:
- IPC Bridge pattern:
audit-bridge.tswrapsAuditorcallbacks →webContents.send()for streaming progress.db-bridge.tswrapsAuditsDatabase→ipcMain.handle()for queries. - Preload security:
contextIsolation: true,nodeIntegration: false. The preload script exposes a typedElectronAPIviacontextBridge.exposeInMainWorld(). - State management: Zustand store (
audit-store.ts) with state machine:idle → running → complete | error. IPC events drive state transitions. - Rule metadata: The rule registry only exists in the main process. After an audit completes,
audit-bridge.tsbuilds aruleId → { name, description }map viagetRuleById()and sends it alongside theAuditResultso the renderer can display rule names and descriptions. - Design tokens: CSS variables in
globals.cssextracted fromsrc/reporters/html-reporter.tsfor visual consistency. Light/dark theme support via[data-theme="dark"]. - Build: electron-vite handles the triple build (main → CJS, preload → ESM, renderer → Vite/React). Config:
electron/electron-vite.config.ts. - Path aliases:
@core→../src(access CLI engine from Electron main),@renderer→./renderer. - CSS: Tailwind v4 uses
@theme {}block for custom properties.@layer baseis critical — unlayered CSS overrides Tailwind v4 utilities. getAPI()returnsnulloutside Electron — all renderer hooks must null-guard.
Testing Conventions
- Test files:
src/rules/<category>/<category>.test.ts - Tests create a minimal
AuditContextusingcheerio.load(html)for$, with stub values for other fields - Use
null as anyfor context fields not relevant to the rule under test - Import rules directly from their individual files, not via the category index
- Run
npm rebuild better-sqlite3before running CLI tests if you were previously running Electron
Tech Stack
CLI (src/)
- TypeScript (ES2022 target, ESM modules, bundler resolution)
- tsup for building (single ESM entry,
#!/usr/bin/env nodebanner) - vitest for testing
- Cheerio for HTML parsing
- Playwright for CWV measurement and rendered DOM capture
- better-sqlite3 for storage
- Commander for CLI parsing
- chalk/ora/cli-table3/log-update for terminal UI
Desktop App (electron/)
- Electron + electron-vite (triple build: main/preload/renderer)
- React with Tailwind CSS v4 (uses
@theme {}block for custom properties) - Zustand for state management
- Recharts for score trend charts
- electron-builder for packaging
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

