This prompt is designed for doc site maintainers and platform engineers who need to audit internal and external links across documentation pages at scale. The core job-to-be-done is transforming raw HTTP validation results into a categorized, actionable remediation report. The ideal user is a technical writer or DevOps engineer integrating this into a CI/CD pipeline where link extraction and HTTP status checks are already handled by application code (e.g., a crawler or a script using wget or curl). The model's role is not to crawl the web, but to analyze a pre-compiled list of URLs and their statuses, identify patterns like redirect chains or broken anchors, and suggest specific replacement URLs or fixes.
Prompt
Broken Link Detection Prompt for Documentation Sites

When to Use This Prompt
Understand the ideal workflow, user, and preconditions for the broken link detection prompt before integrating it into your documentation pipeline.
You should use this prompt when you have a structured input of URLs with their HTTP status codes and any error messages. The prompt expects a specific [INPUT] format, typically a JSON array of objects containing the source page, the target link, the HTTP status, and any redirect chain or anchor validation result. It is most effective in a gated deployment where a human reviews the model's suggested replacements before they are committed to the documentation repository. This is not a real-time link checker for a live site; it is a batch analysis tool for pre-publication audits or scheduled integrity checks.
Do not use this prompt for crawling or discovering links. It will fail if asked to fetch URLs or if provided with unvalidated lists. It is also unsuitable for auditing authenticated endpoints unless the input data already includes the results of authenticated requests, as the model cannot perform login flows. Avoid using this prompt for pages with dynamic, JavaScript-rendered content unless the input data comes from a browser-based crawler that has already resolved the final DOM state. For high-risk documentation like security protocols or legal terms, always require human approval on any suggested link changes before publication.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the Broken Link Detection Prompt fits your documentation pipeline before you invest in the harness.
Good Fit: Static Documentation Sites
Use when: you maintain a Hugo, Docusaurus, MkDocs, or similar static site with predictable HTML structure. Guardrail: The prompt performs best when pages are pre-rendered and links are standard <a href> tags. Pair with a sitemap crawler for full coverage.
Bad Fit: JavaScript-Heavy SPAs
Avoid when: your docs are a single-page application that renders links client-side after hydration. Guardrail: The prompt cannot execute JavaScript. Use a headless browser pre-rendering step before link extraction, or switch to a browser-based agent for SPA crawling.
Required Inputs
What you need: a list of page URLs to audit, the rendered HTML for each page, and a link extraction strategy (CSS selector or regex). Guardrail: Without consistent HTML input, the prompt will hallucinate links. Always pass extracted anchor elements with their href attributes and surrounding context, not raw page screenshots.
Operational Risk: Authenticated Endpoints
What to watch: internal links pointing to authenticated dashboards, admin panels, or SSO-gated pages will return 401/403 and appear broken. Guardrail: Pre-filter URLs against a known allowlist of public paths. Flag auth-gated links as 'unverifiable' rather than 'broken' to avoid false-positive noise in the report.
Operational Risk: Rate Limiting and IP Blocking
What to watch: aggressive link checking can trigger rate limits or IP bans on external sites, causing false 429 or 403 errors. Guardrail: Implement per-domain request throttling, respect robots.txt crawl-delay directives, and use exponential backoff. The prompt should classify 429 responses as 'rate-limited' rather than 'broken'.
Not a Replacement for Continuous Monitoring
What to watch: this prompt is a point-in-time audit, not a live link monitor. Links break between audits. Guardrail: Schedule the prompt as a recurring CI job. Pair it with a lightweight cron-based link checker for high-traffic pages between full audits. Use the prompt's categorized report to prioritize fixes, not as your only detection mechanism.
Copy-Ready Prompt Template
A reusable prompt with square-bracket placeholders for auditing documentation pages and producing a categorized broken link report.
This template is the core instruction set for a broken link detection workflow. It expects a list of documentation page URLs and a set of constraints that define what constitutes a broken link in your environment. The prompt instructs the model to produce a structured report categorizing each link by status code, redirect chain depth, anchor validity, and suggested replacements. Use this template as the foundation for a tool-calling agent or a batch processing pipeline that validates links against live HTTP responses.
textYou are a documentation link auditor. Your task is to analyze a list of URLs from a documentation site and produce a categorized broken link report. ## INPUT - Page URLs to audit: [PAGE_URLS] - Optional: previously crawled link graph or sitemap: [LINK_GRAPH] ## CONSTRAINTS - Follow redirects up to [MAX_REDIRECT_DEPTH] hops. Report any chain exceeding this depth as broken. - Treat HTTP status codes [BROKEN_STATUS_CODES] as broken links. - Ignore links matching these patterns (e.g., authenticated endpoints, dynamic routes): [IGNORE_PATTERNS] - Check anchor targets (`#fragment`) against the destination page's heading IDs. Report anchors with no matching ID as broken. - For external links, do not scrape the full page; rely on the HTTP status code and, if available, a HEAD request. - If a link returns a status code in [WARNING_STATUS_CODES] (e.g., 301, 308), flag it as a warning with the redirect target. ## OUTPUT_SCHEMA Return a JSON object with this exact structure: { "audit_summary": { "total_links_checked": <int>, "broken_links": <int>, "warnings": <int>, "skipped_links": <int> }, "broken_links": [ { "source_page": "<URL of the page containing the link>", "link_text": "<visible link text>", "target_url": "<full href target>", "status_code": <int or null>, "error": "<connection error, timeout, or DNS failure description if no status code>", "redirect_chain": ["<url1>", "<url2>"], "anchor_valid": <true | false | null>, "category": "<404 | redirect_loop | anchor_missing | connection_error | timeout | blocked_by_robots | other>", "suggested_replacement": "<proposed fix or null>" } ], "warnings": [ { "source_page": "<URL>", "target_url": "<URL>", "status_code": <int>, "redirect_target": "<final destination URL>", "category": "<permanent_redirect | temporary_redirect | soft_404 | other>" } ], "skipped_links": [ { "source_page": "<URL>", "target_url": "<URL>", "reason": "<matched ignore pattern or authentication requirement>" } ] } ## INSTRUCTIONS 1. For each source page in [PAGE_URLS], extract every `<a href="...">` link. 2. Filter out links matching [IGNORE_PATTERNS] and record them in `skipped_links`. 3. For each remaining link, perform an HTTP HEAD or GET request (respecting `Retry-After` headers). 4. Follow redirects up to [MAX_REDIRECT_DEPTH]. Record the full chain. 5. Classify the result into `broken_links` or `warnings` based on [BROKEN_STATUS_CODES] and [WARNING_STATUS_CODES]. 6. For same-domain links with anchors, verify the anchor exists on the destination page. 7. Populate `suggested_replacement` only when a likely fix is obvious (e.g., a 404 where the correct page is known from the link graph). 8. If the link target is blocked by robots.txt, categorize it as `blocked_by_robots` and do not attempt to fetch. ## RISK_LEVEL [RISK_LEVEL] If RISK_LEVEL is "high", do not attempt to fetch any link that requires authentication, contains session tokens, or points to internal admin endpoints. Log these as skipped with the reason "high_risk_skip".
Adapting the template: Replace each square-bracket placeholder with concrete values before sending the prompt to a model or wiring it into an application. [PAGE_URLS] should be a JSON array of fully qualified URLs. [BROKEN_STATUS_CODES] is typically [404, 410] but may include [403, 500] if your team treats those as actionable failures. [IGNORE_PATTERNS] is critical for avoiding false positives from authenticated endpoints—use regex patterns like ["/api/admin/*", "*/login?*"]. [RISK_LEVEL] gates whether the system should attempt to resolve links that might trigger side effects. For documentation sites behind authentication, set this to "high" and combine the prompt with a pre-fetch step that strips session cookies.
Next steps: After adapting the placeholders, pair this prompt with a deterministic link extractor and an HTTP client that performs the actual requests. The model should receive the extracted links and HTTP response metadata, not raw HTML pages. This separation keeps the prompt focused on classification and reporting while the application layer handles network I/O, retries, and rate limiting. Before deploying, run the prompt against a known set of pages with intentionally broken links and verify that the output JSON matches the expected schema and correctly categorizes each failure mode.
Prompt Variables
Required inputs for the broken link detection prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to verify the input is well-formed before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[PAGE_URLS] | List of documentation page URLs to scan for broken links | Must be a valid JSON array of absolute URLs. Each URL must return 200 on HEAD request before scanning. Empty array should abort. | |
[LINK_SELECTOR] | CSS selector or XPath to identify link elements on each page | "a[href]:not([href^='#']):not([rel='nofollow'])" | Must be a valid CSS selector string. Test against a sample page to confirm it captures all intended links and excludes navigation chrome. Null allowed if scanning all anchor tags. |
[EXCLUDE_PATTERNS] | URL patterns to skip during link checking | ["localhost", "staging.internal", "test.example.com"] | Must be a JSON array of strings. Each pattern is treated as a substring match against the href. Empty array is valid. Patterns should not contain regex metacharacters unless [USE_REGEX] is true. |
[MAX_REDIRECT_DEPTH] | Maximum redirect chain length before flagging as broken | 5 | Must be a positive integer between 1 and 10. Values above 10 should be rejected. Used to detect redirect loops and excessive chains. Default 5 if not specified. |
[REQUEST_TIMEOUT_MS] | Timeout per link check in milliseconds | 8000 | Must be a positive integer between 1000 and 30000. Values below 1000 cause false positives on slow endpoints. Values above 30000 risk prompt timeout. Default 10000. |
[AUTHENTICATED_ENDPOINTS] | List of URL patterns that require authentication and should be flagged as unverifiable rather than broken | ["dashboard.example.com", "admin.example.com"] | Must be a JSON array of strings. Links matching these patterns will be reported with status 'unverifiable' instead of 'broken'. Empty array is valid. Prevents false positives from 401/403 responses. |
[OUTPUT_CATEGORIES] | Taxonomy of link status categories to use in the report | ["valid", "broken", "redirected", "unverifiable", "timeout", "anchor_missing"] | Must be a JSON array containing at least one of the predefined category strings. Invalid categories should be stripped with a warning. Default includes all six standard categories. |
[ANCHOR_CHECK_ENABLED] | Whether to validate fragment identifiers on same-page and cross-page anchor links | Must be boolean true or false. When true, the prompt will check that anchor targets exist on the destination page. Adds latency per link. Set false for initial broad scans. |
Implementation Harness Notes
How to wire the broken link detection prompt into a documentation pipeline with validation, retries, and human review.
The broken link detection prompt is designed to be called inside an automated documentation pipeline, not as a one-off chat interaction. You will typically invoke it once per documentation page or once per batch of pages, passing the page's rendered HTML, extracted anchor list, and a list of known-good internal routes as [PAGE_HTML], [ANCHOR_LIST], and [KNOWN_ROUTES] respectively. The model returns a structured JSON report that your harness must validate before merging into your link audit database or ticketing system.
Wire the prompt into a script or microservice that first extracts all <a> tags and their href attributes from each documentation page. For internal links, resolve them against [KNOWN_ROUTES] and your site's routing table before sending them to the model; the model should not guess whether /docs/v2/api is valid. For external links, perform a lightweight HEAD request to capture the HTTP status code, redirect chain length, and final destination before passing the result to the prompt as [EXTERNAL_STATUS_MAP]. This pre-processing reduces hallucination risk and lets the model focus on classification, anchor validity, and replacement suggestions rather than raw HTTP mechanics. After the model returns its JSON report, validate every url field against the original input set to catch fabricated links, and reject any report where confidence falls below your configured threshold (start with 0.7). Log every rejected report for later review.
For high-traffic documentation sites, batch pages into groups of 10-20 and run the prompt concurrently with a rate limiter. Use a model that supports structured output (JSON mode or function calling) to enforce the output schema defined in the prompt template. Implement a retry layer: if the model returns malformed JSON or missing required fields, retry once with the same input and an explicit repair instruction appended. If the second attempt fails, flag the page for human review and continue processing the rest of the batch. Store all results in a link audit table with columns for page_url, link_url, status, category, suggested_replacement, confidence, model_version, and reviewed_by. This schema lets you track false positive rates over time and feed corrections back into your evaluation dataset. Avoid wiring this prompt directly into a CI/CD block step on every commit; instead, run it as a scheduled audit (daily or weekly) or on-demand before a major release, since external link rot is slow-moving and full-site scans are expensive.
Expected Output Contract
Fields, format, and validation rules for the broken link detection report. Use this contract to parse, validate, and store the model output before surfacing results to users or downstream systems.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
report_id | string (UUID v4) | Must parse as valid UUID v4. Reject if missing or malformed. | |
generated_at | string (ISO 8601 UTC) | Must parse as valid UTC datetime. Reject if in the future or older than 24 hours from generation time. | |
source_page_url | string (valid URL) | Must parse as absolute HTTPS URL. Reject if scheme is not https or host is empty. | |
total_links_scanned | integer | Must be non-negative integer. Must equal sum of all categorized link counts. Reject if negative or mismatched. | |
broken_links | array of objects | Must be present even if empty. Each object must conform to the broken_link_item schema. Reject if null. | |
broken_link_item.url | string (valid URL) | Must parse as absolute URL. Reject if empty, relative, or contains userinfo component. | |
broken_link_item.status_code | integer or null | If present, must be valid HTTP status code (100-599). Null allowed only when error_type is 'network_error' or 'timeout'. Reject if negative or outside range. | |
broken_link_item.error_type | enum string | Must be one of: '4xx_client_error', '5xx_server_error', 'redirect_loop', 'timeout', 'dns_failure', 'connection_refused', 'ssl_error', 'invalid_url', 'anchor_not_found'. Reject if not in enum. | |
broken_link_item.redirect_chain | array of strings (URLs) | If present, must contain at least 2 URLs. Last URL must match final destination. Reject if chain is circular or empty. | |
broken_link_item.anchor_valid | boolean or null | Required only when error_type is 'anchor_not_found'. Must be false in that case. Null allowed for non-anchor errors. Reject if true when error_type is 'anchor_not_found'. | |
broken_link_item.suggested_replacement | string (URL) or null | If present, must parse as valid absolute URL. Null allowed when no replacement is known. Reject if relative or malformed. | |
broken_link_item.link_text | string | Must be non-empty string representing the anchor text or element text of the broken link. Reject if empty or whitespace-only. | |
broken_link_item.confidence | number (float 0.0-1.0) | Must be between 0.0 and 1.0 inclusive. Values below 0.7 should trigger human review. Reject if outside range. | |
summary | object | Must contain total_broken, by_category, and by_status_code sub-objects. Reject if any sub-object is missing. | |
summary.total_broken | integer | Must equal length of broken_links array. Reject if mismatched. | |
summary.by_category | object | Keys must be valid error_type values. Values must be non-negative integers summing to total_broken. Reject if sum mismatch. | |
summary.by_status_code | object | Keys must be valid HTTP status codes (as strings). Values must be non-negative integers. Reject if keys are not valid codes. | |
false_positives_flagged | array of objects | If present, each object must contain url, reason, and suggested_action fields. Reason must be one of: 'authenticated_endpoint', 'rate_limited', 'ip_restricted', 'requires_csrf', 'dynamic_content'. Reject if reason not in enum. |
Common Failure Modes
What breaks first when using a broken link detection prompt and how to guard against it.
False Positives from Authenticated Endpoints
What to watch: The prompt reports 403 or 401 status codes as broken links when the real issue is missing authentication, not a dead page. This floods the report with noise and erodes trust. Guardrail: Pre-filter the link list to exclude endpoints requiring session tokens, or instruct the prompt to classify auth-gated responses separately with a 'requires manual check' label.
Anchor Link Validation Failures
What to watch: The prompt checks only the base URL and reports the page as live, missing that the specific #section anchor no longer exists on the target page. This creates a false sense of link health. Guardrail: Require the prompt to fetch the page content and verify the anchor ID or name attribute exists in the DOM before marking the link as valid.
Redirect Chain Exhaustion
What to watch: The prompt follows redirects but hits a maximum depth or timeout, reporting the link as broken when the destination is reachable through a longer chain. This masks real link health behind tool limits. Guardrail: Configure a reasonable redirect limit (e.g., 5 hops) and instruct the prompt to report links exceeding the limit as 'unresolved' rather than 'broken,' with the full chain logged for manual review.
Rate Limiting and IP Blocking
What to watch: Aggressive link checking triggers rate limits or IP bans from target sites, causing the prompt to report mass failures that are artifacts of the audit itself, not real broken links. Guardrail: Implement a delay between requests and use a descriptive User-Agent header. Instruct the prompt to recognize 429 status codes and retry with exponential backoff, reporting only persistent failures.
Dynamic Content Rendering Gaps
What to watch: The prompt checks HTTP status codes but misses that JavaScript-rendered pages return 200 with an empty shell or error state. Single-page apps and client-side redirects appear live but are functionally broken. Guardrail: When the documentation site links to known JS-heavy domains, instruct the prompt to check for the presence of expected content markers or use a headless browser tool rather than a simple HTTP status check.
Suggested Replacement Link Hallucination
What to watch: When a link is broken, the prompt confidently suggests a replacement URL that looks plausible but does not exist, compounding the error with fabricated fixes. Guardrail: Require the prompt to verify every suggested replacement link with a live check before including it in the report. If no verified replacement exists, the prompt must output 'no verified replacement found' instead of guessing.
Evaluation Rubric
Use this rubric to evaluate the quality of the broken link detection prompt output before integrating it into a documentation CI/CD pipeline. Each criterion targets a specific failure mode common in link auditing workflows.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Link Categorization Accuracy | Internal, external, and anchor links are correctly classified with >95% accuracy on a labeled test set of 50 links. | External links classified as internal; anchor links reported as page-level links; mailto or javascript links misclassified. | Run prompt against a golden dataset of 50 known links with pre-labeled categories. Compare output categories to ground truth. |
HTTP Status Code Correctness | All reported status codes match the actual HTTP response from a live HEAD/GET request within a 5-second tolerance window. | Reported 200 for a 404; reported 301 when the server returns 200; status code missing for a link that resolves. | For a sample of 20 external links, programmatically issue HEAD requests and compare returned status codes to the prompt output. |
Redirect Chain Completeness | Multi-hop redirects (up to 5 hops) are fully traced, with each intermediate URL and status code reported in order. | Only the final URL reported; intermediate 301/302 hops omitted; redirect loop reported as a single broken link without chain detail. | Seed a test environment with a known 3-hop redirect chain. Verify the output contains all intermediate URLs and status codes in correct sequence. |
Anchor Existence Validation | Anchor links are verified against the actual page HTML. Valid anchors pass; missing anchors are flagged with the exact anchor ID. | Valid anchor reported as broken; broken anchor reported as valid; anchor check skipped entirely for pages that contain anchors. | Create a test page with 3 valid anchors and 2 intentionally broken anchors. Confirm the output correctly identifies each. |
False Positive Rate on Authenticated Endpoints | Links returning 403 or 401 are flagged as 'Requires Authentication' rather than 'Broken', with a false positive rate below 5%. | 403/401 responses reported as broken links; authenticated endpoints incorrectly categorized alongside truly dead links. | Include 5 links to authenticated endpoints (e.g., private GitHub repos) in the test set. Verify they are labeled as requiring authentication, not broken. |
Suggested Replacement Relevance | For broken links with a known replacement, the suggested URL is correct and points to a live, relevant page. | Suggested replacement is a 404 itself; suggestion points to an unrelated page; no suggestion provided when a canonical redirect target exists. | For 5 known-moved documentation pages, verify the suggested replacement matches the current live URL and returns 200. |
Output Schema Compliance | The output strictly matches the defined [OUTPUT_SCHEMA] with all required fields present and correctly typed. | Missing required fields; extra untyped fields; URL field contains non-URL strings; status code field contains text. | Validate the full JSON output against the expected schema using a JSON Schema validator. Reject any output that fails structural validation. |
Timeout and Unreachable Handling | Links that timeout after [REQUEST_TIMEOUT] seconds are reported as 'Unreachable' with the timeout duration noted, not as broken. | Timeout reported as 404 or 500; unreachable link omitted from report entirely; timeout duration not recorded. | Point the prompt at a test endpoint that deliberately delays beyond the timeout threshold. Confirm the output labels it 'Unreachable' with the timeout value. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a single documentation page. Remove strict output schema requirements—accept a plain list of broken links with status codes. Use a frontier model (GPT-4o, Claude 3.5 Sonnet) with a simple instruction: "Check every link on [PAGE_URL]. For each link, report the URL, HTTP status, and whether it resolves." Skip anchor validation and redirect chain analysis initially.
Watch for
- False positives on authenticated endpoints returning 403 instead of 200
- Model hallucinating status codes for links it cannot actually fetch
- Timeouts on slow external sites producing incomplete reports
- No distinction between transient failures and permanent broken links

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us