CLI-doc #7427
sebschopf
started this conversation in
Documentation
CLI-doc
#7427
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
How to give LLMs the full SurrealDB documentation — a build script + CLI
TL;DR: The SurrealDB docs repo contains 1 096
.mdxpages — everything an AIagent needs to write correct SurrealQL. I wrote two small shell scripts: one that
clones the official
surrealdb/docs.surrealdb.comrepo and converts those pagesto clean markdown, and a lightweight CLI that navigates them with minimal token
waste. If you have a better way, I'll happily drop mine.
Table of contents
surreal-docs)The problem
LLMs routinely produce incorrect SurrealQL because they guess from outdated or
fragmented training data. The
surrealdb/agent-skillsrepo is a great startingpoint, but it doesn't cover every statement, every function, every CLI flag.
Meanwhile, the SurrealDB documentation website (Astro + MDX) contains all the
answers — but it's not directly consumable by an agent: the pages have JSX
components (
<Tabs>,<RailroadDiagram>), Astro frontmatter, and a site-specificfolder structure.
The build script
build-surrealdb-docs.sh(gist):surrealdb/docs.surrealdb.com(shallow, blobless — fast and light)..mdxfile undersrc/content/to plain.md:titleanddescriptionfrom the frontmatter.index.jsontree of all 1 096 pages.The output lands in
~/.cache/surrealdb-docs/— about 8.5 MB of clean markdown.The CLI (
surreal-docs)After the build, the agent has 8.5 MB of markdown. The naive approach — dump a
whole page to stdout — burns hundreds of tokens on content it may not need.
surreal-docssolves this: it resolves a topic to a file path (~3 tokens), then the agent
decides whether to read a summary or the full page.
Five modes, each for a specific agent workflow:
surreal-docs selectread_filesurreal-docs --search HNSWsurreal-docs --summary indexessurreal-docs --list statementssurreal-docs --show indexesResolution is case-insensitive and matches partial names:
surreal-docs indexesfinds
define/indexes.mdautomatically.Known limitation: the docs cache is a static snapshot. There is no auto-update
mechanism — you must re-run
build-surrealdb-docs.sh --updatemanually to pull thelatest documentation. We did not build a scheduled refresh or a background watcher.
Integration with agent-skills
I keep the official
surrealdb/agent-skillsloaded as always-on "skills" (theycover the 80 % use-case), and fall back to the cached markdown tree when the
agent needs the full reference. The two layers work together:
Two scripts, one workflow
build-surrealdb-docs.shsurreal-docsRun both once, then the agent has the entire SurrealDB documentation available
on-demand, without wasting context tokens on pages it doesn't need.
Why this matters
I'm building a VTT (Virtual Tabletop) on top of SurrealDB with an AI coding
agent. Every wrong query costs me real debugging time. Having the entire
documentation available to the agent without guessing is a game-changer.
Every coding agent (Cline, Claude Code, Copilot, Cursor) faces the same
constraint: a finite context window. Throwing 8.5 MB of documentation at it
at once is impossible. But letting it navigate that documentation —
resolving topics to paths, reading only what's relevant — makes the entire
knowledge base usable, one page at a time.
If the SurrealDB team could ship an official markdown export (or even an
llms.txt/docs.jsonendpoint), this whole workflow would be trivial foreveryone. Until then, 150 lines of bash do the job.
All reactions