> ## Documentation Index
> Fetch the complete documentation index at: https://goldrush.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CLAUDE

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

GoldRush API documentation site built with **Mintlify**. Content is authored in MDX (Markdown + JSX). The site documents multiple products: Foundational API (REST), Streaming API (GraphQL/WebSockets), CLI, x402 protocol, and MCP Server.

## Commands

| Task                    | Command                                                |
| ----------------------- | ------------------------------------------------------ |
| Local dev server        | `npm run dev` (runs `mintlify dev` on localhost:3000)  |
| Run generation pipeline | `npm run generate` (interactive TUI to select scripts) |
| Populate changelog      | `npm run script:populate-changelog`                    |
| Check nav consistency   | `node s/check-nav-consistency.js`                      |
| Install dependencies    | `yarn install`                                         |

## Content Architecture

### Hand-authored vs Generated content

**Hand-authored** (safe to edit directly):

* `goldrush-foundational-api/` - API overview, quickstart, authentication
* `goldrush-streaming-api/` - Streaming API guides (except `decoded-events.mdx` and `graphql-endpoints.mdx` which are auto-generated)
* `goldrush-cli/` - CLI documentation
* `goldrush-x402/` - x402 protocol docs
* `resources/` - Feature-specific guides
* `overview.mdx`, `faq.mdx`, `error-handling.mdx`, root-level pages
* `snippets/` - Reusable MDX components (some are generated, see below)

**Auto-generated** (do NOT edit directly - regenerate instead):

* `api-reference/foundational-api/**/*.mdx` - from OpenAPI + DatoCMS metadata
* `api-reference/streaming-api/subscriptions/*.mdx` & `queries/*.mdx` - from YAML overlay + GraphQL introspection + DatoCMS metadata
* `api-reference/streaming-api/types/*.mdx` - from GraphQL introspection (Object Types, Enums, Interfaces)
* `api-reference/openapi.json` - compiled OpenAPI spec
* `chains/*.mdx` (except `chains/overview.mdx`) - from DatoCMS chain data
* `changelog/*.mdx` - from DatoCMS
* `snippets/supported-chains-dexes.mdx` - from Streaming API query
* `snippets/latest-updates.mdx` - from DatoCMS (latest 3 changelog entries, rendered on `overview.mdx`)
* `llms.txt`, `llms-full.txt` - LLM context files
* `skills/*/references/*.md` - per-product skill reference files for AI agents
* `data/*.json` - intermediate data files

### Navigation

`docs.json` is the source of truth for site structure. Generation scripts read from and write to it. Keep it in sync with page files.

### Data Flow

```
Conjure YAML (api-defn/src/) → build-conjure → data/conjure-output.json
DatoCMS endpoints API        → get-apiendpoints → data/dato-apiendpoints.json
DatoCMS chains API           → get-chains.js → data/dato-chains.json
GraphQL introspection API    → fetch-streaming-schema.js → data/streaming-schema.json, data/streaming-chains-dexes.json

conjure-output + dato-apiendpoints + docs.json                      → convert-openapi.js → api-reference/foundational-api/**
dato-chains + dato-apiendpoints + docs.json                         → generate-chain-docs.js → chains/*.mdx
YAML overlay + introspection + chains-dexes + dato-apiendpoints + docs.json → convert-streaming.js → api-reference/streaming-api/**, snippets/supported-chains-dexes.mdx
```

### Generation Pipeline (9 steps, order matters)

1. `./s/build-conjure` - compile Conjure YAML schemas
2. `./s/get-apiendpoints` - fetch endpoint metadata from DatoCMS
3. `node ./s/get-chains.js` - fetch chain metadata from DatoCMS
4. `node ./s/convert-openapi.js` - generate Foundational API MDX pages
5. `node ./s/generate-chain-docs.js` - generate per-chain MDX pages
6. `node ./s/fetch-streaming-schema.js` - fetch GraphQL introspection schema and supported chains/DEXes (optional, committed for offline builds)
7. `node ./s/convert-streaming.js` - generate Streaming API endpoint pages, type pages, supported chains/DEXes snippet, and update `docs.json` Types nav
8. `node ./s/generate-llm-txt.js` - generate LLM context files and skills reference files
9. `node ./s/populate-changelog.js` - generate changelog (optional)

Steps 1-3 fetch external data; step 6 fetches the GraphQL schema and chains/DEXes; steps 4-5, 7-8 generate content. Use `npm run generate` for the interactive runner.

## MDX Conventions

Frontmatter format:

```yaml theme={null}
---
title: "Page Title"
sidebarTitle: "Nav Label"    # optional, shorter name for sidebar
description: "SEO description"
---
```

Common Mintlify components used: `<Card>`, `<CardGroup>`, `<CodeGroup>`, `<Accordion>`, `<AccordionGroup>`, `<Tip>`, `<Info>`, `<Warning>`, `<Note>`, `<Steps>`, `<Columns>`.

## Agent Skills (`skills/`)

Per-product reference files for AI agent consumption, generated by step 9 of the pipeline. Each product has a hand-authored `SKILL.md` routing index and auto-generated `references/*.md` files.

```
skills/
├── goldrush-foundational-api/   # REST API, 36 endpoints, 100+ chains
│   ├── SKILL.md                # Hand-authored routing index (do NOT regenerate)
│   └── references/              # Auto-generated (7 files)
├── goldrush-streaming-api/      # GraphQL/WebSocket, 8 endpoints, 10 chains
│   ├── SKILL.md
│   └── references/              # Auto-generated (3 files)
├── goldrush-x402/               # Pay-per-request proxy, 60+ endpoints
│   ├── SKILL.md
│   └── references/              # Auto-generated (3 files)
└── goldrush-cli/                # 17 CLI commands, MCP server
    ├── SKILL.md
    └── references/              # Auto-generated (1 file)
```

**SKILL.md** files are hand-crafted - edit them directly. **references/** files are auto-generated - regenerate with `node s/generate-llm-txt.js`.

Key conventions for skills content:

* SKILL.md must have YAML frontmatter with `name` and `description` fields (per agent skills spec)
* `description` is the primary trigger mechanism - include what the skill does, trigger contexts, and cross-routing to sibling skills
* SKILL.md body should stay generic (no hardcoded endpoint counts/chain lists); delegate specifics to auto-generated reference files
* Reference file tables use "When to read" column to guide the model
* Reference files must be self-contained: no links to repo MDX pages, only external URLs and `#section` anchors
* MDX imports and `[Read more]` links are stripped during generation; local links `[text](/path)` → `**text**` (bold)
* Foundational API reference files include structured parameter and response field tables extracted from the OpenAPI spec (`api-reference/openapi.json`)
* Content headings from source MDX files are bumped down one level in `formatEndpointSection()` to nest correctly under the endpoint H2

## Key Files

* `docs.json` - Mintlify site config and navigation tree
* `s/run.js` - TUI orchestrator for generation pipeline
* `s/convert-streaming.js` - generates Streaming API endpoint pages, type pages, and updates `docs.json`
* `s/lib/schema-utils.js` - GraphQL introspection parsing utilities (type resolution, field extraction, query generation)
* `s/generate-llm-txt.js` - generates `llms.txt`, `llms-full.txt`, and `skills/*/references/*.md`
* `s/sdk-methods-mapping.json` - maps TypeScript SDK methods to OpenAPI operations
* `api-defn/src/` - Conjure YAML schema definitions (base, balances, nft, transactions) and Streaming API overlay files (queries, subscriptions)
* `data/streaming-schema.json` - cached GraphQL introspection result (committed for offline builds)
* `data/` - intermediate JSON data files consumed by generation scripts
