Fetchtype

Fetchtype Documentation

The typography infrastructure layer for agent-native development.

01

Installation

$ npm install -D fetchtype

Or run directly with npx — no installation required:

$ npx fetchtype --help

02

Commands

fetchtype init

Create a starter token file. Use --preset for design system defaults.

fetchtype validate

Validate tokens against 28 rules covering accessibility, hierarchy, motion physics, and consistency.

fetchtype build

Export to CSS, JSON, Tailwind, shadcn, or W3C Design Tokens.

fetchtype resolve <font>

Look up any font in the 1,929-font registry with metrics, pairings, and fallback CSS.

fetchtype pair <font>

Get pairing recommendations with confidence scores and role assignments.

fetchtype search [query]

Search the registry by name, context, category, variable support, or subset.

fetchtype preview

Launch a local dev server to preview your typography tokens with live reload.

fetchtype suggest

Get font suggestions by context (display, interface, reading, editorial, mono, data).

fetchtype import

Import a W3C Design Token file into fetchtype format.

fetchtype mcp

Start the MCP server for AI agent integration (12 tools via stdio).

03

Token Format

Fetchtype tokens live in fetchtype.tokens.json at your project root. The schema covers typography, color, spacing, layout, and hierarchy.

Typography Contexts

Each context maps to a TypographyToken with the following fields:

Field Type Required
fontFamilystring | string[]Yes
fontSizestringYes
fontWeightnumber | stringYes
lineHeightstring | numberYes
letterSpacingstringNo
textTransformnone | uppercase | lowercase | capitalizeNo
textDecorationnone | underline | line-throughNo

The 12 typography contexts:

heading
subheading
body
caption
button
label
input
chart-label
chart-axis
chart-title
code
blockquote

Color Tokens

Defined per mode (light and dark). Each mode contains:

text primary, secondary, muted, accent, inverse
background primary, secondary, accent, muted
border default, muted, accent
interactive default, hover, active, focus, disabled

Spacing, Layout & Hierarchy

spacing unit (base rem) + scale record (e.g. xs, sm, md, lg, xl)
layout.maxWidth prose, content, wide, full
layout.breakpoints Record of named breakpoints
layout.grid Optional columns + gap
hierarchy.scale minor-second | major-second | minor-third | major-third | perfect-fourth
hierarchy.headings h1-h6, each with fontSize, fontWeight, lineHeight, letterSpacing?, fontFamily?
hierarchy.emphasis strong (fontWeight) + subtle (opacity, fontSize?)

Optional Top-Level Fields

themes[] Named theme overrides with colorScheme (light, dark, auto, brand, high-contrast)
modes Named typography/layout overrides (e.g. compact, large-print)
requiredSubsets[] Font subsets required for locale/script coverage validation
fontDisplay auto | block | swap | fallback | optional
// Minimal fetchtype.tokens.json
{
  "typography": {
    "body": {
      "fontFamily": ["Inter", "sans-serif"],
      "fontSize": "1rem",
      "fontWeight": 400,
      "lineHeight": 1.6
    }
  },
  "color": { "light": { ... }, "dark": { ... } },
  "spacing": { "unit": "0.25rem", "scale": { "sm": "0.5rem", "md": "1rem" } },
  "layout": { "maxWidth": { "prose": "65ch", "content": "80rem", "wide": "96rem", "full": "100%" }, "breakpoints": {} },
  "hierarchy": { "scale": "major-third", "baseSize": "1rem", "headings": { ... }, "emphasis": { ... } }
}

04

Presets

Start from a design system preset with validated typography, colors, spacing, and hierarchy.

base

Inter + JetBrains Mono

editorial

Source Serif + Inter

fluent

Segoe UI Variable + Cascadia Code

material

Roboto + Roboto Mono

carbon

IBM Plex Sans + IBM Plex Mono

spectrum

Source Sans 3 + Source Code Pro

radix

Inter + JetBrains Mono

dashboard

Inter + JetBrains Mono

ecommerce

Inter + Source Serif 4

docs

Inter + JetBrains Mono

05

Validation Rules

fetchtype validate checks your tokens against rules in three categories: core validation, font analysis, and site audit.

Core Rules

contrast.text-primary.light

WCAG AA contrast ratio for primary text on light background.

contrast.text-primary.dark

WCAG AA contrast ratio for primary text on dark background.

font-size-min.button

Button text must meet minimum size for tap targets.

font-size-min.caption

Caption text must remain legible (min 0.75rem).

font-size-min.label

Label text must remain legible for form contexts.

text-spacing.body-line-height

Body line-height must be at least 1.5 for readability (WCAG 1.4.12).

line-height.heading-vs-body

Heading line-height should be tighter than body line-height.

line-length.prose

Prose max-width should be 45-80ch for comfortable reading.

heading.size-direction

Heading sizes must decrease monotonically from h1 to h6.

heading.scale-divergence

Heading ratios should stay close to the declared type scale.

spacing.scale-monotonic

Spacing scale values must increase monotonically.

Font Rules

font.missing-fallbacks

Font stacks must include a generic fallback (sans-serif, serif, monospace).

font.unknown-family

Primary font family should exist in the registry or be a system font.

font.payload-estimate

Estimated total font payload should stay under budget.

font.weight-available

Requested font weights must be available for the font family.

font.axis-range

Variable font axis values must be within the font's supported range.

font.subset-coverage

Required subsets must be available for all declared fonts.

font.display-strategy

Font-display value should be swap or optional for web performance.

font.preload-count

Number of preloaded font files should not exceed recommended limit.

font.fluid-type

Fluid type clamp() values must have valid min, preferred, and max.

theme.dark-mode-completeness

Dark mode must define all color tokens present in light mode.

Audit Rules

Run with fetchtype audit <url> to check a live site or HTML file.

audit.render-blocking Font loaded via render-blocking @import
audit.missing-font-display Google Fonts URL missing display= parameter
audit.google-cdn Fonts loaded from Google CDN instead of self-hosted
audit.no-font-display @font-face missing font-display property
audit.no-subset @font-face missing unicode-range subsetting
audit.inconsistent-line-height Body text uses multiple conflicting line-heights
audit.inconsistent-scale Heading sizes do not follow a consistent scale ratio
audit.contrast-warning Text/background combination may fail WCAG contrast
audit.inline-font-style Inline style overriding font properties
audit.no-fallback-metrics No size-adjust or ascent-override for fallback fonts

06

Exporters

fetchtype build transforms your token file into production-ready output. Default format is CSS custom properties.

CSS Custom Properties default

Generates --ft-* variables for all tokens with light/dark mode via prefers-color-scheme.

$ fetchtype build
JSON Token Bundle --format json

Flat JSON output for runtime consumption, theming engines, or design tool sync.

$ fetchtype build --format json
Tailwind Config --format tailwind

Generates a tailwind.config.ts partial with fontFamily, fontSize, lineHeight, colors, and spacing extensions.

$ fetchtype build --format tailwind
shadcn/ui --format shadcn

CSS with HSL variables matching shadcn/ui conventions. Drop-in for globals.css.

$ fetchtype build --format shadcn
W3C Design Tokens --format w3c

Outputs the W3C Design Tokens Community Group format for cross-tool interop (Figma Tokens, Style Dictionary, etc.).

$ fetchtype build --format w3c

07

Font Registry

1,929 Google Fonts with enriched metadata including performance metrics, fallback CSS, pairing recommendations, and context suitability scores.

FontEntry Fields

Field Description
idUnique slug (e.g. inter)
familyDisplay name (e.g. "Inter")
categorysans-serif, serif, monospace, display, handwriting
tagsCurated tags (geometric, humanist, grotesque, etc.)
contextsSuitability scores per typography context
variableWhether the font supports variable axes
axesVariable axes with min/max ranges (wght, wdth, etc.)
weightsAvailable weight values
stylesnormal, italic
subsetsLanguage/script subsets (latin, cyrillic, etc.)
performanceFile sizes, loading stats, CLS impact
metricsascent, descent, lineGap, unitsPerEm, xHeight, capHeight
fallbackPre-computed fallback CSS with size-adjust and ascent-override
pairingRecommended pairings with confidence and role
licenseLicense type (typically OFL)
installnpm package, CDN URL, and self-host instructions

CLI Commands

$ fetchtype resolve inter

Look up a font by name. Returns full metadata, metrics, and fallback CSS.

$ fetchtype search "geometric sans" --variable --context body

Search with filters. Combine name/tag queries with structured filters.

$ fetchtype pair inter

Get pairing recommendations with confidence scores and heading/body role assignments.

Search Filters

--context body, heading, code, etc.
--category sans-serif, serif, mono
--variable Variable fonts only
--subset latin, cyrillic, etc.
--max-payload Maximum font file size in KB

08

Motion & Animation

Define your motion personality as tokens. Durations, easings, spring configs, animation presets, and scroll-driven interpolations — all framework-agnostic values that map to Framer Motion, anime.js, CSS transitions, or any animation library.

Token Format

"motion": {
  "duration": {
    "instant": "100ms",
    "fast": "200ms",
    "normal": "300ms",
    "slow": "500ms"
  },
  "easing": {
    "default": "cubic-bezier(0.4, 0, 0.2, 1)",
    "enter": "cubic-bezier(0, 0, 0.2, 1)",
    "exit": "cubic-bezier(0.4, 0, 1, 1)",
    "bounce": "cubic-bezier(0.34, 1.56, 0.64, 1)"
  },
  "spring": {
    "snappy": { "stiffness": 400, "damping": 30, "mass": 1 },
    "gentle": { "stiffness": 120, "damping": 14, "mass": 1 },
    "bouncy": { "stiffness": 300, "damping": 10, "mass": 1 }
  },
  "preset": {
    "fade-in": {
      "property": "opacity",
      "from": 0, "to": 1,
      "duration": "300ms",
      "easing": "cubic-bezier(0, 0, 0.2, 1)"
    }
  },
  "interpolation": {
    "parallax-depth": {
      "input": "scroll",
      "inputRange": [0, 0.5, 1],
      "outputRange": [0, "-50px", "-100px"]
    }
  }
}

Validation Rules

Rule Severity Description
motion.duration-scale-monotonicwarningDuration scale values must increase monotonically
motion.duration-accessibilityinfoWarn on durations below 100ms (vestibular sensitivity)
motion.spring-damping-positiveerrorSpring damping must be positive (prevents infinite oscillation)
motion.spring-stiffness-positiveerrorSpring stiffness must be positive
motion.easing-valid-beziererrorcubic-bezier values must have 4 valid numeric parameters
timeline.fps-reasonablewarningTimeline fps should be between 24 and 120

CSS Output

:root {
  --ft-motion-duration-instant: 100ms;
  --ft-motion-duration-fast: 200ms;
  --ft-motion-duration-normal: 300ms;
  --ft-motion-easing-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ft-motion-easing-enter: cubic-bezier(0, 0, 0.2, 1);
  --ft-motion-spring-snappy-stiffness: 400;
  --ft-motion-spring-snappy-damping: 30;
  --ft-motion-spring-snappy-mass: 1;
}

09

Scenes & 3D

Define 3D scene parameters as tokens — camera presets, lighting rigs, PBR materials, and environment config. Framework-agnostic values that map to Three.js, React Three Fiber, Spline, or Babylon.js.

"scenes": {
  "camera": {
    "default": {
      "type": "perspective",
      "fov": 45,
      "near": 0.1,
      "far": 1000,
      "position": [0, 2, 5]
    }
  },
  "materials": {
    "brand-surface": {
      "type": "physical",
      "color": "#7c3aed",
      "roughness": 0.35,
      "metalness": 0.1
    },
    "glass": {
      "type": "physical",
      "color": "#ffffff",
      "roughness": 0.05,
      "transmission": 0.95,
      "thickness": 0.5
    }
  },
  "environment": {
    "default": {
      "background": "#0a0a0a",
      "fog": { "color": "#0a0a0a", "near": 10, "far": 50 }
    }
  }
}

Material Validation

Rule Severity Description
scene.material-roughness-rangeerrorRoughness must be 0-1
scene.material-metalness-rangeerrorMetalness must be 0-1
scene.material-transmission-rangeerrorTransmission must be 0-1

10

Timeline Compositions

Frame-based, time-bounded compositions for hero animations, product showcases, and promotional content. Inspired by Remotion's programmatic video model — define sequences on a timeline, not imperative code.

"timeline": {
  "fps": 30,
  "compositions": {
    "hero-intro": {
      "width": 1920,
      "height": 1080,
      "durationInFrames": 90,
      "params": {
        "headline": "string",
        "accentColor": "#7c3aed"
      },
      "sequences": [
        { "name": "bg-fade", "from": 0, "durationInFrames": 30 },
        { "name": "title-enter", "from": 15, "durationInFrames": 45, "stagger": 5 },
        { "name": "cta-appear", "from": 50, "durationInFrames": 40 }
      ]
    }
  }
}
Field Type Description
fpsnumberDefault frame rate for all compositions
width / heightnumberComposition dimensions in pixels
durationInFramesnumberTotal duration as frame count
paramsobjectParametric inputs the composition accepts
sequences[].fromnumberStart frame (0-indexed)
sequences[].staggernumberDelay between sibling elements in frames

11

Spatial Layers

A z-ordered canvas of visual elements, each with composable shader effects and continuous interaction drivers. Inspired by Unicorn Studio's layer-based WebGL model.

"layers": {
  "hero-background": {
    "type": "image",
    "z": 0,
    "effects": [
      { "type": "noise", "intensity": 0.15, "scale": 2.0 },
      { "type": "blur", "radius": "8px" }
    ],
    "interactions": {
      "mouse": {
        "property": "position",
        "intensity": 0.02,
        "smoothing": 0.1
      }
    }
  },
  "hero-mesh": {
    "type": "3d-model",
    "z": 1,
    "interactions": {
      "scroll": {
        "property": "scale",
        "inputRange": [0, 1],
        "outputRange": [1, 1.5]
      }
    }
  }
}
Field Type Description
typeenumimage | shape | text | video | 3d-model
znumberZ-order (higher = in front)
effects[]arrayComposable shader effects (noise, blur, glow, distortion)
interactions.*.propertystringProperty driven by the input signal
interactions.*.intensitynumberResponse strength multiplier
interactions.*.smoothingnumberSmoothing factor (0-1)

12

MCP Server

Fetchtype ships an MCP server with 12 tools for AI agent integration. Works with Claude, Cursor, Windsurf, and any MCP-compatible client.

$ fetchtype mcp

Add to your MCP client config:

{
  "mcpServers": {
    "fetchtype": {
      "command": "npx",
      "args": ["fetchtype", "mcp"]
    }
  }
}

13

Agent Integrations

Drop-in configuration files that give AI coding agents full fetchtype awareness — token schema, all 20 rules, CLI commands, and MCP server setup. Copy the right file into your project.

Claude Code SKILL.md

Full skill file with YAML frontmatter. Auto-activates when working with typography, design tokens, or font selection.

mkdir -p .claude/skills/fetchtype
# Copy SKILL.md from docs/agent-integrations/

Destination: .claude/skills/fetchtype/SKILL.md

Cursor .mdc

MDC rule file with glob patterns. Auto-attaches when editing fetchtype.tokens.json, tailwind.config.*, or globals.css.

Destination: .cursor/rules/fetchtype.mdc

GitHub Copilot .md

Plain markdown instructions. Append to your existing Copilot instructions file.

Destination: .github/copilot-instructions.md (append)

Windsurf .md

Workspace rule file. Set activation mode to "Always On" or "Model Decision" in the Windsurf UI.

Destination: .windsurf/rules/fetchtype.md

Cline .md

Rules file with token schema, validation rules, and MCP config. All files in .clinerules/ are merged automatically.

Destination: .clinerules/fetchtype.md

Each file teaches the agent the full fetchtype workflow: token schema (12 typography contexts), all 20 validation rules, every CLI command with flags, export formats, and MCP server configuration.

# All integration files available on GitHub:

https://github.com/fetchtype/fetchtype/tree/main/docs/agent-integrations

Fastest integration: Skip the config files entirely — just add the MCP server to your tool's config (see section 08 above). This gives the agent 12 tools for validation, font search, pairing, and export with no file copying.

14

REST API

Public REST API for querying the font registry. CORS enabled, public caching.

Base URL: https://fetchtype.dev
GET /api/v1/fonts

List fonts with filtering and pagination.

Param Type Description
pagenumberPage number (default 1)
limitnumberResults per page (default 20, max 100)
categorystringFilter by category
variablebooleanVariable fonts only
contextstringFilter by typography context
searchstringFull-text search on name and tags
curl "https://fetchtype.dev/api/v1/fonts?category=sans-serif&variable=true&limit=5"
GET /api/v1/fonts/:id

Get a single font entry with full metadata, metrics, and fallback CSS.

curl "https://fetchtype.dev/api/v1/fonts/inter"
GET /api/v1/fonts/:id/pairings

Get pairing recommendations with confidence scores and role assignments (heading/body).

curl "https://fetchtype.dev/api/v1/fonts/inter/pairings"

v2 — Batch, Compare & Stack

Agent-optimised endpoints for multi-font queries, side-by-side comparison, and complete stack recommendations. CORS enabled.

POST /api/v2/fonts/batch

Resolve up to 50 fonts in a single request. Returns full registry entries for found IDs and a notFound list for missing ones.

curl -X POST "https://fetchtype.dev/api/v2/fonts/batch" \
  -H "Content-Type: application/json" \
  -d '{"fontIds":["inter","roboto","playfair-display"]}'
GET /api/v2/fonts/compare?fonts=

Side-by-side comparison of up to 10 fonts. Returns metrics, performance, context scores, and pairing counts aligned by font ID.

Param Description
fontsComma-separated font IDs (max 10)
curl "https://fetchtype.dev/api/v2/fonts/compare?fonts=inter,roboto,open-sans"
GET /api/v2/fonts/stack?context=&budget=

Recommended primary + body + mono font stack for a given typographic context, with budget checking and pairing rationale.

Param Values Description
contextdisplay | interface | reading | monoTypographic context (default: interface)
budgetnumberMax total payload in KB (default: 150)
curl "https://fetchtype.dev/api/v2/fonts/stack?context=interface&budget=120"