npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@puralex/astro-markdown-for-agents

v0.2.0

Published

Astro integration that serves Markdown to AI agents — Cloudflare free plan compatible

Readme

astro-markdown-for-agents

An Astro integration that automatically serves Markdown to AI agents — including on Cloudflare's free plan.

Cloudflare's built-in Markdown for Agents feature (launched February 2026) converts HTML pages to Markdown when AI agents request them, significantly reducing token usage. However, it requires a paid Cloudflare plan. This integration replicates that behaviour inside Astro's middleware layer, so any Astro site can benefit regardless of hosting plan.

How It Works

When a request arrives with either:

  • an Accept: text/markdown header, or
  • a User-Agent that matches a known AI crawler (GPTBot, ClaudeBot, PerplexityBot, etc.)

…the middleware intercepts the normal HTML response, converts it to clean Markdown, and returns it with Content-Type: text/markdown.

All other requests are passed through unchanged.

Installation

npm install astro-markdown-for-agents

Usage

// astro.config.mjs
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import markdownForAgents from 'astro-markdown-for-agents';

export default defineConfig({
  adapter: cloudflare(),
  integrations: [markdownForAgents()],
});

The integration works with any Astro adapter, not just Cloudflare.

Testing

# Should return text/markdown
curl -H "Accept: text/markdown" http://localhost:4321/

# Should return normal HTML
curl http://localhost:4321/

# Simulate a known AI crawler
curl -H "User-Agent: GPTBot/1.0" http://localhost:4321/

Token Savings

Serving Markdown instead of HTML dramatically reduces the number of tokens an AI model needs to process. For example, a typical documentation page:

| Format | Tokens | |----------|---------| | HTML | ~16,000 | | Markdown | ~3,100 |

That is roughly an 80% reduction.

Supported AI Agents

The following User-Agent strings are detected out of the box:

  • anthropic-ai / Claude-Web / ClaudeBot
  • GPTBot / ChatGPT-User
  • Google-Extended
  • cohere-ai
  • PerplexityBot
  • YouBot
  • Applebot-Extended
  • Bytespider, CCBot, DataForSeoBot, FacebookBot, facebookexternalhit
  • ImagesiftBot, Omgilibot, Omgili, PiplBot, Seekr
  • Timpibot, VelenPublicWebCrawler, WebzIO-Extended

Any request sending Accept: text/markdown is also matched, regardless of User-Agent.

Edge Runtime Compatibility

The converter is implemented with pure regex — no DOM, no Node.js APIs. It runs natively in Cloudflare Workers, Deno Deploy, and any other edge runtime.

License

GPL-3.0 — see LICENSE.