Site-to-Astro Migration Workflow
Reverse-engineer an existing website into a clean, fast, SEO-safe Astro codebase without losing indexed URLs, conversion tracking, forms, or visual quality.
Read references/principles.md and the plugin rules (rules/AGENTS.md in the full bundle, or references/rules.md when installed via install.sh/install.ps1) before making architectural decisions.
Script Path Resolution Across Harnesses
Depending on how the plugin was installed, locate scripts/*.mjs at the first existing path:
./scripts/site-to-astro/(copied into the target project with--copy-scripts/-CopyScripts)./scripts/insideskills/site-to-astro/(e.g.,.dsh/skills/site-to-astro/scripts/,.agents/skills/site-to-astro/scripts/,~/.hermes/skills/site-to-astro/scripts/)${CLAUDE_PLUGIN_ROOT}/scripts/or.agents/plugins/site-to-astro/scripts/(full plugin bundle)
Core Guardrails (Always Enforce)
- Authorization first: Confirm the user owns or has explicit permission to migrate the target domain and its media/fonts. Never bypass CAPTCHAs, logins, or anti-bot walls.
- Baseline before coding: Crawl and snapshot the legacy site (
audit/url-snapshot.json) before creating routes, schemas, or redirects. - Zero broken URLs: Every indexed URL from the baseline must resolve on the new Astro build either as
200 OKat its original path or via a server-level301redirect. - No hotlinking: Mirror images and fonts into the local repo (
public/images/,public/fonts/) instead of linking legacy CMS/CDN URLs. - Strict factual fidelity: Never invent prices, specifications, client testimonials, addresses, or legal details. Record missing or ambiguous data as open items for the owner.
Four-Phase Pipeline
Phase 1: Reconnaissance & Audit (site-audit)
Load skills/site-audit/SKILL.md (or run the bundled scripts directly):
- Crawl
robots.txt,sitemap.xml(including nested sitemap indexes), and internal links viascripts/crawl-site.mjs --save-html ./audit/raw-htmlto captureaudit/url-snapshot.json, saved raw HTML, and aggregated form/tracker/verification/SPA inventories. - Classify routes, detect CMS duplicates/trailing-slash clones, flag sitemap orphans (
0incoming internal links) and external favicons, and emitaudit/routes.json,audit/redirects-301.json,audit/redirects-301.conf, andaudit/REPORT.mdviascripts/analyze-routes.mjs. - Optionally run
scripts/cdp-inspect.mjs(--mode tokens/--mode spa --snapshot ... --only-spa --update-snapshot) to extract computed design tokens (audit/design-tokens.json), form endpoints, anti-spam fields, and post-hydration SPA HTML.
Phase 2: Astro Architecture & Migration (astro-architecture)
Load skills/astro-architecture/SKILL.md:
- Mirror local images (
--generate-variantswhencwebp/ffmpegis available),.woff2fonts, and documents viascripts/mirror-assets.mjs, then bootstrap the starter Astro codebase from audit artifacts withscripts/init-astro.mjs(auto-choosingoutput: 'static'vsssr,trailingSlash,tokens.css,BaseLayout.astro, proxy configs, and SSR middleware/API handlers). - Batch-extract clean Markdown/JSON Content Collections (
src/content/), Zodsrc/content.config.ts, andaudit/missing-fields.mdviascripts/extract-content.mjs --snapshot ..., keeping shared UI constants insrc/data/. - Rebuild page layouts cleanly with semantic HTML, CSS custom properties, and native browser primitives (
<dialog>,<details>), wired with persistent UTM/session attribution, Telegram/webhook/api/lead, explicitwidth/height,sitemap-images.xml, and a safeNetwork FirstService Worker (if PWA is needed).
Phase 3: Parity & Quality Assurance (parity-and-launch)
Load skills/parity-and-launch/SKILL.md:
- Run static diagnostics (
astro check), unit tests (slugs, domain logic, UTM logic, API validators), production build (npm run build),scripts/patch-adapter-paths.mjs(when SSR standalone), andscripts/report-launch.mjs(verify-parity,verify-seo,mirror-assets --check-hotlinks→audit/LAUNCH-READINESS.md). - Visually inspect Desktop (
1440px,1280px) and Mobile (390px) views viacdp-inspect.mjs --mode qa --test-interactions(plus optional--compare-dir ... --max-diff-percent) for zero horizontal overflow, symmetrical card heights, crisp image rendering, and form/modal interactions.
Phase 4: Safe Production Cutover (parity-and-launch)
- Lower DNS
TTL(300s) 24-48 hours prior to switching records. - Configure reverse proxy (
Caddy/Nginx) with canonical host redirect (www -> apex), legacy301map,Cache-Control: max-age=0on HTML, immutable cache on hashed bundles, and security headers. - Verify HTTPS against the target origin IP before checking propagation across public DNS resolvers and pausing paid traffic changes until propagation completes.
Available Bundle Files
- Engineering rules & anti-patterns: references/principles.md
- Harness installation guide: references/harness-setup.md
- Reference implementation patterns: BaseLayout.astro, middleware.ts, seo.ts, responsive.ts, sitemap-dates.mjs, robots.txt, utm.ts, utm.test.ts, sw.js, Lightbox.astro, LazyEmbed.astro, LeadForm.astro, CookieConsent.astro, api-lead.ts, Caddyfile, nginx.conf, deploy.yml
- Zero-dependency scripts:
scripts/crawl-site.mjs,scripts/analyze-routes.mjs,scripts/mirror-assets.mjs,scripts/extract-content.mjs,scripts/init-astro.mjs,scripts/build-image-manifest.mjs,scripts/sitemap-images.mjs,scripts/patch-adapter-paths.mjs,scripts/verify-parity.mjs,scripts/verify-seo.mjs,scripts/cdp-inspect.mjs,scripts/report-launch.mjs