Client recipes
OpenCode with Stable Baseline.
Connect OpenCode to Stable Baseline and get your entire codebase documented — architecture, schemas, security, business context — in one prompt.
Quickest path · Have OpenCode do it
Already running OpenCode in this repo? Paste the prompt below. OpenCode runs the device-code signup against Stable Baseline's anonymous-callable REST endpoint, shows you a 6-character code to authorise in your browser, then writes opencode.json with the resulting API key.
One block, paste-and-go
I want to onboard to Stable Baseline using its agent-driven signup. Walk me through end-to-end without stopping in between.
1. POST https://api.stablebaseline.io/functions/v1/cloud-serve/api/v1/tools/startSignup
Body: {"agent_label": "OpenCode", "intent": "mcp_setup"}
Response: {user_code, verification_url, device_code, poll_interval_seconds, ...}
Show me user_code and verification_url. Tell me to open the URL, sign in or sign up, paste the code, click Authorize.
2. Every 5 seconds, POST https://api.stablebaseline.io/functions/v1/cloud-serve/api/v1/tools/pollSignupStatus
Body: {"device_code": "<from step 1>"}
Stop when status is "authorized" — response includes api_key (starts with sta_). If denied or expired, tell me and stop.
3. Write opencode.json in the project root (or merge into the existing one):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sb": {
"type": "remote",
"url": "https://api.stablebaseline.io/functions/v1/cloud-serve/mcp",
"headers": {"Authorization": "Bearer <YOUR_KEY>"}
}
}
}
4. Tell me to restart OpenCode so it picks up the new MCP server. Then ask what I want to do next.Already have a key? Skip below
opencode.json by hand.Step 1 · Add the MCP server
Create or edit opencode.json in your project root. Two shapes are supported — pick whichever suits your auth model.
Using an API key (recommended)
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sb": {
"type": "remote",
"url": "https://api.stablebaseline.io/functions/v1/cloud-serve/mcp",
"headers": {
"Authorization": "Bearer {env:STABLE_BASELINE_API_KEY}"
}
}
}
}Set your API key as an environment variable or in a .env file:
STABLE_BASELINE_API_KEY=sta_your_api_key_here
Don't have an API key yet?
Using OAuth 2.1 (alternative)
If your organisation uses OAuth, OpenCode supports the MCP Authorization spec with automatic OAuth discovery:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sb": {
"type": "remote",
"url": "https://api.stablebaseline.io/functions/v1/cloud-serve/mcp",
"enabled": true,
"oauth": {}
}
}
}OpenCode discovers the OAuth endpoints automatically via the Protected Resource Metadata spec (RFC 9728). On first use, it detects the 401 response and initiates the OAuth flow in your browser — no manual configuration required.
You can also manage OAuth sessions from the CLI:
opencode mcp auth sb # Authenticate opencode mcp list # Check connection status opencode mcp logout sb # Sign out
Project vs global config
| Scope | File location | When to use |
|---|---|---|
| Project (recommended) | opencode.json in project root | Team repos — commit to git, everyone gets it |
| Global | ~/.config/opencode/opencode.json | Personal setup across all projects |
We recommend project-level config so every teammate picks up Stable Baseline automatically when they clone the repo.
Step 2 · Run setup
Open OpenCode in your terminal and run the slash command. That's it — the agent handles everything from here.
/sb:sb-setup:mcp
What sb-setup does, in order
- Verifies the MCP connection — If it can't connect, it tells you exactly what to fix and waits for you to say “continue”
- Resolves your workspace & project — If you have multiple, it asks you to pick. If none, it links you to app.stablebaseline.io to create them and waits for you
- Creates
.sb/config.json— Caches your workspace and project IDs locally - Checks for existing documentation — If the project already has docs, it shows you what's there and asks whether to augment, replace, or cancel
- Analyses your repository — Tech stack, architecture, directory structure, dependencies, security model, infrastructure, domain context
- Designs a bespoke documentation structure — No fixed template. Tailored to your repo's natural boundaries — by service, by domain, by layer, whatever fits
- Creates the documentation in Stable Baseline — Real content with diagrams, not stubs
- Generates
AGENTS.md— A cross-IDE auto-sync rule file at your repo root - Provides a summary — Tree view of everything created, with next steps
If anything goes wrong at the connection or workspace steps, the agent stops, tells you exactly what to do, and waits for you to type continue after you've fixed it. No need to start over.
What gets documented
The agent doesn't follow a checklist. It reads your code and documents what matters for this repo. Areas it considers:
- Technical standards & coding patterns — how code should be written in this stack
- Architectural patterns — system design, component relationships, data flows, API contracts
- Security patterns — auth flows, authorisation, data protection, secrets management
- Operational & maintenance — deployment, monitoring, incident response, runbooks
- Compliance & governance — regulatory requirements, audit trails, data retention
- Business context — business rules, domain models, stakeholder requirements
- Drift prevention — the “why” behind decisions so future developers don't deviate
How auto-sync works
The AGENTS.md file generated in step 2 contains a table mapping your repo's file patterns to Stable Baseline documents:
| File pattern | Documentation impact | Action |
|---|---|---|
src/auth/** | Authentication & Authorization doc | editDocument |
migrations/** | Data Model doc | editDocument |
docker-compose.yml, Dockerfile* | Deployment & Infrastructure doc | editDocument |
openapi.yaml, src/routes/** | API Reference doc | editDocument |
These patterns are specific to your repo. When OpenCode's agent changes files matching a pattern, it knows which Stable Baseline document to update — and does so automatically via the MCP tools.
AGENTS.md is cross-IDE
AGENTS.md is the Linux Foundation / Agentic AI Foundation standard. It works in OpenCode, Cursor, VS Code Copilot, Claude Code, Windsurf, Zed, Warp, Roo Code, Aider, and 15+ other tools. Switch IDEs and the auto-sync rules follow.File structure
your-project/ ├── opencode.json # MCP server config (Step 1) ├── .sb/ │ └── config.json # Project IDs (auto-generated) ├── AGENTS.md # Cross-IDE auto-sync rules (auto-generated) └── ...
All files are safe to commit to git. When using an API key with {env:STABLE_BASELINE_API_KEY}, the key stays in your environment — not in the config file. Or use OAuth to avoid secrets entirely. Add .sb/ to .gitignore if you prefer to keep IDs local.
Try it
Your baseline docs are ready. Here are prompts worth pasting next:
“Generate an ERD diagram from my database schema and add it to my docs.”
“Create a sequence diagram for the authentication flow.”
“Summarise the key design decisions in this repo and document them.”
“Add a deployment architecture diagram to my infrastructure doc.”
“What documentation is out of date after the changes I just made?”
Regenerate documentation
Need to start fresh? Tell OpenCode:
Delete all existing folders and documents in my Stable Baseline project, then re-run the /sb:sb-setup:mcp command to regenerate everything from scratch.
Destructive action