Workflows

OpenCode

Connect OpenCode to Stable Baseline and get your entire codebase documented — architecture, schemas, security, business context — in one prompt.

What You'll Get

MCP Tools

Full access to Stable Baseline from OpenCode: create documents, insert diagrams, manage projects.

Bespoke Documentation

Not a template. The agent analyzes YOUR repo and creates a documentation structure tailored to your tech stack, architecture, and domain.

AGENTS.md

A cross-IDE auto-sync rule file at your repo root. Works in OpenCode, Cursor, VS Code, Claude Code, Windsurf, Zed, Warp, and 15+ other tools. Keeps docs in sync whenever you make architectural changes.

Project Config

A .sb/config.json that caches project IDs so your agent skips discovery calls.

Total setup time: ~2 minutes to connect, then the agent does the rest.

Step 1: Add the MCP Server

Add the Stable Baseline MCP server to OpenCode. Create or edit the opencode.json file:

Using an API Key (recommended)

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "stablebaseline-mcp": {
      "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? Go to your Stable Baseline organization → Settings → MCP Setup → API Keys and create one. Full setup guide →

Using OAuth 2.1 (alternative)

If your organization uses OAuth, OpenCode supports the MCP Authorization spec with automatic OAuth discovery:

opencode.json (OAuth)
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "stablebaseline-mcp": {
      "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 stablebaseline-mcp # Authenticate
opencode mcp list # Check connection status
opencode mcp logout stablebaseline-mcp # Sign out

Project vs Global Config

ScopeFile LocationWhen to Use
Projectopencode.json in project rootTeam repos — commit to git, everyone gets it
Global~/.config/opencode/opencode.jsonPersonal setup across all projects

We recommend project-level config so every team member gets Stable Baseline automatically when they clone the repo.

Step 2: Run Setup

Open OpenCode in your terminal and run the slash command /stablebaseline-mcp:sb-setup:mcp. That's it — the agent handles everything from here.

Type into OpenCode
/stablebaseline-mcp:sb-setup:mcp

What it does (in order):

  1. Verifies the MCP connection — If it can't connect, it tells you exactly what to fix and waits for you to say "continue"
  2. Resolves your workspace & project — If you have multiple, it asks you to pick. If you have none, it links you to app.stablebaseline.io to create them and waits for you
  3. Creates .sb/config.json — Caches your workspace and project IDs locally
  4. Checks for existing documentation — If the project already has docs (e.g. created manually in the app), it shows you what's there and asks whether to augment (fill gaps), replace (start fresh), or cancel
  5. Analyzes your repository — Tech stack, architecture, directory structure, dependencies, security model, infrastructure, domain context, and more
  6. Designs a bespoke documentation structure — No fixed template. The structure is tailored to YOUR repo's natural boundaries — by service, by domain, by layer, whatever fits
  7. Creates the documentation in Stable Baseline — Real content with diagrams, not stubs. A developer joining tomorrow should be able to read these docs and understand the system
  8. Generates AGENTS.md — A cross-IDE auto-sync rule file at your repo root with file-pattern-to-document mappings specific to your codebase
  9. Provides a summary — Everything it created, with a tree view and next steps

If anything goes wrong at steps 1 or 2 (connection issues, missing workspace/project), the agent stops, tells you exactly what to do, and waits for you to type continue after you've fixed it. If the project already has documentation (step 4), the agent shows you what exists and lets you choose how to proceed — no surprise overwrites. 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, authorization, 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

Technical and business documentation sit side by side — consistent and driving outcomes from each other.

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 PatternDocumentation ImpactAction
src/auth/**Authentication & Authorization doceditDocument
migrations/**Data Model doceditDocument
docker-compose.yml, Dockerfile*Deployment & Infrastructure doceditDocument
openapi.yaml, src/routes/**API Reference doceditDocument

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 using the MCP tools.

AGENTS.md is the cross-IDE standard (Linux Foundation / Agentic AI Foundation). 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

After setup, your project root will have:

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 some prompts to try next:

"Generate an ERD diagram from my database schema and add it to my docs."

"Create a sequence diagram for the authentication flow."

"Summarize 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:

Type into OpenCode
Delete all existing folders and documents in my Stable Baseline project,
then re-run the /stablebaseline-mcp:sb-setup:mcp command to regenerate everything from scratch.

⚠️ Destructive action: This deletes all existing documents and folders in your Stable Baseline project. Document version history will be lost.