A Node.js CLI tool that detects broken links, auto-fixes href references, generates redirect configurations for major platforms, and monitors endpoints for 500-class server errors.
- Broken Link Detection: Crawls your site using Playwright, discovers all internal links, and checks each one for 404s, redirect chains, and server errors.
- Auto-Fix Suggestions: Computes fix suggestions for broken links using fuzzy matching and path similarity against known-good URLs. Applies fixes to source files when confidence is high enough.
- Redirect Generation: Produces ready-to-use redirect configurations for Next.js (
next.config.jsredirects array), Netlify (_redirectsfile), and nginx (mapblock). - Health Monitoring: Performs periodic synthetic checks against your endpoints, detects 500-class errors, extracts stack traces, classifies the error pattern (timeout, OOM, database, upstream, config, unhandled exception), and recommends bounded remediation actions (restart, rollback, feature-flag-off, or open-issue).
npm install -g site-autofixOr run directly from the repo:
git clone <repo-url>
cd site-autofix
npm install
npm run buildCrawl a site and report broken links.
site-autofix scan https://example.com| Option | Default | Description |
|---|---|---|
--max-pages <n> |
100 | Maximum pages to crawl |
--timeout <ms> |
15000 | Request timeout |
--concurrency <n> |
5 | Concurrent link checks |
--exclude <patterns...> |
— | URL patterns to exclude (regex) |
--output <format> |
console | Output: json, console, or both |
--output-file <path> |
— | Write JSON report to file |
Exit codes: 0 = all links healthy, 1 = broken links found, 2 = scan error.
Scan for broken links and generate redirect configurations.
site-autofix fix https://example.com --target ./redirects --format netlify| Option | Default | Description |
|---|---|---|
--target <dir> |
. |
Directory to write redirect configs |
--format <fmt> |
all | Redirect format: nextjs, netlify, nginx, or all |
--min-confidence <n> |
0.5 | Minimum confidence threshold (0-1) |
--max-pages <n> |
100 | Maximum pages to crawl |
--timeout <ms> |
15000 | Request timeout |
--concurrency <n> |
5 | Concurrent link checks |
--output <format> |
console | Output: json, console, or both |
--output-file <path> |
— | Write JSON report to file |
Generated files:
generated-redirects.js(Next.js)_redirects(Netlify)nginx-redirects.conf(nginx)
Periodically check endpoints for 500-class errors.
site-autofix monitor https://example.com --endpoints / /api/health /api/data --rounds 5| Option | Default | Description |
|---|---|---|
--endpoints <paths...> |
/ |
Endpoint paths to check |
--interval <ms> |
30000 | Interval between rounds |
--timeout <ms> |
10000 | Request timeout |
--rounds <n> |
1 | Number of rounds (0 = indefinite) |
--output <format> |
console | Output: json, console, or both |
--output-file <path> |
— | Write JSON report to file |
Error classifications:
timeout— Endpoint timed outoom— Out of memory detecteddatabase-error— Database connection issueupstream-dependency— Upstream service failure (502/503/504)configuration-error— Missing config or env varsunhandled-exception— Uncaught error with stack traceunknown— Unclassifiable error
Recommended actions per classification:
restart— Restart the service (timeout, OOM, database)rollback— Roll back to last known good deploy (config errors)feature-flag-off— Disable the affected feature (unhandled exceptions)open-issue— File an issue with repro artifacts (upstream, unknown)
src/
cli.ts CLI entry point (commander)
types.ts Shared TypeScript types
link-scanner.ts Crawl + check links (Playwright + fetch)
link-fixer.ts Fuzzy matching + fix computation
redirect-generator.ts Next.js / Netlify / nginx config output
health-monitor.ts Synthetic health checks + error classification
reporter.ts Console + JSON output formatting
-
Scanning uses Playwright to render pages (handling JS-rendered content), then extracts all
<a href>elements. Each discovered internal link is checked viafetchwith redirect tracking. -
Fixing takes the broken links and compares them against known-good URLs using a weighted combination of path segment overlap (60%) and Levenshtein edit distance (40%). Links with redirect targets get a 95% confidence automatic fix.
-
Redirect generation converts the fix map into platform-specific config files, each with inline comments explaining how to integrate them.
-
Monitoring runs periodic
fetchrequests against configured endpoints, collects response headers and bodies for failing requests, extracts stack traces using regex patterns for Node.js/Python/Java/Ruby, classifies the error, and maps it to a bounded remediation action.
- Node.js >= 18
- Playwright browsers (installed automatically on first run, or run
npx playwright install chromium)
MIT