Prompt to crawl the old site into a URL inventory before migrating

Short answer

This prompt asks an AI assistant to read the live site's sitemap, fetch every page, and write inventory.csv with one row per URL: status, title, description, h1, word count, canonical and internal links. You run it before the export, so you have a record to prove parity against afterwards.

Last reviewed

Key facts

  • The inventory is a CSV you can diff later, so run it on the old site before anything changes.
  • A sitemap lists what the owner wants found. Pages missing from it show up only if the assistant also reads home page links.
  • The reference script needs Node 18 or newer and no paid key. A Firecrawl map or crawl call is an option for large sites.
  • Test status: the reference script was run on webexport.online, 30 pages from its sitemap, and wrote a 30-row CSV with every column listed below. The Firecrawl map and crawl calls were not run, because no API key was used.

The prompt

Paste this into Claude Code, Cursor, Codex or another AI coding assistant with your project folder open, and replace everything in square brackets first. See how to run it in each tool.

Build the URL inventory
You are building a URL and content inventory of a live website before it is migrated. The site is [LIVE_URL].

READ
- [LIVE_URL]/sitemap.xml, and any sitemap file it lists. If there is no sitemap, read the links on the home page instead and say so in the report.
- Nothing else. Do not log in to anything.

STEP 1: LIST
Fetch every URL from the sitemap, up to [MAX_PAGES: 200] pages, with at most 5 requests at a time. For each URL record: path, HTTP status, final path after redirects, title, meta description, h1, number of h1 tags, visible word count, canonical URL, number of internal links and a hash of the visible text.
Write the result to inventory.csv in the project root.

STEP 2: GROUP
Write INVENTORY.md with:
- the number of pages for each first path segment (blog, products and so on)
- every page whose status is not 200
- every page with no title, no description, no h1 or more than one h1
- every page under 100 words
- every page whose canonical points to a different path
- the 20 pages with the most internal links

STEP 3: CMS CANDIDATES
List path patterns that repeat 5 or more times, for example /blog/*. They are probably CMS collections. Do not extract their content now.

RULES
- Make GET requests to [LIVE_URL] only. Never submit a form.
- Do not edit or delete any file except inventory.csv and INVENTORY.md.
- If scripts/inventory.mjs exists, use it. Otherwise write a Node 18 script with no dependencies.
- Say which values you could not read and why. Do not guess a value.

How to run it

  1. Open the project folder in your assistant and make sure the live site is still published.
  2. Send the prompt with the live URL filled in. Keep MAX_PAGES small for the first run.
  3. Read INVENTORY.md before you export anything, and fix problems you want gone in the new site while you still have the old one to compare.
  4. Commit inventory.csv. You will feed it to the parity check after the migration.

Run it without a paid key

This script does the same job with no account. It reads sitemap.xml, follows a sitemap index one level down, and falls back to the home page links when there is no sitemap. Save it as scripts/inventory.mjs and run it with Node 18 or newer. The regular expressions are simple on purpose, so a page with an unusual meta tag order can come back with an empty description. Check a few rows by hand.

scripts/inventory.mjs
// Usage: node inventory.mjs https://example.com 50 > inventory.csv
// Reads sitemap.xml (falls back to links on the home page), fetches each page and writes one CSV row per URL.
import { createHash } from 'node:crypto';

const [base, limit = '50'] = process.argv.slice(2);
if (!base) { console.error('Usage: node inventory.mjs https://example.com [limit]'); process.exit(1); }
const origin = new URL(base).origin;

async function get(url) {
  try {
    const r = await fetch(url, { redirect: 'follow', headers: { 'user-agent': 'site-inventory/1.0' }, signal: AbortSignal.timeout(15000) });
    return { status: r.status, url: r.url, text: await r.text() };
  } catch { return { status: 0, url, text: '' }; }
}
const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1].replace(/&amp;/g, '&'));
async function sitemapUrls(url, depth = 0) {
  const r = await get(url);
  if (r.status !== 200) return [];
  const found = locs(r.text);
  if (!/<sitemapindex/.test(r.text) || depth > 1) return found;
  return (await Promise.all(found.map((s) => sitemapUrls(s, depth + 1)))).flat();
}
const visible = (html) => html.replace(/<(script|style|noscript|svg)[\s\S]*?<\/\1>/gi, ' ').replace(/<[^>]+>/g, ' ').replace(/&[#\w]+;/g, ' ').replace(/\s+/g, ' ').trim();
const decode = (s) => s.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#x27;|&#39;/g, "'");
const first = (html, re) => decode((html.match(re)?.[1] ?? '').replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim());
const q = (v) => `"${String(v).replace(/"/g, '""')}"`;

let urls = await sitemapUrls(`${origin}/sitemap.xml`);
if (!urls.length) {
  const home = await get(origin);
  urls = [origin, ...[...home.text.matchAll(/href=["'](\/[^"'#?]*)["']/g)].map((m) => origin + m[1])];
}
urls = [...new Set(urls)].filter((u) => u.startsWith(origin)).slice(0, Number(limit));

const cols = ['path', 'status', 'final_path', 'title', 'description', 'h1', 'h1_count', 'words', 'canonical', 'internal_links', 'text_hash'];
console.log(cols.join(','));
const queue = [...urls];
const rows = [];
await Promise.all(Array.from({ length: 5 }, async () => {
  while (queue.length) {
    const u = queue.shift();
    const r = await get(u);
    const text = visible(r.text);
    const h = r.text;
    rows.push([
      new URL(u).pathname, r.status, new URL(r.url).pathname,
      first(h, /<title[^>]*>([\s\S]*?)<\/title>/i),
      first(h, /<meta[^>]+name=["']description["'][^>]*content=["']([^"']*)/i),
      first(h, /<h1[^>]*>([\s\S]*?)<\/h1>/i),
      (h.match(/<h1[\s>]/gi) ?? []).length,
      text ? text.split(' ').length : 0,
      first(h, /<link[^>]+rel=["']canonical["'][^>]*href=["']([^"']+)/i),
      (h.match(/href=["'](\/(?!\/)|https?:\/\/(?:www\.)?[^"']*)/g) ?? []).filter((x) => x.includes('href="/') || x.includes("href='/") || x.includes(origin)).length,
      createHash('sha1').update(text).digest('hex').slice(0, 12),
    ]);
  }
}));
rows.sort((a, b) => String(a[0]).localeCompare(String(b[0])));
for (const row of rows) console.log(row.map(q).join(','));
console.error(`Wrote ${rows.length} rows from ${origin}`);

The Firecrawl path

Firecrawl is a hosted web data API. For a large site, or one that draws its content with JavaScript, its calls save you from writing the crawler. Everything here is taken from the map, crawl and billing pages, read on 2026-11-29. Prices and limits change, so check them before you rely on them.

CallWhat you getCredits per the billing page
POST /v2/mapA list of URLs for a site, with a title and description where available. One synchronous response, up to 100,000 links.1 per call
POST /v2/crawlStarts a crawl and returns an id. Poll GET /v2/crawl/{id} for status and pages. Results stay available for 24 hours.1 per page
POST /v2/scrapeOne page as markdown, html, links or JSON, with metadata such as the status code.1 per page, and the JSON format adds 4

Map is the quickest way to list URLs. It does not return word counts or h1 tags, so use a crawl or the script above for those columns.

terminal
curl -s -X POST https://api.firecrawl.dev/v2/map \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","limit":500,"sitemap":"include"}'

Keep the key in an environment variable. Tell the assistant never to write it into a file or a commit.

Verify the result

Check that the row count matches the sitemap and that the status column looks right.

terminal
curl -s https://example.com/sitemap.xml | grep -o "<loc>" | wc -l
wc -l inventory.csv
cut -d, -f2 inventory.csv | sort | uniq -c
head -3 inventory.csv
  • The row count is the sitemap count plus one header line, or lower by the limit you set.
  • The status column is mostly "200", and every other value appears in INVENTORY.md.
  • Three pages you open by hand match their rows for title, h1 and word count.

What can go wrong

  • A sitemap that is out of date lists deleted pages and hides new ones. Compare it with the pages you can click to.
  • Pages that fill in text with JavaScript show a low word count in a plain fetch. A Firecrawl scrape renders the page first.
  • Fetching too fast can trip a rate limit on the old host. Keep the concurrency at 5 or lower.

Frequently asked questions

Why build an inventory before exporting?

After the move you need proof that every page still exists with the same title and content. Only a record taken from the old site can give you that.

Do I need Firecrawl for this?

No. The script on this page reads a sitemap and fetches pages with Node alone. Firecrawl helps when a site is large or draws content with JavaScript.

What about pages that are not in the sitemap?

The prompt falls back to home page links when there is no sitemap. For a thorough list, add the URL list from your analytics or the Sitemap URL Extractor.

Can I use the CSV for redirects?

Yes. It is the list of old paths you need to cover. Feed it to the redirect map prompt once the new URLs are known.

Official documentation

Free tools for this job

Start with the files

Prompts work best on a WebExport download of your site. Paste your public URL into the export form and get a ZIP. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.