CLI for Contentrain.
Start here:
contentrain is the local operations surface for a Contentrain project:
- initialize
.contentrain/in an existing repo - inspect project health and validation state
- generate the typed
#contentrainSDK client - review pending
contentrain/*branches - run the local review UI
- expose the MCP server over stdio for IDE agents
This package is the human-facing companion to:
@contentrain/mcpfor deterministic content operations@contentrain/queryfor generated runtime queries@contentrain/rulesand@contentrain/skillsfor agent guidance
Use npx:
npx contentrain initOr install globally:
pnpm add -g contentrain
contentrain statusRequirements:
- Node.js 22+
- Git available in
PATH
| Command | Purpose |
|---|---|
contentrain init |
Initialize .contentrain/, git workflow, templates, and IDE rules |
contentrain status |
Show project overview, models, branch pressure, and validation summary |
contentrain doctor |
Check setup health, SDK freshness, orphan content, and branch limits |
contentrain validate |
Validate content against schemas, optionally create review-branch fixes |
contentrain generate |
Generate .contentrain/client/ and #contentrain package imports |
contentrain diff |
Review and merge or reject pending contentrain/* branches |
contentrain serve |
Start the local review UI or the MCP stdio server |
Initialize a project:
contentrain initCheck project state:
contentrain status
contentrain doctorGenerate the typed SDK client:
contentrain generateValidate content and create review-branch fixes when possible:
contentrain validate
contentrain validate --fixReview pending changes:
contentrain diffOpen the local UI:
contentrain servecontentrain serve has two roles.
Start the local review UI:
contentrain serve
contentrain serve --port 3333 --host localhostThis serves:
- REST endpoints for status, content, validation, branches, and normalize data
- a WebSocket stream for live updates
- the embedded Vue
serve-uiapp bundled with the CLI
Start the MCP server for IDE integration:
contentrain serve --stdioUse stdio mode when connecting Claude Code, Cursor, Windsurf, or another MCP client to the local project.
contentrain generate writes a typed client to .contentrain/client/ and injects #contentrain imports into your package.json.
After generation:
import { query, singleton, dictionary, document } from '#contentrain'Run with watch mode during local model/content work:
contentrain generate --watchMost write operations create feature branches from the dedicated contentrain branch. In review mode, these branches are pushed to remote for team review. In auto-merge mode, they are merged into the contentrain branch and baseBranch is advanced via update-ref.
Use:
contentrain status
contentrain diffto understand:
- how many active review branches exist on the
contentrainbranch - whether branch health is blocking new writes
- what changed before merging or deleting a branch
contentrain init installs project-level AI rules automatically:
CLAUDE.mdfor Claude Code or generic fallback.cursorrulesfor Cursor.windsurfrulesfor Windsurf
If the target file already exists, Contentrain appends its rules instead of overwriting unrelated content where possible.
Full documentation at ai.contentrain.io/packages/cli.
From the monorepo root:
pnpm --filter contentrain test -- --run
pnpm --filter contentrain exec tsc --noEmit
pnpm --filter contentrain build