Getting Started
Contentrain AI is an open-source, repo-native content governance stack. Your AI agent creates, extracts, and updates content through Model Context Protocol (MCP) tools, while Contentrain ensures that content is structured, validated, reviewed, and deliverable to any platform.
Prerequisites
- Node.js 22+
- Git
- An MCP-compatible AI agent (Claude Code, Cursor, Windsurf, or similar)
Choose Your Path
# This is the main wedge: rescue hardcoded strings
npx contentrain init
# Then tell your agent: "Scan my project and extract all hardcoded strings"# Start with structured content from day one
npx contentrain initQuick Start: Existing Project
Already have hardcoded strings scattered across your codebase? Start here.
npx contentrain init
npx contentrain serve --stdioThen tell your agent:
Scan my project and extract all hardcoded UI strings into structured content.Typical outcome:
Agent scans 47 files → finds 523 strings → classifies → creates models → writes content → proposes source patchesReview the extracted content and branch diffs locally, then continue with the full Normalize Flow.
Quick Start: New Project
1. Initialize
npx contentrain initThis creates .contentrain/ in your project root with configuration, model definitions, and content directories. If the directory is not a git repo, it runs git init automatically.
2. Connect your AI agent
Add the Contentrain MCP server to your IDE:
{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}{
"mcpServers": {
"contentrain": {
"command": "npx",
"args": ["contentrain", "serve", "--stdio"]
}
}
}3. Create a content model
Tell your agent:
Create a hero section model with title, subtitle, and CTA fieldsThe agent calls contentrain_model_save and creates:
.contentrain/
models/hero-section.json
content/marketing/hero-section/en.json4. Add content
Add content to the hero section: title is "Build faster with AI",
subtitle is "Content governance for any platform"5. Use your content
The content is plain JSON — you can read it directly from any language or platform:
{
"title": "Build faster with AI",
"subtitle": "Content governance for any platform"
}For TypeScript projects, generate a typed SDK client for convenience:
npx contentrain generateimport { singleton } from '#contentrain'
const hero = singleton('hero-section').locale('en').get()
console.log(hero.title) // "Build faster with AI"SDK is optional
The generated TypeScript SDK provides type-safe queries, but the content files are plain JSON and Markdown. Any platform that reads JSON — Go, Python, Swift, Kotlin, Rust — can consume your content directly.
6. Review with the local UI
npx contentrain serveOpen http://localhost:3333 to browse models, content, validation results, and pending branches.
Team Workflows
When the local CLI and MCP flow are not enough, Contentrain Studio adds the team web layer:
- workspace and project management
- role-based access and review responsibilities
- chat-first content operations
- branch and diff review
- media management
- CDN delivery for non-web platforms
Connect your local project to Studio with two commands:
contentrain studio login
contentrain studio connectThe connect command detects your git remote, verifies GitHub App installation, scans for .contentrain/ configuration, and creates the project — all in one interactive flow. See CLI Studio Integration for details.
The Content Pipeline
Every operation follows the same governance pipeline:
Agent generates → MCP validates → Human reviews → Git commits → Content delivered- Agent decides what to create (your AI, your choice — BYOA)
- MCP enforces structure, validation, and canonical serialization
- Human reviews and approves through the local UI or Studio
- Git stores everything — full history, rollback, audit trail
- Content is delivered as plain JSON/Markdown to any platform
Packages
All packages are published on npm:
| Package | Description | Install |
|---|---|---|
contentrain | CLI (init, serve, generate, validate) | npx contentrain init |
@contentrain/mcp | 15 MCP tools for AI agents | pnpm add @contentrain/mcp |
@contentrain/query | TypeScript query SDK (optional) | pnpm add @contentrain/query |
@contentrain/types | Shared TypeScript types | pnpm add @contentrain/types |
@contentrain/rules | AI agent quality rules | pnpm add @contentrain/rules |
@contentrain/skills | AI agent workflow procedures | pnpm add @contentrain/skills |
Starter Templates
Want to skip setup? Start from a production-ready template with content models, SDK client, and framework patterns pre-configured:
| Template | Framework | Use Case |
|---|---|---|
| astro-blog | Astro | Blog / editorial |
| astro-landing | Astro | Landing page |
| next-commerce | Next.js | E-commerce |
| next-saas-dashboard | Next.js | SaaS dashboard |
| nuxt-saas | Nuxt | SaaS marketing |
| sveltekit-editorial | SvelteKit | Editorial |
| vitepress-docs | VitePress | Documentation |
See all 10 templates on GitHub
What's Next?
- Core Concepts — Models, content kinds, domains, and the governance architecture
- Ecosystem Map — How AI packages and Studio fit together
- MCP Tools — All 15 tools available to your agent
- Normalize Flow — Extract hardcoded strings from existing code
- i18n Workflow — Add languages to your content
- Framework Integration — Platform-specific setup patterns
Contentrain Studio
Contentrain Studio is the open-core team operations surface for Git-native structured content. Teams can self-host the AGPL core or use a managed Pro/Enterprise offering when they want web-based collaboration, review, media, and CDN delivery on top of the same content model.