Skip to content

arsolutioner/markdown-for-agents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown for Agents Skill

An open source agent skill that fetches web content as clean markdown using Cloudflare's Markdown for Agents standard. Wraps content negotiation, Workers AI, and Browser Rendering into a single tool with automatic cascading fallback. Saves ~80-99% of tokens compared to raw HTML.

Works with Claude Code, OpenClaw, Cursor, and any tool that supports the Agent Skills standard.


Why This Exists

Markdown has become the lingua franca for AI agents. Its explicit structure is ideal for LLM processing -- better results, fewer tokens. A typical web page can shrink from hundreds of thousands of HTML tokens to a few thousand markdown tokens, an 80-99% reduction.

Cloudflare built Markdown for Agents directly into their CDN. When an agent sends Accept: text/markdown to any Cloudflare-enabled site with the feature turned on, the network converts HTML to markdown on the fly at the edge. The response includes an x-markdown-tokens header with the estimated token count and a Content-Signal header with machine-readable usage permissions. No API key needed for this path.

For sites where content negotiation is not available, Cloudflare provides two additional APIs. Workers AI toMarkdown handles arbitrary document conversion -- not just HTML, but PDFs, Word documents, Excel spreadsheets, images, CSV, XML, and more. Browser Rendering opens a real Chromium browser to render JavaScript-heavy pages before converting the result to markdown.

This skill wraps all three methods into a single tool with automatic cascading fallback. Requires Python 3.6+ (standard library only, no pip packages).


How It Works

Three Cloudflare methods in a cascading chain, stopping at the first success:

Request --> [1] Content Negotiation --> [2] Workers AI --> [3] Browser Rendering
              (no credentials)        (credentials)       (credentials)

Method 1: Content Negotiation

Sends an HTTP request with Accept: text/markdown. If the site is behind Cloudflare and has the "Markdown for Agents" feature enabled, Cloudflare converts the HTML to markdown at the CDN edge and returns it directly. No API calls, no credentials, no processing on your side. The response includes token counts (X-Markdown-Tokens) and a usage policy signal (Content-Signal).

Method 2: Workers AI toMarkdown

Downloads the file from the URL, then uploads it to Cloudflare's Workers AI toMarkdown REST API for server-side conversion. This is the most versatile method -- it handles 15+ file formats including PDFs, Word documents, Excel spreadsheets, images, and more. Text document conversion is free; image conversion uses AI vision models and may consume Neurons.

Method 3: Browser Rendering

Sends the URL to Cloudflare's headless Chromium service, which opens a real browser, loads the page, executes all JavaScript, waits for content to render, then converts the fully-rendered DOM to markdown. This is the only method that captures content generated by client-side JavaScript. Does not work on PDFs.

Comparison

Content Negotiation Workers AI Browser Rendering
Credentials None Required Required
Cost Free Free (images may cost Neurons) Free tier: 10 min/day
File Types HTML only HTML, PDF, images, Office docs, CSV, XML (15+ formats) HTML only
JavaScript No No Yes
Speed Fast (single request) Medium (fetch + API call) Slow (browser render)
Best For Cloudflare sites with feature enabled PDFs, documents, any site JS-heavy SPAs, dynamic pages

See the SKILL.md for full CLI usage, options, and examples.


Installation

One-Line Install

# Using npx (works across 37+ AI coding agents)
npx skills add arsolutioner/markdown-for-agents

# Using curl
curl -fsSL https://raw.githubusercontent.com/arsolutioner/markdown-for-agents/main/install.sh | bash

Claude Code Plugin System

/plugin marketplace add arsolutioner/markdown-for-agents
/plugin install markdown-for-agents

OpenClaw

Tell your agent:

Install the skill from https://github.com/arsolutioner/markdown-for-agents

Or via ClawHub:

clawhub install markdown-for-agents

Cursor / Augment Code / Codex / OpenCode

npx skills add arsolutioner/markdown-for-agents

The npx skills add command from Vercel Labs auto-detects your installed agents and places the skill in the correct location.


Configuration

No setup needed for Method 1. For Methods 2 and 3, set Cloudflare credentials:

export CLOUDFLARE_ACCOUNT_ID=your_account_id
export CLOUDFLARE_API_TOKEN=your_api_token

Or add to ~/.claude/.env when using with Claude Code.

To create an API token: dash.cloudflare.com > My Profile > API Tokens > Create Token with Workers AI: Read and Browser Rendering: Edit permissions.


Supported File Types

Workers AI (Method 2) converts these formats to markdown:

Format Extensions
HTML .html, .htm
PDF .pdf
Images .jpeg, .jpg, .png, .webp, .svg
Microsoft Word .docx
Microsoft Excel .xlsx, .xlsm, .xlsb, .xls
Open Document .ods, .odt
CSV / XML .csv, .xml
Apple Numbers .numbers

Methods 1 and 3 handle HTML web pages only.


Pricing

All three methods can be used for free within Cloudflare's included tiers.

Method Free? What's Included When You Pay
Content Negotiation Yes Unlimited requests, no metered billing Free for the agent. Works on any site that has the feature enabled.
Workers AI Yes 10,000 Neurons/day. Text docs cost 0 Neurons. Images consume Neurons. Beyond 10k/day: $0.011/1k Neurons (Workers Paid $5/mo)
Browser Rendering Yes Free plan: 10 min/day, 3 concurrent browsers. No payment needed. Beyond free tier: Workers Paid ($5/mo) gives 10 hrs/month, then $0.09/hr

In practice: Text-based conversion (web pages, PDFs, documents) is free. Content Negotiation is free to use on any site that supports it. Browser Rendering is free under 10 min/day.


Limitations

Method Limitation
Content Negotiation Only works on sites that have the feature enabled. Max 2 MB response.
Workers AI Large files may timeout -- use -t 120. Images consume Neurons.
Browser Rendering Does NOT work on PDFs. Free plan: 10 min/day.

JavaScript-rendered content is only captured by Browser Rendering (Method 3).


Cross-Platform Compatibility

This skill follows the Agent Skills open standard:

Platform Install
Claude Code /plugin install or copy to ~/.claude/skills/
OpenClaw clawhub install or copy to ~/.openclaw/skills/
Cursor npx skills add
Augment Code npx skills add
Codex npx skills add
OpenCode npx skills add

Project Structure

markdown-for-agents/
  .claude-plugin/
    plugin.json              # Claude Code plugin manifest
    marketplace.json         # Claude Code marketplace descriptor
  skills/
    markdown-for-agents/
      SKILL.md               # Agent Skills manifest (full docs, CLI usage, examples)
  scripts/
    fetch_markdown.py        # Main CLI tool (all 3 methods)
  install.sh                 # One-line installer script

Contributing

Contributions are welcome. Please open an issue first to discuss what you would like to change.


License

MIT

About

Agent skill wrapping Cloudflare's Markdown for Agents, Works with Claude Code, OpenClaw, Cursor, and 30+ AI coding agents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors