Build with an agent
Give Claude Code, Codex or another coding agent these docs and a prompt that adds Undertext to your app.
These docs are written to be read by coding agents as well as people. Every page is plain Markdown at its own address plus .md, and the whole set is gathered in one file agents can fetch in one go.
| File | What's in it |
|---|---|
/llms.txt | The map: what Undertext is, and every page with what it covers |
/llms-full.txt | Every page, in full |
/<page>.md | One page, e.g. /quickstart.md |
Each page also has a Copy Markdown button under its title, for pasting one page into a chat, and an Open menu with the page as Markdown and links that hand it to ChatGPT, Claude and other assistants.
A prompt that adds Undertext to your app
Paste this into Claude Code, Codex or your agent of choice from the root of your project. Put your development platform's key in your environment first, so the agent never needs to see it.
Add the Undertext editor to this app using the Undertext API.
Read https://docs.undertext.sh/llms-full.txt first. Then:
1. Install @undertext/sdk (server) and @undertext/embed (browser).
2. Keep every Undertext call on the server, with the key from UNDERTEXT_SECRET_KEY.
Never send the key to the browser.
3. Add an undertext_user_id column to our users. When a user signs up or changes
their name or picture, PUT them to /v1/users/external/{our user id} and
store the Undertext id it returns.
4. Store an Undertext document id beside each of our documents. Create the Undertext
document when ours is created, with our user's Undertext id as owner.
5. Add a POST route that checks our own session and permissions, then creates
an Undertext editor session for that user and document and returns the token.
6. Mount the editor where we show a document, with getToken calling that route.
7. Add a webhook route that verifies the Undertext-Signature header and logs events.
Use our existing auth, routing and styles. Show me the plan before writing code.Adjust step 4 to how your app stores documents. If your app already has sharing, ask the agent to mirror it into members as well.
Keep the docs in reach
Add a line to the instructions file your agent reads (CLAUDE.md, AGENTS.md or similar), so it checks the docs instead of guessing:
## Undertext
We embed the Undertext editor. Before changing anything that calls the Undertext API,
read the relevant page from https://docs.undertext.sh/llms.txt (each page is also at
its path plus .md). Use a platform of its own for development; never log or expose UNDERTEXT_SECRET_KEY.Things agents tend to get wrong
- Calling Undertext from the browser. Everything but the editor itself goes through your server. The browser only gets editor session tokens.
- Treating Undertext as the account system. Undertext has no sign-in. Your session check comes first, then the Undertext call.
- Passing your own ids where Undertext ids go. Your id for a user goes in one place,
PUT /v1/users/external/{external_id}. Everything else takes the Undertext id (usr_…) that call returns, so store it beside your user. - Skipping signature checks on webhooks. Verify
Undertext-Signaturebefore trusting an event. The Node SDK'sundertext.webhooks.verifydoes it in one call. - Mixing up the two MCP servers. Your users' agents connect to
mcp.undertext.sh/<your slug>to work in documents. That is a feature for your users, not a tool for building your app.