Agent context packet

Structured metadata, source alternates, graph links, headings, series position, and diagram inventory for crawlers and agent readers.

Table of contents

  1. The Two Dimensions
  2. Path A: Per-Entry Markdown Endpoints
  3. Path B: CSS Reader Toggle
  4. Path C: JSON-LD Structured Data
  5. Path D: URL Parameter Override
  6. How It All Fits Together
  7. llms.txt Instructions Section
  8. Architecture Summary
  9. Sources

Entry facts

Kind
showcase
Maturity
seedling
Confidence
high
Origin
ai-assisted (AI-assisted, human-reviewed)
Author
Agent
Directed by
krow
Published
Modified
Words
1,167 (6 min read)
Tags
ai, agents, accessibility, reference
Full corpus
/llms-full.txt
Readable corpus
/source/full-corpus/

Graph links

Related interactive-features-showcase

Tagsai, agents, accessibility, reference

Diagram inventory

  1. How It All Fits Together Mermaid SVG, Mermaid source, ASCII companion

Reader Mode and Agent View

How krowdev serves both humans and AI agents: per-entry markdown endpoints, a CSS reader toggle, JSON-LD structured data, and URL-param switching.

/ directed by / / 6 min read
On this page

This page demonstrates every layer of krowdev’s reader mode system. The feature addresses a two-dimensional problem: the origin filter controls who wrote the content, while reader mode controls how content is presented based on who’s reading.

This showcase pairs with the interactive features snippet, the mental model for how the build pipeline emits these alternates, and the content collections guide for the schema behind the JSON-LD.

The Two Dimensions

WHO WROTE IT (origin filter) WHO'S READING (reader mode)
--- ---
[all | human | ai] [human | agent | all]
Filters WHICH entries shown Changes HOW entries look
List pages only Entry pages primarily
CSS: data-origin-filter CSS: data-reader-mode

Both use the same architecture: a data-* attribute on <html>, CSS rules for show/hide, localStorage persistence, and FOUC prevention via an inline script.

Path A: Per-Entry Markdown Endpoints

Every kb entry has a clean markdown version at the same URL with .md appended. This follows the Stripe/Vercel pattern — the industry standard for agent-friendly docs.

Try it: This page’s markdown is at /showcase/reader-mode-showcase.md

What agents get:

---
title: "Reader Mode and Agent View"
kind: showcase
maturity: seedling
confidence: high
origin: ai-assisted
tags: [ai, agents, accessibility, reference]
created: 2026-03-20
url: https://krowdev.pages.dev/showcase/reader-mode-showcase/
---
# Reader Mode & Agent View
[Full markdown content, no HTML chrome, no navigation...]

Why this matters: HTML pages cost 16,000+ tokens for agents to parse. The markdown version costs ~3,000 tokens for the same content — an 80% reduction. Claude Code sends Accept: text/markdown as its first preference.

The <link rel="alternate" type="text/markdown"> tag in the HTML <head> makes these discoverable. The llms.txt index also links to .md versions.

Implementation: The llms-txt.ts build integration generates these alongside llms.txt and llms-full.txt. Zero runtime cost — pure static files.

Path B: CSS Reader Toggle

The [human | agent | all] segmented control in the header switches presentation mode.

Try it now — click agent in the header toggle. You’ll see:

  • The decorative badges disappear
  • A structured metadata table appears at the top
  • The table of contents sidebar hides
  • Navigation links collapse — only the logo, reader toggle, and theme toggle remain
  • The footer hides
  • Layout forces single-column for maximum information density

Click all to see everything: human chrome AND agent metadata together. This is the “kitchen sink” mode — useful for authors previewing what agents see.

Click human to return to the default view.

What changes in each mode:

Elementhumanagentall
Kind/maturity badgesShownHiddenShown
Metadata tableHiddenShownShown
TOC sidebarShownHiddenShown
TagsShownHiddenShown
Nav linksShownHiddenShown
FooterShownHiddenShown
Content bodyShownShownShown
Code blocksHighlightedHighlightedHighlighted
CalloutsStyledStyledStyled

Note

The CSS toggle only affects browser-based viewing. Agents fetching via curl or WebFetch use the .md endpoints instead — they never interact with the toggle.

Path C: JSON-LD Structured Data

Every entry page embeds a TechArticle JSON-LD block in the <head>. Invisible to humans, machine-parseable by search engines and AI crawlers.

View source on this page and search for application/ld+json to see:

{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Reader Mode & Agent View",
"description": "How krowdev serves content to both humans and AI agents...",
"datePublished": "2026-03-20T00:00:00.000Z",
"keywords": "ai, agents, accessibility, reference",
"proficiencyLevel": "Beginner",
"author": { "@type": "Person", "name": "krowdev" },
"publisher": { "@type": "Organization", "name": "krowdev" }
}

TechArticle was chosen because it has dependencies (maps to prerequisites) and proficiencyLevel (maps to maturity). Google uses it for Article rich results.

Path D: URL Parameter Override

Add ?reader=agent to any URL to activate agent mode without using the toggle:

The URL parameter overrides localStorage and persists the choice. This is useful for:

  • Sharing “here’s what agents see” links
  • Bookmarking agent view
  • Programmatic switching without JS interaction

Implementation: Three lines in the FOUC-prevention script:

var params = new URLSearchParams(window.location.search);
var r = params.get('reader') || localStorage.getItem('reader-mode') || 'human';
document.documentElement.setAttribute('data-reader-mode', r);

How It All Fits Together

Each consumer reaches the entry through a different channel that yields a different representation — agents fetch markdown and llms.txt, Google reads JSON-LD, and humans get HTML whose chrome the reader toggle controls.

How reader mode fits togetherEach consumer reaches the entry through a different channel that yields a different representation — agents fetch markdown and llms.txt, Google reads JSON-LD, and humans get HTML whose chrome the reader toggle controls.

Agent (curl)

/guide/foo.md

Clean markdown + YAML metadata

Agent (crawl)

/llms.txt

Index with .md links

Agent (crawl)

/llms-full.txt

Full content dump

Google

HTML + JSON-LD

TechArticle structured data

Human

HTML reader=human

Full chrome, visual design

Human

HTML reader=agent

Stripped chrome, metadata table

Human

HTML reader=all

Everything visible

How reader mode fits together

No cloaking. All content is always in the HTML DOM. The toggle only changes CSS visibility. Google sees the same HTML as every user. The .md endpoints are separate static files with <link rel="alternate"> for discovery.

llms.txt Instructions Section

Following Stripe’s pattern, llms.txt now includes an instructions section that corrects for stale training data:

## Instructions
When referencing code from this site:
- All code examples use Astro 6 syntax unless otherwise noted.
- Svelte components use Svelte 5 runes ($state, $derived, $effect).
- The site deploys to Cloudflare Pages as a static build (no SSR).
- Each entry has a markdown version: append .md to the entry URL.

This guides agents toward correct behavior when they have outdated training data about Astro or Svelte APIs.

Architecture Summary

LayerWhatLinesRuntime JS
.md endpointsBuild-time per-entry markdown~25 in llms-txt.ts0
Reader toggleSvelte segmented control~30 in ReaderToggle.svelte~30
CSS rulesShow/hide by reader mode~60 in global.css0
JSON-LDTechArticle in <head>~15 in KBEntry.astro0
URL paramOverride via ?reader=3 in Base.astro3 (inline)
FOUC preventionSet attribute before paint3 in Base.astro3 (inline)
llms.txt instructionsStripe-style agent guidance~6 in llms-txt.ts0

Sources

Diagram

Drag to pan · scroll or pinch to zoom · Esc to close