🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

afdocs

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afdocs

Test your documentation site against the Agent-Friendly Documentation Spec

Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

afdocs

CI npm

Test your documentation site against the Agent-Friendly Documentation Spec.

Agents don't use docs like humans. They hit truncation limits, get walls of CSS instead of content, can't follow cross-host redirects, and don't know about quality-of-life improvements like llms.txt or .md docs pages that would make life swell. Maybe this is because the industry has lacked guidance - until now.

afdocs runs 21 checks across 8 categories to evaluate how well your docs serve agent consumers. 16 are fully implemented; the rest return skip until completed.

Status: Early development (0.x) This project is under active development. Check IDs, CLI flags, and output formats may change between minor versions. Feel free to try it out, but don't build automation against specific output until 1.0.

Implements spec v0.1.0 (2026-02-22).

Quick start

npx afdocs check https://docs.example.com

Example output:

Agent-Friendly Docs Check: https://react.dev

llms-txt
  ✓ llms-txt-exists: llms.txt found at 1 location(s)
  ✓ llms-txt-valid: llms.txt follows the proposed structure
  ✓ llms-txt-size: llms.txt is 14,347 characters (under 50,000 threshold)
  ✓ llms-txt-links-resolve: All 50 tested links resolve (177 total links)
  ✓ llms-txt-links-markdown: 50/50 links point to markdown content (100%)

Markdown Availability
  ✗ content-negotiation: Server ignores Accept: text/markdown header (0/50 sampled pages return markdown)
  ✗ markdown-url-support: No sampled pages support .md URLs (0/50 tested)

URL Stability
  ✓ http-status-codes: All 50 sampled pages return proper error codes for bad URLs

Authentication
  ✓ auth-gate-detection: All 50 sampled pages are publicly accessible

Summary
  9 passed, 3 failed, 9 skipped (21 total)

Install

npm install afdocs

CLI usage

# Run all checks
afdocs check https://docs.example.com

# Run specific checks
afdocs check https://docs.example.com --checks llms-txt-exists,llms-txt-valid,llms-txt-size

# JSON output
afdocs check https://docs.example.com --format json

# Adjust thresholds
afdocs check https://docs.example.com --pass-threshold 30000 --fail-threshold 80000

Options

OptionDefaultDescription
--format <format>textOutput format: text or json
-v, --verboseShow per-page details for checks with issues
--checks <ids>allComma-separated list of check IDs
--max-concurrency <n>3Maximum concurrent HTTP requests
--request-delay <ms>200Delay between requests
--max-links <n>50Maximum links to test in link checks
--pass-threshold <n>50000Size pass threshold (characters)
--fail-threshold <n>100000Size fail threshold (characters)

Exit codes

  • 0 if all checks pass or warn
  • 1 if any check fails

Programmatic API

import { runChecks, createContext, getCheck } from 'afdocs';

// Run all checks
const report = await runChecks('https://docs.example.com');

// Run a single check
const ctx = createContext('https://docs.example.com');
const check = getCheck('llms-txt-exists')!;
const result = await check.run(ctx);

Test helpers

afdocs includes vitest helpers so you can add agent-friendliness checks to your docs site's test suite.

Config-driven

Create agent-docs.config.yml:

url: https://docs.example.com
checks:
  - llms-txt-exists
  - llms-txt-valid
  - llms-txt-size

Then in your test file:

import { describeAgentDocs } from 'afdocs/helpers';

describeAgentDocs();

This reads the config and generates one test assertion covering all specified checks.

Direct imports

import { createContext, getCheck } from 'afdocs';
import { describe, it, expect } from 'vitest';

describe('agent-friendliness', () => {
  it('has a valid llms.txt', async () => {
    const ctx = createContext('https://docs.example.com');
    const check = getCheck('llms-txt-exists')!;
    const result = await check.run(ctx);
    expect(result.status).toBe('pass');
  });
});

Checks

21 checks across 8 categories. Checks marked with * are not yet implemented and return skip.

Category 1: llms.txt

CheckDescription
llms-txt-existsWhether llms.txt is discoverable at candidate locations
llms-txt-validWhether llms.txt follows the llmstxt.org structure
llms-txt-sizeWhether llms.txt fits within agent truncation limits
llms-txt-links-resolveWhether URLs in llms.txt return 200
llms-txt-links-markdownWhether URLs in llms.txt point to markdown content

Category 2: Markdown Availability

CheckDescription
markdown-url-supportWhether .md URL variants return markdown
content-negotiationWhether the server honors Accept: text/markdown

Category 3: Page Size and Truncation Risk

CheckDescription
page-size-markdownCharacter count when served as markdown
page-size-htmlCharacter count of HTML and post-conversion size
content-start-positionHow far into the response actual content begins

Category 4: Content Structure

CheckDescription
tabbed-content-serialization *Whether tabbed content creates oversized output
section-header-quality *Whether headers in tabbed sections include context
markdown-code-fence-validityWhether markdown has unclosed code fences

Category 5: URL Stability and Redirects

CheckDescription
http-status-codesWhether error pages return correct status codes
redirect-behaviorWhether redirects are same-host HTTP redirects

Category 6: Agent Discoverability Directives

CheckDescription
llms-txt-directiveWhether pages include a directive pointing to llms.txt

Category 7: Observability and Content Health

CheckDescription
llms-txt-freshness *Whether llms.txt reflects current site state
markdown-content-parity *Whether markdown and HTML versions match
cache-header-hygieneWhether cache headers allow timely updates

Category 8: Authentication and Access

CheckDescription
auth-gate-detectionWhether documentation pages require authentication to access content
auth-alternative-access *Whether auth-gated sites provide alternative access paths for agents

Check dependencies

Some checks depend on others. If a dependency doesn't pass, the dependent check is skipped automatically.

  • llms-txt-valid, llms-txt-size, llms-txt-links-resolve, llms-txt-links-markdown require llms-txt-exists
  • page-size-markdown requires markdown-url-support or content-negotiation
  • section-header-quality requires tabbed-content-serialization
  • markdown-code-fence-validity requires markdown-url-support or content-negotiation
  • llms-txt-freshness requires llms-txt-exists
  • markdown-content-parity requires markdown-url-support or content-negotiation
  • auth-alternative-access requires auth-gate-detection (warn or fail)

Responsible use

afdocs makes HTTP requests to the sites it checks. It enforces delays between requests (200ms default), caps concurrent connections, and honors Retry-After headers. The goal is to help documentation teams improve agent accessibility, not to load-test their infrastructure.

License

MIT

Keywords

agent

FAQs

Package last updated on 12 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts