DocsAdvanced usage

Advanced usage

Use this guide for scripts, catalog downloads, repository actions, and hosting the full website or API yourself. For everyday extraction, use the website or install the standalone skill in your coding agent.

The skill runs locally and can use your agent’s model for enrichment. It needs no Docker, database, or AI API key. Use the website or install the skill.

Hosted key policy
No user keys

Deterministic extraction does not call an LLM and does not need an Anthropic key.

HTTP extraction can return JSON, raw design.md Markdown, or deterministic MDX.

Hosted AI enrichment uses purchased AI runs and the deployment's server key.

The hosted service does not accept or store user Anthropic keys.

Use your own Anthropic key only in a local checkout or self-hosted deployment via ANTHROPIC_API_KEY.

API surface

What the hosted API does

The hosted API exposes keyless extraction and AI-run-backed routes. It does not accept user Anthropic keys in headers, bodies, or stored browser settings.

GET

/api/extract?url=...&format=json|markdown|mdx

No Anthropic key

Loads the URL in headless Chromium. Return JSON for the full payload, raw Markdown for design.md, or MDX for an export-ready docs artifact.

POST

/api/enrich-design-md

Hosted AI runs

Streams an AI-enriched design.md as Server-Sent Events. Hosted Free design.md uses its own server key and purchased AI runs; it rejects user-supplied Anthropic keys.

POST

/api/iterate-design-md

Hosted AI runs

Streams a revised design.md from previousMarkdown and userPrompt. The hosted route uses purchased AI runs, not user Anthropic keys.

GET

/api/catalog-designs

Public catalog

Lists curated downloadable design.md artifacts by slug, title, URL, category, description, and best-use text. The CLI uses this for `free-design-md list`.

GET

/api/metrics

Prometheus

Exposes low-cardinality counters and histograms for extraction, AI enrichment, AI iteration, quota outcomes, and artifact exports.

HTTP

Hosted extraction is keyless

Use the hosted API for deterministic design.md extraction. The same endpoint can return structured JSON, raw Markdown, or MDX. Hosted AI routes are available through the web app's signed-in AI-run balance, not by sending your Anthropic key to Free design.md.

JSON

format=json

Use this when another tool needs the complete extraction payload: design.md text, token tree, page signals, and screenshot data URL.

Markdown

format=markdown, format=md, or omit format

Use this when you only want the portable design.md document as text. The response content type is text/markdown.

MDX

format=mdx

Use this when a docs site wants an .mdx export with metadata, the designMd string, previewHtml, and a TokenPreview component.

# Hosted deterministic extraction: no Anthropic key required.
curl "https://freedesign.md/api/extract?url=https://stripe.com&format=json" \
  -o extract.json

# Raw design.md Markdown. You can also omit format or use format=md.
curl "https://freedesign.md/api/extract?url=https://stripe.com&format=markdown" \
  -o design.md

# Export-ready MDX with designMd, previewHtml, and a TokenPreview component.
curl "https://freedesign.md/api/extract?url=https://stripe.com&format=mdx" \
  -o design.mdx

Catalog CLI

Download existing designs with npm

The free-design-md npm package lists curated designs, filters by category or search text, and downloads a chosen artifact into your project. Use the skill or HTTP API when you want to extract a fresh URL.

View the public catalog repo

List the catalog

Grouped terminal output shows the slug, title, source URL, and best-fit usage for each curated artifact.

Download by slug

Use the slug from the list with add to write the enriched design.md file into your repo.

# Browse every curated design.md available for download.
npx free-design-md list

# Filter the catalog.
npx free-design-md list --category "Developer Tools & IDEs"
npx free-design-md list --search stripe

# Use JSON when another agent or script needs the catalog.
npx free-design-md list --json

# Download a curated design.md by slug.
npx free-design-md add stripe --out specs/stripe.design.md

Repository actions

Run the extractor from a checkout

These commands require this repository and its dependencies. Use pnpm --silent when saving or piping JSON so the package manager’s banner stays out of the result. Extraction needs no AI key; local enrichment reads ANTHROPIC_API_KEY from your environment.

Extraction

Calls Playwright and returns deterministic JSON. No LLM and no key.

Enrichment

Calls Anthropic with the extraction payload and returns the final enriched design.md.

# Requires Node.js 22.12 and pnpm. Clone and install first.
git clone https://github.com/zuchka/free-design-md.git
cd free-design-md
pnpm install --frozen-lockfile
pnpm exec playwright install chromium

# Deterministic extraction from the checkout.
pnpm --silent action extract-design-md --url stripe.com > extract.json

# The action returns JSON. Save only the design.md text with jq.
pnpm --silent action extract-design-md --url stripe.com | jq -r '.markdown' > design.md

# For AI enrichment, load ANTHROPIC_API_KEY into your local environment first.
pnpm --silent action enrich-design-md \
  --url stripe.com \
  --designSystemData '<json from extract>' \
  --signals '<json from extract>' \
  --screenshotDataUrl '<data URL from extract>' \
  --deterministicMarkdown '<markdown from extract>'

Optional self-hosting

Run the full website and API with Docker

Self-hosting runs the complete application and requires PostgreSQL and auth configuration. For extraction inside your coding agent, use the standalone skill. The public image includes Linux amd64 and arm64 builds.

View the GHCR package

Before starting, apply the repository’s SQL migrations in filename order to a dedicated database. The migrations expect the anon and authenticated roles, which Supabase provides. Create those roles first when using plain PostgreSQL, and grant your runtime login membership in free_design_app. Use a TLS-enabled connection for a database on a remote host.

Public GHCR image

Install from ghcr.io/zuchka/free-design-md:latest without cloning the repository.

External Postgres

Set DATABASE_URL to a migrated PostgreSQL database. Startup never applies migrations. Set a persistent BETTER_AUTH_SECRET and the public origin too.

# First set DATABASE_URL to a PostgreSQL database with the app migrations applied.
# Generate this secret once and reuse it across restarts.
export BETTER_AUTH_SECRET="$(openssl rand -hex 32)"
export PUBLIC_ORIGIN="http://localhost:3000"
export BETTER_AUTH_URL="$PUBLIC_ORIGIN"

# Optional: set ANTHROPIC_API_KEY for self-hosted AI enrichment.
docker pull ghcr.io/zuchka/free-design-md:latest
docker run --rm \
  -p 127.0.0.1:3000:3000 \
  -e FREE_DESIGN_MD_SELF_HOSTED=1 \
  -e DATABASE_URL \
  -e BETTER_AUTH_SECRET \
  -e BETTER_AUTH_URL \
  -e PUBLIC_ORIGIN \
  -e ANTHROPIC_API_KEY \
  ghcr.io/zuchka/free-design-md:latest

Open http://localhost:3000 after startup. For a hosted deployment, set both origin variables to its public URL and configure your network access. Deterministic extraction works without an AI key; AI enrichment requires ANTHROPIC_API_KEY in the container environment. Self-hosted AI uses that key without spending hosted AI runs.

# Optional: build locally from a repository checkout.
docker build -t free-design-md:local .

The Dockerfile also builds our production deployment. Build locally when developing from a checkout or testing unreleased changes.

Observability

Scrape Prometheus metrics

Free design.md exposes persistent event counters, billing totals, and process-local duration histograms. Metrics use bounded labels: route, status, key source, credit outcome, pack, and artifact format. They never include URLs, prompts, user IDs, org names, saved design IDs, or API keys.

Request counters

Track free extraction, paid and self-hosted AI requests, fulfilled credit packs, and reserved, committed, refunded, or rejected credits.

Duration histograms

Measure extraction and AI stream latency with Prometheus histogram buckets.

# Optional endpoint protection.
PROMETHEUS_METRICS_TOKEN=replace-with-a-long-random-token

# Prometheus scrape config.
scrape_configs:
  - job_name: free-design-md
    metrics_path: /api/metrics
    authorization:
      type: Bearer
      credentials: replace-with-a-long-random-token
    static_configs:
      - targets:
          - freedesign.md

Hosted production /api/metrics requires PROMETHEUS_METRICS_TOKEN and either an Authorization: Bearer token or an x-prometheus-token header. Self-hosted instances can opt in to this protection. The aggregate extraction-health summary stays public; recent request URLs always require a token. Database snapshots refresh every two minutes, while latency histograms remain live. If you run multiple app processes, scrape each process for latency histograms. Database-backed counters and billing totals are shared; scrape one replica or deduplicate those series before aggregating.

FAQ

API and CLI questions

Short answers for developers using Free design.md in scripts, agents, CI jobs, and local tooling.

Do I need Docker to use the agent skill?

No. The standalone skill needs Node.js and installs its own extraction dependencies and Chromium. It needs no app server, database, or AI API key; optional enrichment uses your coding agent’s model.

Can I use Free design.md without the browser UI?

Yes. Install the standalone extract-design-md skill in your coding agent, use GET /api/extract, or run the repository actions from a local checkout.

Can I browse curated design.md files from the CLI?

Yes. Run npx free-design-md list to see every curated artifact, then npx free-design-md add <slug> to download one.

Can the extract API return JSON, Markdown, or MDX?

Yes. Set format=json for the full payload, format=markdown or format=md for raw design.md Markdown, or format=mdx for an export-ready MDX artifact. Omitting format returns Markdown.

Does basic design.md extraction require an API key?

No. The deterministic extractor does not use AI, so it does not require an Anthropic key.

How do I use my own Anthropic key?

Run Free design.md locally or in your own self-hosted deployment and set ANTHROPIC_API_KEY in that environment.

Can I send my Anthropic key to the hosted API?

No. The hosted API rejects user-supplied Anthropic keys. Hosted AI uses purchased AI runs.

Does the npm CLI extract a new URL?

The free-design-md npm package browses and downloads the curated catalog. Use the standalone skill, HTTP API, or repository actions to extract a fresh URL.

How do I download, install, and run Free design.md with Docker?

Prepare a migrated PostgreSQL database, set DATABASE_URL, BETTER_AUTH_SECRET, BETTER_AUTH_URL, and PUBLIC_ORIGIN, then run the image with FREE_DESIGN_MD_SELF_HOSTED=1. ANTHROPIC_API_KEY is only needed for AI enrichment.

Which operating systems can run the Docker image?

The public image is published for Linux amd64 and arm64. Docker pulls the matching image on Docker Desktop for macOS and Windows and Docker Engine on Linux.

The hosted service does not accept your Anthropic key.

Hosted AI uses purchased AI runs. Local and self-hosted runtimes use your own environment, where your key stays under your control.

Read about design.md