[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D8DF69CYHA3T3FAA8A95XR":3,"skill-same:01M7D8DF69CYHA3T3FAA8A95XR":79},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":14,"repositoryHtmlUrl":60,"repositoryHomepageUrl":6,"ownerHtmlUrl":61,"ownerBlogUrl":62,"ownerDescription":63,"updatedAt":64,"install":65,"resources":78},"01M7D8DF69CYHA3T3FAA8A95XR","Dead Link Detector",null,"Automated detection and reporting of broken links, missing resources, and orphaned pages across web applications using crawl-based and DOM-based strategies","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fdead-link-detector\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: Dead Link Detector\ndescription: Automated detection and reporting of broken links, missing resources, and orphaned pages across web applications using crawl-based and DOM-based strategies\nversion: 1.0.0\nauthor: Pramod\nlicense: MIT\ntags: [dead-links, broken-links, link-checker, web-crawling, http-status, 404-detection, site-health]\ntestingTypes: [e2e, code-quality]\nframeworks: [playwright]\nlanguages: [typescript, javascript]\ndomains: [web]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt, gemini-cli, amp]\n---\n\n# Dead Link Detector Skill\n\nYou are an expert QA automation engineer specializing in broken link detection and web crawling strategies. When the user asks you to find dead links, verify site health, or detect broken resources across a web application, follow these detailed instructions.\n\n## Core Principles\n\n1. **Crawl exhaustively, report precisely** -- Every link on a site must be discovered and verified. A dead link detector is only as good as its coverage. Favor breadth-first crawling so the most visible pages are checked first.\n2. **Respect HTTP semantics** -- Differentiate between 404 (not found), 410 (gone), 301\u002F302 (redirects), 403 (forbidden), and 5xx (server errors). Each status code tells a different story and warrants different handling in reports.\n3. **Check all resource types** -- Links are not just anchor tags. Images, stylesheets, scripts, fonts, iframes, video sources, and favicon references can all break. A thorough detector covers every resource type embedded in the DOM.\n4. **Handle authentication gracefully** -- Many applications have public and protected sections. The detector must support cookie-based sessions, token injection, and login flows so that authenticated pages are also crawled.\n5. **Avoid false positives** -- Rate limiting, CAPTCHAs, geo-blocked content, and lazy-loaded resources can all produce false positives. Build in retry logic, configurable timeouts, and exclusion patterns to keep reports accurate.\n6. **Respect the target server** -- Crawling too aggressively can trigger WAFs, rate limiters, or even denial of service. Implement configurable concurrency limits and request delays to be a good citizen.\n7. **Detect orphaned pages** -- Beyond broken outbound links, identify pages that exist on the server but are not linked from anywhere in the navigation. These orphaned pages are invisible to users and search engines alike.\n\n## Project Structure\n\nOrganize your dead link detection suite with this structure:\n\n```\ntests\u002F\n  link-checker\u002F\n    crawl-all-links.spec.ts\n    check-images.spec.ts\n    check-external-links.spec.ts\n    check-anchor-links.spec.ts\n    orphaned-pages.spec.ts\n  fixtures\u002F\n    crawler.fixture.ts\n    auth.fixture.ts\n  helpers\u002F\n    link-extractor.ts\n    url-resolver.ts\n    report-generator.ts\n    link-classifier.ts\n  reports\u002F\n    broken-links.json\n    broken-links.html\nplaywright.config.ts\n```\n\n## How It Works: Crawl-Based Link Checking\n\nThe fundamental approach uses Playwright to visit pages, extract all links from the DOM, resolve them to absolute URLs, and then verify each one. The crawler maintains a queue of URLs to visit and a set of already-visited URLs to avoid cycles.\n\n### The Link Extractor\n\nThe link extractor is the core utility that parses a page and returns every resource URL present in the DOM.\n\n```typescript\nimport { Page } from '@playwright\u002Ftest';\n\nexport interface ExtractedLink {\n  url: string;\n  sourceUrl: string;\n  element: string;\n  attribute: string;\n  text: string;\n  line?: number;\n}\n\nexport async function extractAllLinks(page: Page, sourceUrl: string): Promise\u003CExtractedLink[]> {\n  return await page.evaluate((source) => {\n    const links: Array\u003C{\n      url: string;\n      sourceUrl: string;\n      element: string;\n      attribute: string;\n      text: string;\n    }> = [];\n\n    \u002F\u002F Anchor tags\n    document.querySelectorAll('a[href]').forEach((el) => {\n      const anchor = el as HTMLAnchorElement;\n      links.push({\n        url: anchor.href,\n        sourceUrl: source,\n        element: 'a',\n        attribute: 'href',\n        text: anchor.textContent?.trim().substring(0, 100) || '',\n      });\n    });\n\n    \u002F\u002F Images\n    document.querySelectorAll('img[src]').forEach((el) => {\n      const img = el as HTMLImageElement;\n      links.push({\n        url: img.src,\n        sourceUrl: source,\n        element: 'img',\n        attribute: 'src',\n        text: img.alt || '',\n      });\n    });\n\n    \u002F\u002F Stylesheets\n    document.querySelectorAll('link[href]').forEach((el) => {\n      const link = el as HTMLLinkElement;\n      links.push({\n        url: link.href,\n        sourceUrl: source,\n        element: 'link',\n        attribute: 'href',\n        text: link.rel || '',\n      });\n    });\n\n    \u002F\u002F Scripts\n    document.querySelectorAll('script[src]').forEach((el) => {\n      const script = el as HTMLScriptElement;\n      links.push({\n        url: script.src,\n        sourceUrl: source,\n        element: 'script',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Iframes\n    document.querySelectorAll('iframe[src]').forEach((el) => {\n      const iframe = el as HTMLIFrameElement;\n      links.push({\n        url: iframe.src,\n        sourceUrl: source,\n        element: 'iframe',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Video and audio sources\n    document.querySelectorAll('source[src]').forEach((el) => {\n      const source_el = el as HTMLSourceElement;\n      links.push({\n        url: source_el.src,\n        sourceUrl: source,\n        element: 'source',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Background images in inline styles\n    document.querySelectorAll('[style*=\"url(\"]').forEach((el) => {\n      const style = (el as HTMLElement).style.cssText;\n      const urlMatch = style.match(\u002Furl\\([\"']?([^\"')]+)[\"']?\\)\u002F);\n      if (urlMatch) {\n        links.push({\n          url: new URL(urlMatch[1], window.location.href).href,\n          sourceUrl: source,\n          element: el.tagName.toLowerCase(),\n          attribute: 'style',\n          text: '',\n        });\n      }\n    });\n\n    return links;\n  }, sourceUrl);\n}\n```\n\n### URL Resolver and Classifier\n\nNot all extracted URLs are equal. Some are internal, some external. Some are page links, others are resource links. The classifier helps route each URL to the appropriate verification strategy.\n\n```typescript\nexport interface ClassifiedUrl {\n  original: string;\n  resolved: string;\n  isInternal: boolean;\n  isAnchor: boolean;\n  isMailto: boolean;\n  isTel: boolean;\n  isJavascript: boolean;\n  isDataUri: boolean;\n  protocol: string;\n}\n\nexport function classifyUrl(url: string, baseUrl: string): ClassifiedUrl {\n  const base = new URL(baseUrl);\n\n  const isMailto = url.startsWith('mailto:');\n  const isTel = url.startsWith('tel:');\n  const isJavascript = url.startsWith('javascript:');\n  const isDataUri = url.startsWith('data:');\n  const isAnchor = url.startsWith('#');\n\n  let resolved = url;\n  let protocol = '';\n  let isInternal = false;\n\n  if (!isMailto && !isTel && !isJavascript && !isDataUri) {\n    try {\n      const parsed = new URL(url, baseUrl);\n      resolved = parsed.href;\n      protocol = parsed.protocol;\n      isInternal = parsed.hostname === base.hostname;\n    } catch {\n      resolved = url;\n    }\n  }\n\n  return {\n    original: url,\n    resolved,\n    isInternal,\n    isAnchor,\n    isMailto,\n    isTel,\n    isJavascript,\n    isDataUri,\n    protocol,\n  };\n}\n\nexport function shouldCrawl(classified: ClassifiedUrl): boolean {\n  if (classified.isMailto || classified.isTel || classified.isJavascript || classified.isDataUri) {\n    return false;\n  }\n  if (!classified.isInternal) {\n    return false;\n  }\n  const skipExtensions = ['.pdf', '.zip', '.png', '.jpg', '.gif', '.svg', '.css', '.js', '.woff'];\n  if (skipExtensions.some((ext) => classified.resolved.toLowerCase().endsWith(ext))) {\n    return false;\n  }\n  return true;\n}\n```\n\n### The Crawler Fixture\n\nUse a Playwright fixture to encapsulate the crawling logic so that test files remain clean and focused on assertions.\n\n```typescript\nimport { test as base, Page, APIRequestContext } from '@playwright\u002Ftest';\nimport { extractAllLinks, ExtractedLink } from '..\u002Fhelpers\u002Flink-extractor';\nimport { classifyUrl, shouldCrawl, ClassifiedUrl } from '..\u002Fhelpers\u002Furl-resolver';\n\nexport interface LinkCheckResult {\n  url: string;\n  statusCode: number;\n  statusText: string;\n  responseTime: number;\n  sourceUrl: string;\n  element: string;\n  attribute: string;\n  linkText: string;\n  error?: string;\n  redirectChain?: string[];\n}\n\nexport interface CrawlerOptions {\n  maxPages: number;\n  maxConcurrency: number;\n  timeout: number;\n  retries: number;\n  excludePatterns: RegExp[];\n  includeExternal: boolean;\n  delayBetweenRequests: number;\n}\n\nconst defaultOptions: CrawlerOptions = {\n  maxPages: 500,\n  maxConcurrency: 5,\n  timeout: 30000,\n  retries: 2,\n  excludePatterns: [],\n  includeExternal: true,\n  delayBetweenRequests: 100,\n};\n\nexport class LinkCrawler {\n  private visited = new Set\u003Cstring>();\n  private queue: string[] = [];\n  private results: LinkCheckResult[] = [];\n  private allLinks: ExtractedLink[] = [];\n  private options: CrawlerOptions;\n\n  constructor(\n    private page: Page,\n    private request: APIRequestContext,\n    private baseUrl: string,\n    options: Partial\u003CCrawlerOptions> = {}\n  ) {\n    this.options = { ...defaultOptions, ...options };\n  }\n\n  async crawl(startUrl?: string): Promise\u003CLinkCheckResult[]> {\n    const start = startUrl || this.baseUrl;\n    this.queue.push(start);\n\n    while (this.queue.length > 0 && this.visited.size \u003C this.options.maxPages) {\n      const url = this.queue.shift()!;\n      if (this.visited.has(url)) continue;\n      if (this.options.excludePatterns.some((p) => p.test(url))) continue;\n\n      this.visited.add(url);\n\n      try {\n        await this.page.goto(url, {\n          waitUntil: 'networkidle',\n          timeout: this.options.timeout,\n        });\n\n        const links = await extractAllLinks(this.page, url);\n        this.allLinks.push(...links);\n\n        for (const link of links) {\n          const classified = classifyUrl(link.url, this.baseUrl);\n\n          if (shouldCrawl(classified) && !this.visited.has(classified.resolved)) {\n            this.queue.push(classified.resolved);\n          }\n        }\n\n        if (this.options.delayBetweenRequests > 0) {\n          await this.page.waitForTimeout(this.options.delayBetweenRequests);\n        }\n      } catch (error) {\n        this.results.push({\n          url,\n          statusCode: 0,\n          statusText: 'Navigation Error',\n          responseTime: 0,\n          sourceUrl: 'crawler',\n          element: 'page',\n          attribute: 'navigation',\n          linkText: '',\n          error: error instanceof Error ? error.message : String(error),\n        });\n      }\n    }\n\n    await this.verifyAllLinks();\n    return this.results;\n  }\n\n  private async verifyAllLinks(): Promise\u003Cvoid> {\n    const uniqueLinks = new Map\u003Cstring, ExtractedLink>();\n    for (const link of this.allLinks) {\n      const classified = classifyUrl(link.url, this.baseUrl);\n      if (classified.isMailto || classified.isTel || classified.isJavascript || classified.isDataUri) {\n        continue;\n      }\n      if (!this.options.includeExternal && !classified.isInternal) {\n        continue;\n      }\n      if (!uniqueLinks.has(classified.resolved)) {\n        uniqueLinks.set(classified.resolved, link);\n      }\n    }\n\n    const entries = Array.from(uniqueLinks.entries());\n    for (let i = 0; i \u003C entries.length; i += this.options.maxConcurrency) {\n      const batch = entries.slice(i, i + this.options.maxConcurrency);\n      const results = await Promise.allSettled(\n        batch.map(([url, link]) => this.checkLink(url, link))\n      );\n      for (const result of results) {\n        if (result.status === 'fulfilled') {\n          this.results.push(result.value);\n        }\n      }\n    }\n  }\n\n  private async checkLink(url: string, link: ExtractedLink): Promise\u003CLinkCheckResult> {\n    const start = Date.now();\n    let lastError = '';\n\n    for (let attempt = 0; attempt \u003C= this.options.retries; attempt++) {\n      try {\n        const response = await this.request.head(url, {\n          timeout: this.options.timeout,\n          ignoreHTTPSErrors: true,\n        });\n\n        return {\n          url,\n          statusCode: response.status(),\n          statusText: response.statusText(),\n          responseTime: Date.now() - start,\n          sourceUrl: link.sourceUrl,\n          element: link.element,\n          attribute: link.attribute,\n          linkText: link.text,\n        };\n      } catch (error) {\n        lastError = error instanceof Error ? error.message : String(error);\n        if (attempt \u003C this.options.retries) {\n          await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));\n        }\n      }\n    }\n\n    \u002F\u002F Fallback to GET if HEAD fails\n    try {\n      const response = await this.request.get(url, {\n        timeout: this.options.timeout,\n        ignoreHTTPSErrors: true,\n      });\n      return {\n        url,\n        statusCode: response.status(),\n        statusText: response.statusText(),\n        responseTime: Date.now() - start,\n        sourceUrl: link.sourceUrl,\n        element: link.element,\n        attribute: link.attribute,\n        linkText: link.text,\n      };\n    } catch {\n      return {\n        url,\n        statusCode: 0,\n        statusText: 'Request Failed',\n        responseTime: Date.now() - start,\n        sourceUrl: link.sourceUrl,\n        element: link.element,\n        attribute: link.attribute,\n        linkText: link.text,\n        error: lastError,\n      };\n    }\n  }\n\n  getResults(): LinkCheckResult[] {\n    return this.results;\n  }\n\n  getBrokenLinks(): LinkCheckResult[] {\n    return this.results.filter(\n      (r) => r.statusCode === 0 || r.statusCode >= 400\n    );\n  }\n\n  getRedirects(): LinkCheckResult[] {\n    return this.results.filter(\n      (r) => r.statusCode >= 300 && r.statusCode \u003C 400\n    );\n  }\n}\n\nexport const test = base.extend\u003C{ crawler: LinkCrawler }>({\n  crawler: async ({ page, request }, use) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    const crawler = new LinkCrawler(page, request, baseUrl);\n    await use(crawler);\n  },\n});\n\nexport { expect } from '@playwright\u002Ftest';\n```\n\n### Writing the Tests\n\nWith the fixture and helpers in place, the actual test files are concise and declarative.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcrawl-all-links.spec.ts\nimport { test, expect } from '..\u002Ffixtures\u002Fcrawler.fixture';\n\ntest.describe('Dead Link Detection - Full Site Crawl', () => {\n  test('should have zero broken internal links', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const broken = results.filter(\n      (r) => (r.statusCode === 0 || r.statusCode >= 400) && r.url.includes('localhost')\n    );\n\n    if (broken.length > 0) {\n      const report = broken.map(\n        (b) =>\n          `  [${b.statusCode}] ${b.url}\\n    Found on: ${b.sourceUrl}\\n    Element: \u003C${b.element} ${b.attribute}=\"${b.url}\">\\n    Text: \"${b.linkText}\"\\n    Error: ${b.error || 'HTTP ' + b.statusCode}`\n      );\n      console.error(`Found ${broken.length} broken internal links:\\n${report.join('\\n')}`);\n    }\n\n    expect(broken).toHaveLength(0);\n  });\n\n  test('should have no server errors (5xx) on any page', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const serverErrors = results.filter(\n      (r) => r.statusCode >= 500 && r.statusCode \u003C 600\n    );\n\n    expect(serverErrors).toHaveLength(0);\n  });\n\n  test('should not have excessive redirects', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const redirects = crawler.getRedirects();\n\n    \u002F\u002F Redirects are not errors but excessive redirects indicate problems\n    const redirectRatio = redirects.length \u002F results.length;\n    expect(redirectRatio).toBeLessThan(0.3); \u002F\u002F Less than 30% of links redirect\n  });\n});\n```\n\n## Handling Anchor Links and Hash Fragments\n\nAnchor links (hash fragments) require special treatment because they reference elements within a page rather than separate resources. The server returns 200 for the page, but the target element might not exist.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-anchor-links.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\nimport { extractAllLinks } from '..\u002Fhelpers\u002Flink-extractor';\n\ntest.describe('Anchor Link Validation', () => {\n  test('all hash links should reference existing elements', async ({ page }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    const pagesToCheck = ['\u002F', '\u002Fdocs', '\u002Fabout', '\u002Ffaq'];\n    const brokenAnchors: Array\u003C{ page: string; hash: string }> = [];\n\n    for (const path of pagesToCheck) {\n      await page.goto(`${baseUrl}${path}`, { waitUntil: 'networkidle' });\n\n      const anchorLinks = await page.evaluate(() => {\n        const links: string[] = [];\n        document.querySelectorAll('a[href*=\"#\"]').forEach((el) => {\n          const href = (el as HTMLAnchorElement).getAttribute('href');\n          if (href && href.includes('#')) {\n            const hash = href.split('#')[1];\n            if (hash) links.push(hash);\n          }\n        });\n        return links;\n      });\n\n      for (const hash of anchorLinks) {\n        const exists = await page.evaluate((id) => {\n          return !!(document.getElementById(id) || document.querySelector(`[name=\"${id}\"]`));\n        }, hash);\n\n        if (!exists) {\n          brokenAnchors.push({ page: path, hash });\n        }\n      }\n    }\n\n    if (brokenAnchors.length > 0) {\n      console.error(\n        'Broken anchor links:\\n' +\n          brokenAnchors.map((a) => `  ${a.page}#${a.hash}`).join('\\n')\n      );\n    }\n\n    expect(brokenAnchors).toHaveLength(0);\n  });\n});\n```\n\n## Checking Images and Media Resources\n\nBroken images degrade user experience significantly. This test specifically validates all image sources, including srcset attributes for responsive images, open graph images, and favicon references.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-images.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Image and Media Resource Validation', () => {\n  test('all images should load successfully', async ({ page, request }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await page.goto(baseUrl, { waitUntil: 'networkidle' });\n\n    const imageUrls = await page.evaluate(() => {\n      const urls: string[] = [];\n\n      \u002F\u002F Standard img src\n      document.querySelectorAll('img[src]').forEach((el) => {\n        urls.push((el as HTMLImageElement).src);\n      });\n\n      \u002F\u002F srcset for responsive images\n      document.querySelectorAll('img[srcset], source[srcset]').forEach((el) => {\n        const srcset = el.getAttribute('srcset') || '';\n        srcset.split(',').forEach((entry) => {\n          const url = entry.trim().split(\u002F\\s+\u002F)[0];\n          if (url) {\n            try {\n              urls.push(new URL(url, window.location.href).href);\n            } catch {\n              \u002F\u002F skip invalid URLs\n            }\n          }\n        });\n      });\n\n      \u002F\u002F Open Graph and meta images\n      document\n        .querySelectorAll('meta[property=\"og:image\"], meta[name=\"twitter:image\"]')\n        .forEach((el) => {\n          const content = el.getAttribute('content');\n          if (content) {\n            try {\n              urls.push(new URL(content, window.location.href).href);\n            } catch {\n              \u002F\u002F skip\n            }\n          }\n        });\n\n      \u002F\u002F Favicon\n      document.querySelectorAll('link[rel*=\"icon\"]').forEach((el) => {\n        const href = (el as HTMLLinkElement).href;\n        if (href) urls.push(href);\n      });\n\n      return [...new Set(urls)];\n    });\n\n    const brokenImages: Array\u003C{ url: string; status: number }> = [];\n\n    for (const url of imageUrls) {\n      try {\n        const response = await request.head(url, { timeout: 15000 });\n        if (response.status() >= 400) {\n          brokenImages.push({ url, status: response.status() });\n        }\n      } catch {\n        brokenImages.push({ url, status: 0 });\n      }\n    }\n\n    if (brokenImages.length > 0) {\n      console.error(\n        `Found ${brokenImages.length} broken images:\\n` +\n          brokenImages.map((b) => `  [${b.status}] ${b.url}`).join('\\n')\n      );\n    }\n\n    expect(brokenImages).toHaveLength(0);\n  });\n});\n```\n\n## Report Generation\n\nGenerating structured reports is essential for CI integration and historical tracking. Below is a report generator that produces both JSON and HTML output.\n\n```typescript\n\u002F\u002F tests\u002Fhelpers\u002Freport-generator.ts\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { LinkCheckResult } from '..\u002Ffixtures\u002Fcrawler.fixture';\n\nexport interface LinkReport {\n  timestamp: string;\n  baseUrl: string;\n  totalLinksChecked: number;\n  brokenLinks: number;\n  redirects: number;\n  healthyLinks: number;\n  results: LinkCheckResult[];\n  summary: {\n    byStatusCode: Record\u003Cnumber, number>;\n    byElement: Record\u003Cstring, number>;\n    bySourcePage: Record\u003Cstring, number>;\n    averageResponseTime: number;\n    slowestLinks: LinkCheckResult[];\n  };\n}\n\nexport function generateReport(\n  results: LinkCheckResult[],\n  baseUrl: string\n): LinkReport {\n  const byStatusCode: Record\u003Cnumber, number> = {};\n  const byElement: Record\u003Cstring, number> = {};\n  const bySourcePage: Record\u003Cstring, number> = {};\n  let totalResponseTime = 0;\n\n  for (const r of results) {\n    byStatusCode[r.statusCode] = (byStatusCode[r.statusCode] || 0) + 1;\n    byElement[r.element] = (byElement[r.element] || 0) + 1;\n\n    const brokenOnly = r.statusCode === 0 || r.statusCode >= 400;\n    if (brokenOnly) {\n      bySourcePage[r.sourceUrl] = (bySourcePage[r.sourceUrl] || 0) + 1;\n    }\n    totalResponseTime += r.responseTime;\n  }\n\n  const broken = results.filter((r) => r.statusCode === 0 || r.statusCode >= 400);\n  const redirects = results.filter((r) => r.statusCode >= 300 && r.statusCode \u003C 400);\n  const slowest = [...results].sort((a, b) => b.responseTime - a.responseTime).slice(0, 10);\n\n  return {\n    timestamp: new Date().toISOString(),\n    baseUrl,\n    totalLinksChecked: results.length,\n    brokenLinks: broken.length,\n    redirects: redirects.length,\n    healthyLinks: results.length - broken.length - redirects.length,\n    results,\n    summary: {\n      byStatusCode,\n      byElement,\n      bySourcePage,\n      averageResponseTime: results.length > 0 ? totalResponseTime \u002F results.length : 0,\n      slowestLinks: slowest,\n    },\n  };\n}\n\nexport function saveReport(report: LinkReport, outputDir: string): void {\n  fs.mkdirSync(outputDir, { recursive: true });\n\n  \u002F\u002F JSON report\n  const jsonPath = path.join(outputDir, 'broken-links.json');\n  fs.writeFileSync(jsonPath, JSON.stringify(report, null, 2));\n\n  \u002F\u002F HTML report\n  const htmlPath = path.join(outputDir, 'broken-links.html');\n  const html = buildHtmlReport(report);\n  fs.writeFileSync(htmlPath, html);\n\n  console.log(`Reports saved to:\\n  JSON: ${jsonPath}\\n  HTML: ${htmlPath}`);\n}\n\nfunction buildHtmlReport(report: LinkReport): string {\n  const brokenRows = report.results\n    .filter((r) => r.statusCode === 0 || r.statusCode >= 400)\n    .map(\n      (r) => `\n      \u003Ctr>\n        \u003Ctd>${r.statusCode}\u003C\u002Ftd>\n        \u003Ctd>\u003Ca href=\"${r.url}\">${r.url}\u003C\u002Fa>\u003C\u002Ftd>\n        \u003Ctd>${r.sourceUrl}\u003C\u002Ftd>\n        \u003Ctd>&lt;${r.element}&gt;\u003C\u002Ftd>\n        \u003Ctd>${r.linkText}\u003C\u002Ftd>\n        \u003Ctd>${r.error || ''}\u003C\u002Ftd>\n      \u003C\u002Ftr>`\n    )\n    .join('');\n\n  return `\u003C!DOCTYPE html>\n\u003Chtml>\n\u003Chead>\n  \u003Ctitle>Dead Link Report - ${report.timestamp}\u003C\u002Ftitle>\n  \u003Cstyle>\n    body { font-family: system-ui, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }\n    table { border-collapse: collapse; width: 100%; margin-top: 20px; }\n    th, td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 14px; }\n    th { background: #f5f5f5; }\n    .summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }\n    .stat { background: #f9f9f9; padding: 16px; border-radius: 8px; text-align: center; }\n    .stat h3 { margin: 0; font-size: 32px; }\n    .stat p { margin: 4px 0 0; color: #666; }\n    .broken { color: #dc2626; }\n    .healthy { color: #16a34a; }\n  \u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Ch1>Dead Link Report\u003C\u002Fh1>\n  \u003Cp>Generated: ${report.timestamp} | Base URL: ${report.baseUrl}\u003C\u002Fp>\n  \u003Cdiv class=\"summary\">\n    \u003Cdiv class=\"stat\">\u003Ch3>${report.totalLinksChecked}\u003C\u002Fh3>\u003Cp>Total Links\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3 class=\"healthy\">${report.healthyLinks}\u003C\u002Fh3>\u003Cp>Healthy\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3 class=\"broken\">${report.brokenLinks}\u003C\u002Fh3>\u003Cp>Broken\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3>${report.redirects}\u003C\u002Fh3>\u003Cp>Redirects\u003C\u002Fp>\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n  \u003Ch2>Broken Links\u003C\u002Fh2>\n  \u003Ctable>\n    \u003Cthead>\u003Ctr>\u003Cth>Status\u003C\u002Fth>\u003Cth>URL\u003C\u002Fth>\u003Cth>Found On\u003C\u002Fth>\u003Cth>Element\u003C\u002Fth>\u003Cth>Text\u003C\u002Fth>\u003Cth>Error\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\n    \u003Ctbody>${brokenRows || '\u003Ctr>\u003Ctd colspan=\"6\">No broken links found\u003C\u002Ftd>\u003C\u002Ftr>'}\u003C\u002Ftbody>\n  \u003C\u002Ftable>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>`;\n}\n```\n\n## Handling Auth-Protected Pages\n\nMany web applications have sections behind authentication. The crawler must log in before crawling those areas.\n\n```typescript\n\u002F\u002F tests\u002Ffixtures\u002Fauth.fixture.ts\nimport { test as base, Page } from '@playwright\u002Ftest';\n\nexport async function loginAndGetCookies(page: Page, baseUrl: string): Promise\u003Cvoid> {\n  await page.goto(`${baseUrl}\u002Flogin`);\n  await page.getByLabel('Email').fill(process.env.TEST_USER_EMAIL || 'test@example.com');\n  await page.getByLabel('Password').fill(process.env.TEST_USER_PASSWORD || 'testpassword');\n  await page.getByRole('button', { name: 'Sign in' }).click();\n  await page.waitForURL('**\u002Fdashboard**');\n}\n\nexport const test = base.extend\u003C{ authenticatedPage: Page }>({\n  authenticatedPage: async ({ page }, use) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await loginAndGetCookies(page, baseUrl);\n    await use(page);\n  },\n});\n```\n\n## Checking External Links\n\nExternal links require a different strategy: you cannot crawl them (robots.txt, rate limits), but you must verify they resolve. Use HEAD requests with appropriate timeouts and user-agent strings.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-external-links.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\nimport { extractAllLinks } from '..\u002Fhelpers\u002Flink-extractor';\nimport { classifyUrl } from '..\u002Fhelpers\u002Furl-resolver';\n\ntest.describe('External Link Validation', () => {\n  test('all external links should be reachable', async ({ page, request }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await page.goto(baseUrl, { waitUntil: 'networkidle' });\n\n    const allLinks = await extractAllLinks(page, baseUrl);\n    const externalLinks = allLinks\n      .map((l) => ({ ...l, classified: classifyUrl(l.url, baseUrl) }))\n      .filter((l) => !l.classified.isInternal && !l.classified.isMailto && !l.classified.isTel);\n\n    const uniqueExternal = [...new Map(externalLinks.map((l) => [l.classified.resolved, l])).values()];\n\n    const broken: Array\u003C{ url: string; status: number; source: string }> = [];\n\n    for (const link of uniqueExternal) {\n      try {\n        const response = await request.head(link.classified.resolved, {\n          timeout: 20000,\n          headers: {\n            'User-Agent': 'QASkills-LinkChecker\u002F1.0 (automated testing)',\n          },\n        });\n\n        \u002F\u002F Some servers block HEAD requests; retry with GET\n        if (response.status() === 405 || response.status() === 403) {\n          const getResponse = await request.get(link.classified.resolved, {\n            timeout: 20000,\n          });\n          if (getResponse.status() >= 400) {\n            broken.push({\n              url: link.classified.resolved,\n              status: getResponse.status(),\n              source: link.sourceUrl,\n            });\n          }\n        } else if (response.status() >= 400) {\n          broken.push({\n            url: link.classified.resolved,\n            status: response.status(),\n            source: link.sourceUrl,\n          });\n        }\n      } catch {\n        broken.push({\n          url: link.classified.resolved,\n          status: 0,\n          source: link.sourceUrl,\n        });\n      }\n    }\n\n    expect(broken).toHaveLength(0);\n  });\n});\n```\n\n## Configuration\n\nConfigure the dead link detector through the Playwright config and environment variables.\n\n```typescript\n\u002F\u002F playwright.config.ts\nimport { defineConfig } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Flink-checker',\n  timeout: 120_000,\n  retries: 1,\n  workers: 1, \u002F\u002F Crawling is sequential by nature\n  reporter: [\n    ['html', { outputFolder: 'reports\u002Fhtml' }],\n    ['json', { outputFile: 'reports\u002Fresults.json' }],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    ignoreHTTPSErrors: true,\n    extraHTTPHeaders: {\n      'User-Agent': 'QASkills-LinkChecker\u002F1.0',\n    },\n  },\n  projects: [\n    {\n      name: 'internal-links',\n      testMatch: \u002Fcrawl-all-links|check-anchor-links\u002F,\n    },\n    {\n      name: 'external-links',\n      testMatch: \u002Fcheck-external-links\u002F,\n    },\n    {\n      name: 'media-resources',\n      testMatch: \u002Fcheck-images\u002F,\n    },\n  ],\n});\n```\n\n### Environment Variables\n\n| Variable | Description | Default |\n|---|---|---|\n| `BASE_URL` | Target application URL | `http:\u002F\u002Flocalhost:3000` |\n| `MAX_PAGES` | Maximum pages to crawl | `500` |\n| `MAX_CONCURRENCY` | Parallel link checks | `5` |\n| `LINK_TIMEOUT` | Request timeout in ms | `30000` |\n| `INCLUDE_EXTERNAL` | Check external links | `true` |\n| `TEST_USER_EMAIL` | Auth email for protected pages | -- |\n| `TEST_USER_PASSWORD` | Auth password for protected pages | -- |\n\n## CI Integration\n\nAdd the dead link detector to your CI pipeline to catch broken links before they reach production.\n\n```yaml\n# .github\u002Fworkflows\u002Flink-check.yml\nname: Dead Link Check\non:\n  schedule:\n    - cron: '0 6 * * 1'  # Every Monday at 6 AM\n  push:\n    branches: [main]\n  workflow_dispatch:\n\njobs:\n  check-links:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n      - run: npm ci\n      - run: npx playwright install --with-deps chromium\n      - name: Start application\n        run: npm run start &\n        env:\n          NODE_ENV: production\n      - name: Wait for server\n        run: npx wait-on http:\u002F\u002Flocalhost:3000 --timeout 60000\n      - name: Run link checker\n        run: npx playwright test --project=internal-links\n        env:\n          BASE_URL: http:\u002F\u002Flocalhost:3000\n      - uses: actions\u002Fupload-artifact@v4\n        if: always()\n        with:\n          name: link-check-report\n          path: reports\u002F\n```\n\n## Best Practices\n\n1. **Run link checks on a schedule, not just on push** -- Links break when external sites change, certificates expire, or CDNs go down. A weekly scheduled run catches drift.\n2. **Separate internal and external link checks** -- Internal links should never break and warrant a hard failure. External links are outside your control and might benefit from a warning threshold instead.\n3. **Use HEAD requests before GET** -- HEAD requests are faster and use less bandwidth. Only fall back to GET when the server returns 405 Method Not Allowed.\n4. **Implement exponential backoff on retries** -- Transient network failures happen. Retry with increasing delays (1s, 2s, 4s) before marking a link as broken.\n5. **Maintain an exclusion list** -- Some URLs will always fail in CI (localhost links in documentation, example.com references, intentionally broken test URLs). Keep a maintained exclusion list rather than ignoring failures.\n6. **Track broken link trends over time** -- Store historical reports and track whether the broken link count is increasing or decreasing. A spike indicates a deployment issue.\n7. **Verify redirects resolve to valid destinations** -- A 301 redirect is not inherently a problem, but a redirect chain that ends in a 404 is. Follow the chain to its terminus.\n8. **Set realistic timeouts for external links** -- External sites in different regions may respond slowly. Use 20-30 second timeouts for external links, but 5-10 seconds for internal ones.\n9. **Check links after deployment, not just in staging** -- Production CDN configuration, DNS, and TLS certificates differ from staging. Run a post-deploy link check.\n10. **Include link context in reports** -- A broken link URL alone is not actionable. Always include the source page, the element type, and the link text so developers can find and fix it quickly.\n11. **Handle single-page applications correctly** -- SPAs load content dynamically. Wait for `networkidle` or specific selectors before extracting links, and handle client-side routing.\n12. **Test with and without authentication** -- Public and authenticated views often have different navigation. Crawl both to get full coverage.\n\n## Anti-Patterns to Avoid\n\n1. **Checking only the homepage** -- Most broken links are buried deep in the site. Checking only the homepage misses 90% of issues. Always crawl recursively.\n2. **Treating all non-200 responses as broken** -- 301 redirects, 204 No Content, and 206 Partial Content are all valid responses. Only 4xx and 5xx codes (and connection failures) indicate problems.\n3. **Crawling without a visited-URL set** -- Without cycle detection, the crawler will loop infinitely on sites with circular navigation links. Always maintain a set of visited URLs.\n4. **Ignoring rate limits on external sites** -- Hammering an external site with hundreds of concurrent HEAD requests will get your CI server IP blocked. Limit concurrency and add delays.\n5. **Hardcoding URLs instead of crawling** -- Maintaining a static list of URLs to check becomes stale immediately. Let the crawler discover links dynamically from the DOM.\n6. **Not handling JavaScript-rendered content** -- Many modern sites render links via JavaScript. Using a simple HTTP client without a browser engine will miss dynamically generated links. Always use a real browser (Playwright) for extraction.\n7. **Failing the entire CI build on external link breakage** -- External link failures are outside your control. Warn on external breakage, fail on internal breakage.\n\n## Debugging Tips\n\n- **Use Playwright trace viewer for failed crawls** -- Enable tracing with `trace: 'on-first-retry'` in your config to get a step-by-step visual replay of what happened before a navigation failure.\n- **Log the full redirect chain** -- When a link fails after redirects, log each hop in the chain. The problem might be an intermediate redirect, not the final destination.\n- **Check for lazy-loaded content** -- If links are missing from extraction, they may be below the fold and not yet rendered. Scroll the page before extracting links, or use `page.evaluate` to check the full DOM including off-screen elements.\n- **Verify DNS resolution** -- A common cause of false positives is DNS resolution failure in CI environments. Use `nslookup` or `dig` to verify that the target domain resolves from your CI runner.\n- **Inspect response headers on 403 errors** -- A 403 might indicate a WAF blocking your user-agent or IP, not an actually forbidden resource. Check for `X-Robots-Tag`, `Retry-After`, or challenge headers.\n- **Test with `--headed` mode locally** -- Running Playwright in headed mode lets you visually confirm that pages load correctly and see any popup dialogs, cookie banners, or interstitials that might block crawling.\n- **Check for meta refresh redirects** -- Some pages use `\u003Cmeta http-equiv=\"refresh\">` instead of HTTP 3xx redirects. These will not appear in the response status code but will cause the page to navigate away. Parse meta tags explicitly.\n- **Monitor response times alongside status codes** -- A link that returns 200 but takes 30 seconds to respond is effectively broken for users. Flag links with response times above a threshold as slow links in your report.","# Dead Link Detector Skill\n\nYou are an expert QA automation engineer specializing in broken link detection and web crawling strategies. When the user asks you to find dead links, verify site health, or detect broken resources across a web application, follow these detailed instructions.\n\n## Core Principles\n\n1. **Crawl exhaustively, report precisely** -- Every link on a site must be discovered and verified. A dead link detector is only as good as its coverage. Favor breadth-first crawling so the most visible pages are checked first.\n2. **Respect HTTP semantics** -- Differentiate between 404 (not found), 410 (gone), 301\u002F302 (redirects), 403 (forbidden), and 5xx (server errors). Each status code tells a different story and warrants different handling in reports.\n3. **Check all resource types** -- Links are not just anchor tags. Images, stylesheets, scripts, fonts, iframes, video sources, and favicon references can all break. A thorough detector covers every resource type embedded in the DOM.\n4. **Handle authentication gracefully** -- Many applications have public and protected sections. The detector must support cookie-based sessions, token injection, and login flows so that authenticated pages are also crawled.\n5. **Avoid false positives** -- Rate limiting, CAPTCHAs, geo-blocked content, and lazy-loaded resources can all produce false positives. Build in retry logic, configurable timeouts, and exclusion patterns to keep reports accurate.\n6. **Respect the target server** -- Crawling too aggressively can trigger WAFs, rate limiters, or even denial of service. Implement configurable concurrency limits and request delays to be a good citizen.\n7. **Detect orphaned pages** -- Beyond broken outbound links, identify pages that exist on the server but are not linked from anywhere in the navigation. These orphaned pages are invisible to users and search engines alike.\n\n## Project Structure\n\nOrganize your dead link detection suite with this structure:\n\n```\ntests\u002F\n  link-checker\u002F\n    crawl-all-links.spec.ts\n    check-images.spec.ts\n    check-external-links.spec.ts\n    check-anchor-links.spec.ts\n    orphaned-pages.spec.ts\n  fixtures\u002F\n    crawler.fixture.ts\n    auth.fixture.ts\n  helpers\u002F\n    link-extractor.ts\n    url-resolver.ts\n    report-generator.ts\n    link-classifier.ts\n  reports\u002F\n    broken-links.json\n    broken-links.html\nplaywright.config.ts\n```\n\n## How It Works: Crawl-Based Link Checking\n\nThe fundamental approach uses Playwright to visit pages, extract all links from the DOM, resolve them to absolute URLs, and then verify each one. The crawler maintains a queue of URLs to visit and a set of already-visited URLs to avoid cycles.\n\n### The Link Extractor\n\nThe link extractor is the core utility that parses a page and returns every resource URL present in the DOM.\n\n```typescript\nimport { Page } from '@playwright\u002Ftest';\n\nexport interface ExtractedLink {\n  url: string;\n  sourceUrl: string;\n  element: string;\n  attribute: string;\n  text: string;\n  line?: number;\n}\n\nexport async function extractAllLinks(page: Page, sourceUrl: string): Promise\u003CExtractedLink[]> {\n  return await page.evaluate((source) => {\n    const links: Array\u003C{\n      url: string;\n      sourceUrl: string;\n      element: string;\n      attribute: string;\n      text: string;\n    }> = [];\n\n    \u002F\u002F Anchor tags\n    document.querySelectorAll('a[href]').forEach((el) => {\n      const anchor = el as HTMLAnchorElement;\n      links.push({\n        url: anchor.href,\n        sourceUrl: source,\n        element: 'a',\n        attribute: 'href',\n        text: anchor.textContent?.trim().substring(0, 100) || '',\n      });\n    });\n\n    \u002F\u002F Images\n    document.querySelectorAll('img[src]').forEach((el) => {\n      const img = el as HTMLImageElement;\n      links.push({\n        url: img.src,\n        sourceUrl: source,\n        element: 'img',\n        attribute: 'src',\n        text: img.alt || '',\n      });\n    });\n\n    \u002F\u002F Stylesheets\n    document.querySelectorAll('link[href]').forEach((el) => {\n      const link = el as HTMLLinkElement;\n      links.push({\n        url: link.href,\n        sourceUrl: source,\n        element: 'link',\n        attribute: 'href',\n        text: link.rel || '',\n      });\n    });\n\n    \u002F\u002F Scripts\n    document.querySelectorAll('script[src]').forEach((el) => {\n      const script = el as HTMLScriptElement;\n      links.push({\n        url: script.src,\n        sourceUrl: source,\n        element: 'script',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Iframes\n    document.querySelectorAll('iframe[src]').forEach((el) => {\n      const iframe = el as HTMLIFrameElement;\n      links.push({\n        url: iframe.src,\n        sourceUrl: source,\n        element: 'iframe',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Video and audio sources\n    document.querySelectorAll('source[src]').forEach((el) => {\n      const source_el = el as HTMLSourceElement;\n      links.push({\n        url: source_el.src,\n        sourceUrl: source,\n        element: 'source',\n        attribute: 'src',\n        text: '',\n      });\n    });\n\n    \u002F\u002F Background images in inline styles\n    document.querySelectorAll('[style*=\"url(\"]').forEach((el) => {\n      const style = (el as HTMLElement).style.cssText;\n      const urlMatch = style.match(\u002Furl\\([\"']?([^\"')]+)[\"']?\\)\u002F);\n      if (urlMatch) {\n        links.push({\n          url: new URL(urlMatch[1], window.location.href).href,\n          sourceUrl: source,\n          element: el.tagName.toLowerCase(),\n          attribute: 'style',\n          text: '',\n        });\n      }\n    });\n\n    return links;\n  }, sourceUrl);\n}\n```\n\n### URL Resolver and Classifier\n\nNot all extracted URLs are equal. Some are internal, some external. Some are page links, others are resource links. The classifier helps route each URL to the appropriate verification strategy.\n\n```typescript\nexport interface ClassifiedUrl {\n  original: string;\n  resolved: string;\n  isInternal: boolean;\n  isAnchor: boolean;\n  isMailto: boolean;\n  isTel: boolean;\n  isJavascript: boolean;\n  isDataUri: boolean;\n  protocol: string;\n}\n\nexport function classifyUrl(url: string, baseUrl: string): ClassifiedUrl {\n  const base = new URL(baseUrl);\n\n  const isMailto = url.startsWith('mailto:');\n  const isTel = url.startsWith('tel:');\n  const isJavascript = url.startsWith('javascript:');\n  const isDataUri = url.startsWith('data:');\n  const isAnchor = url.startsWith('#');\n\n  let resolved = url;\n  let protocol = '';\n  let isInternal = false;\n\n  if (!isMailto && !isTel && !isJavascript && !isDataUri) {\n    try {\n      const parsed = new URL(url, baseUrl);\n      resolved = parsed.href;\n      protocol = parsed.protocol;\n      isInternal = parsed.hostname === base.hostname;\n    } catch {\n      resolved = url;\n    }\n  }\n\n  return {\n    original: url,\n    resolved,\n    isInternal,\n    isAnchor,\n    isMailto,\n    isTel,\n    isJavascript,\n    isDataUri,\n    protocol,\n  };\n}\n\nexport function shouldCrawl(classified: ClassifiedUrl): boolean {\n  if (classified.isMailto || classified.isTel || classified.isJavascript || classified.isDataUri) {\n    return false;\n  }\n  if (!classified.isInternal) {\n    return false;\n  }\n  const skipExtensions = ['.pdf', '.zip', '.png', '.jpg', '.gif', '.svg', '.css', '.js', '.woff'];\n  if (skipExtensions.some((ext) => classified.resolved.toLowerCase().endsWith(ext))) {\n    return false;\n  }\n  return true;\n}\n```\n\n### The Crawler Fixture\n\nUse a Playwright fixture to encapsulate the crawling logic so that test files remain clean and focused on assertions.\n\n```typescript\nimport { test as base, Page, APIRequestContext } from '@playwright\u002Ftest';\nimport { extractAllLinks, ExtractedLink } from '..\u002Fhelpers\u002Flink-extractor';\nimport { classifyUrl, shouldCrawl, ClassifiedUrl } from '..\u002Fhelpers\u002Furl-resolver';\n\nexport interface LinkCheckResult {\n  url: string;\n  statusCode: number;\n  statusText: string;\n  responseTime: number;\n  sourceUrl: string;\n  element: string;\n  attribute: string;\n  linkText: string;\n  error?: string;\n  redirectChain?: string[];\n}\n\nexport interface CrawlerOptions {\n  maxPages: number;\n  maxConcurrency: number;\n  timeout: number;\n  retries: number;\n  excludePatterns: RegExp[];\n  includeExternal: boolean;\n  delayBetweenRequests: number;\n}\n\nconst defaultOptions: CrawlerOptions = {\n  maxPages: 500,\n  maxConcurrency: 5,\n  timeout: 30000,\n  retries: 2,\n  excludePatterns: [],\n  includeExternal: true,\n  delayBetweenRequests: 100,\n};\n\nexport class LinkCrawler {\n  private visited = new Set\u003Cstring>();\n  private queue: string[] = [];\n  private results: LinkCheckResult[] = [];\n  private allLinks: ExtractedLink[] = [];\n  private options: CrawlerOptions;\n\n  constructor(\n    private page: Page,\n    private request: APIRequestContext,\n    private baseUrl: string,\n    options: Partial\u003CCrawlerOptions> = {}\n  ) {\n    this.options = { ...defaultOptions, ...options };\n  }\n\n  async crawl(startUrl?: string): Promise\u003CLinkCheckResult[]> {\n    const start = startUrl || this.baseUrl;\n    this.queue.push(start);\n\n    while (this.queue.length > 0 && this.visited.size \u003C this.options.maxPages) {\n      const url = this.queue.shift()!;\n      if (this.visited.has(url)) continue;\n      if (this.options.excludePatterns.some((p) => p.test(url))) continue;\n\n      this.visited.add(url);\n\n      try {\n        await this.page.goto(url, {\n          waitUntil: 'networkidle',\n          timeout: this.options.timeout,\n        });\n\n        const links = await extractAllLinks(this.page, url);\n        this.allLinks.push(...links);\n\n        for (const link of links) {\n          const classified = classifyUrl(link.url, this.baseUrl);\n\n          if (shouldCrawl(classified) && !this.visited.has(classified.resolved)) {\n            this.queue.push(classified.resolved);\n          }\n        }\n\n        if (this.options.delayBetweenRequests > 0) {\n          await this.page.waitForTimeout(this.options.delayBetweenRequests);\n        }\n      } catch (error) {\n        this.results.push({\n          url,\n          statusCode: 0,\n          statusText: 'Navigation Error',\n          responseTime: 0,\n          sourceUrl: 'crawler',\n          element: 'page',\n          attribute: 'navigation',\n          linkText: '',\n          error: error instanceof Error ? error.message : String(error),\n        });\n      }\n    }\n\n    await this.verifyAllLinks();\n    return this.results;\n  }\n\n  private async verifyAllLinks(): Promise\u003Cvoid> {\n    const uniqueLinks = new Map\u003Cstring, ExtractedLink>();\n    for (const link of this.allLinks) {\n      const classified = classifyUrl(link.url, this.baseUrl);\n      if (classified.isMailto || classified.isTel || classified.isJavascript || classified.isDataUri) {\n        continue;\n      }\n      if (!this.options.includeExternal && !classified.isInternal) {\n        continue;\n      }\n      if (!uniqueLinks.has(classified.resolved)) {\n        uniqueLinks.set(classified.resolved, link);\n      }\n    }\n\n    const entries = Array.from(uniqueLinks.entries());\n    for (let i = 0; i \u003C entries.length; i += this.options.maxConcurrency) {\n      const batch = entries.slice(i, i + this.options.maxConcurrency);\n      const results = await Promise.allSettled(\n        batch.map(([url, link]) => this.checkLink(url, link))\n      );\n      for (const result of results) {\n        if (result.status === 'fulfilled') {\n          this.results.push(result.value);\n        }\n      }\n    }\n  }\n\n  private async checkLink(url: string, link: ExtractedLink): Promise\u003CLinkCheckResult> {\n    const start = Date.now();\n    let lastError = '';\n\n    for (let attempt = 0; attempt \u003C= this.options.retries; attempt++) {\n      try {\n        const response = await this.request.head(url, {\n          timeout: this.options.timeout,\n          ignoreHTTPSErrors: true,\n        });\n\n        return {\n          url,\n          statusCode: response.status(),\n          statusText: response.statusText(),\n          responseTime: Date.now() - start,\n          sourceUrl: link.sourceUrl,\n          element: link.element,\n          attribute: link.attribute,\n          linkText: link.text,\n        };\n      } catch (error) {\n        lastError = error instanceof Error ? error.message : String(error);\n        if (attempt \u003C this.options.retries) {\n          await new Promise((r) => setTimeout(r, 1000 * (attempt + 1)));\n        }\n      }\n    }\n\n    \u002F\u002F Fallback to GET if HEAD fails\n    try {\n      const response = await this.request.get(url, {\n        timeout: this.options.timeout,\n        ignoreHTTPSErrors: true,\n      });\n      return {\n        url,\n        statusCode: response.status(),\n        statusText: response.statusText(),\n        responseTime: Date.now() - start,\n        sourceUrl: link.sourceUrl,\n        element: link.element,\n        attribute: link.attribute,\n        linkText: link.text,\n      };\n    } catch {\n      return {\n        url,\n        statusCode: 0,\n        statusText: 'Request Failed',\n        responseTime: Date.now() - start,\n        sourceUrl: link.sourceUrl,\n        element: link.element,\n        attribute: link.attribute,\n        linkText: link.text,\n        error: lastError,\n      };\n    }\n  }\n\n  getResults(): LinkCheckResult[] {\n    return this.results;\n  }\n\n  getBrokenLinks(): LinkCheckResult[] {\n    return this.results.filter(\n      (r) => r.statusCode === 0 || r.statusCode >= 400\n    );\n  }\n\n  getRedirects(): LinkCheckResult[] {\n    return this.results.filter(\n      (r) => r.statusCode >= 300 && r.statusCode \u003C 400\n    );\n  }\n}\n\nexport const test = base.extend\u003C{ crawler: LinkCrawler }>({\n  crawler: async ({ page, request }, use) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    const crawler = new LinkCrawler(page, request, baseUrl);\n    await use(crawler);\n  },\n});\n\nexport { expect } from '@playwright\u002Ftest';\n```\n\n### Writing the Tests\n\nWith the fixture and helpers in place, the actual test files are concise and declarative.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcrawl-all-links.spec.ts\nimport { test, expect } from '..\u002Ffixtures\u002Fcrawler.fixture';\n\ntest.describe('Dead Link Detection - Full Site Crawl', () => {\n  test('should have zero broken internal links', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const broken = results.filter(\n      (r) => (r.statusCode === 0 || r.statusCode >= 400) && r.url.includes('localhost')\n    );\n\n    if (broken.length > 0) {\n      const report = broken.map(\n        (b) =>\n          `  [${b.statusCode}] ${b.url}\\n    Found on: ${b.sourceUrl}\\n    Element: \u003C${b.element} ${b.attribute}=\"${b.url}\">\\n    Text: \"${b.linkText}\"\\n    Error: ${b.error || 'HTTP ' + b.statusCode}`\n      );\n      console.error(`Found ${broken.length} broken internal links:\\n${report.join('\\n')}`);\n    }\n\n    expect(broken).toHaveLength(0);\n  });\n\n  test('should have no server errors (5xx) on any page', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const serverErrors = results.filter(\n      (r) => r.statusCode >= 500 && r.statusCode \u003C 600\n    );\n\n    expect(serverErrors).toHaveLength(0);\n  });\n\n  test('should not have excessive redirects', async ({ crawler }) => {\n    const results = await crawler.crawl();\n    const redirects = crawler.getRedirects();\n\n    \u002F\u002F Redirects are not errors but excessive redirects indicate problems\n    const redirectRatio = redirects.length \u002F results.length;\n    expect(redirectRatio).toBeLessThan(0.3); \u002F\u002F Less than 30% of links redirect\n  });\n});\n```\n\n## Handling Anchor Links and Hash Fragments\n\nAnchor links (hash fragments) require special treatment because they reference elements within a page rather than separate resources. The server returns 200 for the page, but the target element might not exist.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-anchor-links.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\nimport { extractAllLinks } from '..\u002Fhelpers\u002Flink-extractor';\n\ntest.describe('Anchor Link Validation', () => {\n  test('all hash links should reference existing elements', async ({ page }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    const pagesToCheck = ['\u002F', '\u002Fdocs', '\u002Fabout', '\u002Ffaq'];\n    const brokenAnchors: Array\u003C{ page: string; hash: string }> = [];\n\n    for (const path of pagesToCheck) {\n      await page.goto(`${baseUrl}${path}`, { waitUntil: 'networkidle' });\n\n      const anchorLinks = await page.evaluate(() => {\n        const links: string[] = [];\n        document.querySelectorAll('a[href*=\"#\"]').forEach((el) => {\n          const href = (el as HTMLAnchorElement).getAttribute('href');\n          if (href && href.includes('#')) {\n            const hash = href.split('#')[1];\n            if (hash) links.push(hash);\n          }\n        });\n        return links;\n      });\n\n      for (const hash of anchorLinks) {\n        const exists = await page.evaluate((id) => {\n          return !!(document.getElementById(id) || document.querySelector(`[name=\"${id}\"]`));\n        }, hash);\n\n        if (!exists) {\n          brokenAnchors.push({ page: path, hash });\n        }\n      }\n    }\n\n    if (brokenAnchors.length > 0) {\n      console.error(\n        'Broken anchor links:\\n' +\n          brokenAnchors.map((a) => `  ${a.page}#${a.hash}`).join('\\n')\n      );\n    }\n\n    expect(brokenAnchors).toHaveLength(0);\n  });\n});\n```\n\n## Checking Images and Media Resources\n\nBroken images degrade user experience significantly. This test specifically validates all image sources, including srcset attributes for responsive images, open graph images, and favicon references.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-images.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Image and Media Resource Validation', () => {\n  test('all images should load successfully', async ({ page, request }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await page.goto(baseUrl, { waitUntil: 'networkidle' });\n\n    const imageUrls = await page.evaluate(() => {\n      const urls: string[] = [];\n\n      \u002F\u002F Standard img src\n      document.querySelectorAll('img[src]').forEach((el) => {\n        urls.push((el as HTMLImageElement).src);\n      });\n\n      \u002F\u002F srcset for responsive images\n      document.querySelectorAll('img[srcset], source[srcset]').forEach((el) => {\n        const srcset = el.getAttribute('srcset') || '';\n        srcset.split(',').forEach((entry) => {\n          const url = entry.trim().split(\u002F\\s+\u002F)[0];\n          if (url) {\n            try {\n              urls.push(new URL(url, window.location.href).href);\n            } catch {\n              \u002F\u002F skip invalid URLs\n            }\n          }\n        });\n      });\n\n      \u002F\u002F Open Graph and meta images\n      document\n        .querySelectorAll('meta[property=\"og:image\"], meta[name=\"twitter:image\"]')\n        .forEach((el) => {\n          const content = el.getAttribute('content');\n          if (content) {\n            try {\n              urls.push(new URL(content, window.location.href).href);\n            } catch {\n              \u002F\u002F skip\n            }\n          }\n        });\n\n      \u002F\u002F Favicon\n      document.querySelectorAll('link[rel*=\"icon\"]').forEach((el) => {\n        const href = (el as HTMLLinkElement).href;\n        if (href) urls.push(href);\n      });\n\n      return [...new Set(urls)];\n    });\n\n    const brokenImages: Array\u003C{ url: string; status: number }> = [];\n\n    for (const url of imageUrls) {\n      try {\n        const response = await request.head(url, { timeout: 15000 });\n        if (response.status() >= 400) {\n          brokenImages.push({ url, status: response.status() });\n        }\n      } catch {\n        brokenImages.push({ url, status: 0 });\n      }\n    }\n\n    if (brokenImages.length > 0) {\n      console.error(\n        `Found ${brokenImages.length} broken images:\\n` +\n          brokenImages.map((b) => `  [${b.status}] ${b.url}`).join('\\n')\n      );\n    }\n\n    expect(brokenImages).toHaveLength(0);\n  });\n});\n```\n\n## Report Generation\n\nGenerating structured reports is essential for CI integration and historical tracking. Below is a report generator that produces both JSON and HTML output.\n\n```typescript\n\u002F\u002F tests\u002Fhelpers\u002Freport-generator.ts\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { LinkCheckResult } from '..\u002Ffixtures\u002Fcrawler.fixture';\n\nexport interface LinkReport {\n  timestamp: string;\n  baseUrl: string;\n  totalLinksChecked: number;\n  brokenLinks: number;\n  redirects: number;\n  healthyLinks: number;\n  results: LinkCheckResult[];\n  summary: {\n    byStatusCode: Record\u003Cnumber, number>;\n    byElement: Record\u003Cstring, number>;\n    bySourcePage: Record\u003Cstring, number>;\n    averageResponseTime: number;\n    slowestLinks: LinkCheckResult[];\n  };\n}\n\nexport function generateReport(\n  results: LinkCheckResult[],\n  baseUrl: string\n): LinkReport {\n  const byStatusCode: Record\u003Cnumber, number> = {};\n  const byElement: Record\u003Cstring, number> = {};\n  const bySourcePage: Record\u003Cstring, number> = {};\n  let totalResponseTime = 0;\n\n  for (const r of results) {\n    byStatusCode[r.statusCode] = (byStatusCode[r.statusCode] || 0) + 1;\n    byElement[r.element] = (byElement[r.element] || 0) + 1;\n\n    const brokenOnly = r.statusCode === 0 || r.statusCode >= 400;\n    if (brokenOnly) {\n      bySourcePage[r.sourceUrl] = (bySourcePage[r.sourceUrl] || 0) + 1;\n    }\n    totalResponseTime += r.responseTime;\n  }\n\n  const broken = results.filter((r) => r.statusCode === 0 || r.statusCode >= 400);\n  const redirects = results.filter((r) => r.statusCode >= 300 && r.statusCode \u003C 400);\n  const slowest = [...results].sort((a, b) => b.responseTime - a.responseTime).slice(0, 10);\n\n  return {\n    timestamp: new Date().toISOString(),\n    baseUrl,\n    totalLinksChecked: results.length,\n    brokenLinks: broken.length,\n    redirects: redirects.length,\n    healthyLinks: results.length - broken.length - redirects.length,\n    results,\n    summary: {\n      byStatusCode,\n      byElement,\n      bySourcePage,\n      averageResponseTime: results.length > 0 ? totalResponseTime \u002F results.length : 0,\n      slowestLinks: slowest,\n    },\n  };\n}\n\nexport function saveReport(report: LinkReport, outputDir: string): void {\n  fs.mkdirSync(outputDir, { recursive: true });\n\n  \u002F\u002F JSON report\n  const jsonPath = path.join(outputDir, 'broken-links.json');\n  fs.writeFileSync(jsonPath, JSON.stringify(report, null, 2));\n\n  \u002F\u002F HTML report\n  const htmlPath = path.join(outputDir, 'broken-links.html');\n  const html = buildHtmlReport(report);\n  fs.writeFileSync(htmlPath, html);\n\n  console.log(`Reports saved to:\\n  JSON: ${jsonPath}\\n  HTML: ${htmlPath}`);\n}\n\nfunction buildHtmlReport(report: LinkReport): string {\n  const brokenRows = report.results\n    .filter((r) => r.statusCode === 0 || r.statusCode >= 400)\n    .map(\n      (r) => `\n      \u003Ctr>\n        \u003Ctd>${r.statusCode}\u003C\u002Ftd>\n        \u003Ctd>\u003Ca href=\"${r.url}\">${r.url}\u003C\u002Fa>\u003C\u002Ftd>\n        \u003Ctd>${r.sourceUrl}\u003C\u002Ftd>\n        \u003Ctd>&lt;${r.element}&gt;\u003C\u002Ftd>\n        \u003Ctd>${r.linkText}\u003C\u002Ftd>\n        \u003Ctd>${r.error || ''}\u003C\u002Ftd>\n      \u003C\u002Ftr>`\n    )\n    .join('');\n\n  return `\u003C!DOCTYPE html>\n\u003Chtml>\n\u003Chead>\n  \u003Ctitle>Dead Link Report - ${report.timestamp}\u003C\u002Ftitle>\n  \u003Cstyle>\n    body { font-family: system-ui, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }\n    table { border-collapse: collapse; width: 100%; margin-top: 20px; }\n    th, td { border: 1px solid #ddd; padding: 8px; text-align: left; font-size: 14px; }\n    th { background: #f5f5f5; }\n    .summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }\n    .stat { background: #f9f9f9; padding: 16px; border-radius: 8px; text-align: center; }\n    .stat h3 { margin: 0; font-size: 32px; }\n    .stat p { margin: 4px 0 0; color: #666; }\n    .broken { color: #dc2626; }\n    .healthy { color: #16a34a; }\n  \u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Ch1>Dead Link Report\u003C\u002Fh1>\n  \u003Cp>Generated: ${report.timestamp} | Base URL: ${report.baseUrl}\u003C\u002Fp>\n  \u003Cdiv class=\"summary\">\n    \u003Cdiv class=\"stat\">\u003Ch3>${report.totalLinksChecked}\u003C\u002Fh3>\u003Cp>Total Links\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3 class=\"healthy\">${report.healthyLinks}\u003C\u002Fh3>\u003Cp>Healthy\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3 class=\"broken\">${report.brokenLinks}\u003C\u002Fh3>\u003Cp>Broken\u003C\u002Fp>\u003C\u002Fdiv>\n    \u003Cdiv class=\"stat\">\u003Ch3>${report.redirects}\u003C\u002Fh3>\u003Cp>Redirects\u003C\u002Fp>\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n  \u003Ch2>Broken Links\u003C\u002Fh2>\n  \u003Ctable>\n    \u003Cthead>\u003Ctr>\u003Cth>Status\u003C\u002Fth>\u003Cth>URL\u003C\u002Fth>\u003Cth>Found On\u003C\u002Fth>\u003Cth>Element\u003C\u002Fth>\u003Cth>Text\u003C\u002Fth>\u003Cth>Error\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\n    \u003Ctbody>${brokenRows || '\u003Ctr>\u003Ctd colspan=\"6\">No broken links found\u003C\u002Ftd>\u003C\u002Ftr>'}\u003C\u002Ftbody>\n  \u003C\u002Ftable>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>`;\n}\n```\n\n## Handling Auth-Protected Pages\n\nMany web applications have sections behind authentication. The crawler must log in before crawling those areas.\n\n```typescript\n\u002F\u002F tests\u002Ffixtures\u002Fauth.fixture.ts\nimport { test as base, Page } from '@playwright\u002Ftest';\n\nexport async function loginAndGetCookies(page: Page, baseUrl: string): Promise\u003Cvoid> {\n  await page.goto(`${baseUrl}\u002Flogin`);\n  await page.getByLabel('Email').fill(process.env.TEST_USER_EMAIL || 'test@example.com');\n  await page.getByLabel('Password').fill(process.env.TEST_USER_PASSWORD || 'testpassword');\n  await page.getByRole('button', { name: 'Sign in' }).click();\n  await page.waitForURL('**\u002Fdashboard**');\n}\n\nexport const test = base.extend\u003C{ authenticatedPage: Page }>({\n  authenticatedPage: async ({ page }, use) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await loginAndGetCookies(page, baseUrl);\n    await use(page);\n  },\n});\n```\n\n## Checking External Links\n\nExternal links require a different strategy: you cannot crawl them (robots.txt, rate limits), but you must verify they resolve. Use HEAD requests with appropriate timeouts and user-agent strings.\n\n```typescript\n\u002F\u002F tests\u002Flink-checker\u002Fcheck-external-links.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\nimport { extractAllLinks } from '..\u002Fhelpers\u002Flink-extractor';\nimport { classifyUrl } from '..\u002Fhelpers\u002Furl-resolver';\n\ntest.describe('External Link Validation', () => {\n  test('all external links should be reachable', async ({ page, request }) => {\n    const baseUrl = process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000';\n    await page.goto(baseUrl, { waitUntil: 'networkidle' });\n\n    const allLinks = await extractAllLinks(page, baseUrl);\n    const externalLinks = allLinks\n      .map((l) => ({ ...l, classified: classifyUrl(l.url, baseUrl) }))\n      .filter((l) => !l.classified.isInternal && !l.classified.isMailto && !l.classified.isTel);\n\n    const uniqueExternal = [...new Map(externalLinks.map((l) => [l.classified.resolved, l])).values()];\n\n    const broken: Array\u003C{ url: string; status: number; source: string }> = [];\n\n    for (const link of uniqueExternal) {\n      try {\n        const response = await request.head(link.classified.resolved, {\n          timeout: 20000,\n          headers: {\n            'User-Agent': 'QASkills-LinkChecker\u002F1.0 (automated testing)',\n          },\n        });\n\n        \u002F\u002F Some servers block HEAD requests; retry with GET\n        if (response.status() === 405 || response.status() === 403) {\n          const getResponse = await request.get(link.classified.resolved, {\n            timeout: 20000,\n          });\n          if (getResponse.status() >= 400) {\n            broken.push({\n              url: link.classified.resolved,\n              status: getResponse.status(),\n              source: link.sourceUrl,\n            });\n          }\n        } else if (response.status() >= 400) {\n          broken.push({\n            url: link.classified.resolved,\n            status: response.status(),\n            source: link.sourceUrl,\n          });\n        }\n      } catch {\n        broken.push({\n          url: link.classified.resolved,\n          status: 0,\n          source: link.sourceUrl,\n        });\n      }\n    }\n\n    expect(broken).toHaveLength(0);\n  });\n});\n```\n\n## Configuration\n\nConfigure the dead link detector through the Playwright config and environment variables.\n\n```typescript\n\u002F\u002F playwright.config.ts\nimport { defineConfig } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Flink-checker',\n  timeout: 120_000,\n  retries: 1,\n  workers: 1, \u002F\u002F Crawling is sequential by nature\n  reporter: [\n    ['html', { outputFolder: 'reports\u002Fhtml' }],\n    ['json', { outputFile: 'reports\u002Fresults.json' }],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    ignoreHTTPSErrors: true,\n    extraHTTPHeaders: {\n      'User-Agent': 'QASkills-LinkChecker\u002F1.0',\n    },\n  },\n  projects: [\n    {\n      name: 'internal-links',\n      testMatch: \u002Fcrawl-all-links|check-anchor-links\u002F,\n    },\n    {\n      name: 'external-links',\n      testMatch: \u002Fcheck-external-links\u002F,\n    },\n    {\n      name: 'media-resources',\n      testMatch: \u002Fcheck-images\u002F,\n    },\n  ],\n});\n```\n\n### Environment Variables\n\n| Variable | Description | Default |\n|---|---|---|\n| `BASE_URL` | Target application URL | `http:\u002F\u002Flocalhost:3000` |\n| `MAX_PAGES` | Maximum pages to crawl | `500` |\n| `MAX_CONCURRENCY` | Parallel link checks | `5` |\n| `LINK_TIMEOUT` | Request timeout in ms | `30000` |\n| `INCLUDE_EXTERNAL` | Check external links | `true` |\n| `TEST_USER_EMAIL` | Auth email for protected pages | -- |\n| `TEST_USER_PASSWORD` | Auth password for protected pages | -- |\n\n## CI Integration\n\nAdd the dead link detector to your CI pipeline to catch broken links before they reach production.\n\n```yaml\n# .github\u002Fworkflows\u002Flink-check.yml\nname: Dead Link Check\non:\n  schedule:\n    - cron: '0 6 * * 1'  # Every Monday at 6 AM\n  push:\n    branches: [main]\n  workflow_dispatch:\n\njobs:\n  check-links:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: actions\u002Fsetup-node@v4\n        with:\n          node-version: 20\n      - run: npm ci\n      - run: npx playwright install --with-deps chromium\n      - name: Start application\n        run: npm run start &\n        env:\n          NODE_ENV: production\n      - name: Wait for server\n        run: npx wait-on http:\u002F\u002Flocalhost:3000 --timeout 60000\n      - name: Run link checker\n        run: npx playwright test --project=internal-links\n        env:\n          BASE_URL: http:\u002F\u002Flocalhost:3000\n      - uses: actions\u002Fupload-artifact@v4\n        if: always()\n        with:\n          name: link-check-report\n          path: reports\u002F\n```\n\n## Best Practices\n\n1. **Run link checks on a schedule, not just on push** -- Links break when external sites change, certificates expire, or CDNs go down. A weekly scheduled run catches drift.\n2. **Separate internal and external link checks** -- Internal links should never break and warrant a hard failure. External links are outside your control and might benefit from a warning threshold instead.\n3. **Use HEAD requests before GET** -- HEAD requests are faster and use less bandwidth. Only fall back to GET when the server returns 405 Method Not Allowed.\n4. **Implement exponential backoff on retries** -- Transient network failures happen. Retry with increasing delays (1s, 2s, 4s) before marking a link as broken.\n5. **Maintain an exclusion list** -- Some URLs will always fail in CI (localhost links in documentation, example.com references, intentionally broken test URLs). Keep a maintained exclusion list rather than ignoring failures.\n6. **Track broken link trends over time** -- Store historical reports and track whether the broken link count is increasing or decreasing. A spike indicates a deployment issue.\n7. **Verify redirects resolve to valid destinations** -- A 301 redirect is not inherently a problem, but a redirect chain that ends in a 404 is. Follow the chain to its terminus.\n8. **Set realistic timeouts for external links** -- External sites in different regions may respond slowly. Use 20-30 second timeouts for external links, but 5-10 seconds for internal ones.\n9. **Check links after deployment, not just in staging** -- Production CDN configuration, DNS, and TLS certificates differ from staging. Run a post-deploy link check.\n10. **Include link context in reports** -- A broken link URL alone is not actionable. Always include the source page, the element type, and the link text so developers can find and fix it quickly.\n11. **Handle single-page applications correctly** -- SPAs load content dynamically. Wait for `networkidle` or specific selectors before extracting links, and handle client-side routing.\n12. **Test with and without authentication** -- Public and authenticated views often have different navigation. Crawl both to get full coverage.\n\n## Anti-Patterns to Avoid\n\n1. **Checking only the homepage** -- Most broken links are buried deep in the site. Checking only the homepage misses 90% of issues. Always crawl recursively.\n2. **Treating all non-200 responses as broken** -- 301 redirects, 204 No Content, and 206 Partial Content are all valid responses. Only 4xx and 5xx codes (and connection failures) indicate problems.\n3. **Crawling without a visited-URL set** -- Without cycle detection, the crawler will loop infinitely on sites with circular navigation links. Always maintain a set of visited URLs.\n4. **Ignoring rate limits on external sites** -- Hammering an external site with hundreds of concurrent HEAD requests will get your CI server IP blocked. Limit concurrency and add delays.\n5. **Hardcoding URLs instead of crawling** -- Maintaining a static list of URLs to check becomes stale immediately. Let the crawler discover links dynamically from the DOM.\n6. **Not handling JavaScript-rendered content** -- Many modern sites render links via JavaScript. Using a simple HTTP client without a browser engine will miss dynamically generated links. Always use a real browser (Playwright) for extraction.\n7. **Failing the entire CI build on external link breakage** -- External link failures are outside your control. Warn on external breakage, fail on internal breakage.\n\n## Debugging Tips\n\n- **Use Playwright trace viewer for failed crawls** -- Enable tracing with `trace: 'on-first-retry'` in your config to get a step-by-step visual replay of what happened before a navigation failure.\n- **Log the full redirect chain** -- When a link fails after redirects, log each hop in the chain. The problem might be an intermediate redirect, not the final destination.\n- **Check for lazy-loaded content** -- If links are missing from extraction, they may be below the fold and not yet rendered. Scroll the page before extracting links, or use `page.evaluate` to check the full DOM including off-screen elements.\n- **Verify DNS resolution** -- A common cause of false positives is DNS resolution failure in CI environments. Use `nslookup` or `dig` to verify that the target domain resolves from your CI runner.\n- **Inspect response headers on 403 errors** -- A 403 might indicate a WAF blocking your user-agent or IP, not an actually forbidden resource. Check for `X-Robots-Tag`, `Retry-After`, or challenge headers.\n- **Test with `--headed` mode locally** -- Running Playwright in headed mode lets you visually confirm that pages load correctly and see any popup dialogs, cookie banners, or interstitials that might block crawling.\n- **Check for meta refresh redirects** -- Some pages use `\u003Cmeta http-equiv=\"refresh\">` instead of HTTP 3xx redirects. These will not appear in the response status code but will cause the page to navigate away. Parse meta tags explicitly.\n- **Monitor response times alongside status codes** -- A link that returns 200 but takes 30 seconds to respond is effectively broken for users. Flag links with response times above a threshold as slow links in your report.",{"name":5,"tags":24,"agents":32,"author":45,"domains":46,"license":15,"version":48,"languages":49,"frameworks":52,"description":7,"testingTypes":54},[25,26,27,28,29,30,31],"dead-links","broken-links","link-checker","web-crawling","http-status","404-detection","site-health",[33,34,35,36,37,38,39,40,41,42,43,44],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp","Pramod",[47],"web","1.0.0",[50,51],"typescript","javascript",[53],"playwright",[55,56],"e2e","code-quality","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Fdead-link-detector","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":66,"prompt":76,"zipAvailable":77},[67,70,73],{"tool":68,"command":69},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Dead Link Detector\"",{"tool":71,"command":72},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Dead Link Detector\"",{"tool":74,"command":75},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Dead Link Detector\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fdead-link-detector\u002FSKILL.md",true,[],[80,88,95,102,109,116],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":84,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]