5 min read
Getting started with full pipeline mode
No existing SDK generator? Full pipeline mode generates TypeScript, Python, and Go SDKs, an MCP server, API documentation, and an OpenAPI spec on every passing sync — all from a single stateanchor.yaml.
What you need
- A GitHub repo (public or private)
- A running API with at least one endpoint
- A StateAnchor account
Step 1: Describe your API
Create stateanchor.yaml in your repo root. List every endpoint you want to generate SDKs for. Be specific about request bodies and auth. Set docs: true and openapi: true to enable documentation and OpenAPI spec generation.
service: my-api
version: "1.0.0"
server:
base_url: https://api.myapp.com
auth:
type: bearer
endpoints:
- name: listItems
method: GET
path: /items
description: List all items for the authenticated user
- name: createItem
method: POST
path: /items
description: Create a new item
body:
name: string
category: string
- name: getItem
method: GET
path: /items/{id}
description: Get a single item by ID
- name: deleteItem
method: DELETE
path: /items/{id}
description: Delete an item
outputs:
languages:
- typescript
- python
- go
mcp: true
docs: true
openapi: trueStep 2: Connect the repo
Go to stateanchor.dev/connect. Authorize GitHub access and select your repo.
Step 3: Push
git add stateanchor.yaml git commit -m "feat: add stateanchor spec" git push origin main
What happens next
- StateAnchor parses
stateanchor.yamland builds a canonical intermediate representation (IR). - The gate engine scores the change. First push is always score 0 (additive).
- TypeScript, Python, and Go SDKs are generated with full types, async support, and error handling.
- An MCP server is generated for AI agent integration.
- API documentation is generated and hosted.
- An OpenAPI spec is generated and exported.
- All artifacts are content-addressed and bound to the exact commit SHA.
Step 4: Use the SDK
import { MyApiClient } from "./generated/typescript-sdk";
const client = new MyApiClient({
baseUrl: "https://api.myapp.com",
token: process.env.API_TOKEN,
});
const items = await client.listItems();
const newItem = await client.createItem({
name: "Widget",
category: "hardware",
});Step 5: Protect against drift
Every subsequent push to stateanchor.yaml triggers a diff against the previous state. Breaking changes (removed endpoints, changed types, narrowed contracts) are scored and blocked.
Add the GitHub Action to enforce this on PRs:
# .github/workflows/stateanchor.yml
name: StateAnchor Sync
on:
push:
branches: [main]
pull_request:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: stateanchor/sync-action@v1
with:
api-key: ${{ secrets.STATEANCHOR_API_KEY }}