contentrain
v0.2.3
Published
CLI for Contentrain — AI content governance infrastructure
Maintainers
Readme
contentrain
CLI for Contentrain.
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
🚀 Install
Use npx:
npx contentrain initOr install globally:
pnpm add -g contentrain
contentrain statusRequirements:
- Node.js 22+
- Git available in
PATH
🧰 Commands
| 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 |
🔄 Typical Flow
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 serve🖥 serve Modes
contentrain 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.
📦 generate and #contentrain
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 --watch👀 Review Workflow
Most write operations create contentrain/* branches in review mode.
Use:
contentrain status
contentrain diffto understand:
- how many active review branches exist
- whether branch health is blocking new writes
- what changed before merging or deleting a branch
🤖 IDE Rules
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.
📚 Documentation
Full documentation at ai.contentrain.io/packages/cli.
🛠 Development
From the monorepo root:
pnpm --filter contentrain test -- --run
pnpm --filter contentrain exec tsc --noEmit
pnpm --filter contentrain build