Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

contentrain

npm version GitHub source Docs

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 #contentrain SDK 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:

🚀 Install

Use npx:

npx contentrain init

Or install globally:

pnpm add -g contentrain
contentrain status

Requirements:

  • 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 init

Check project state:

contentrain status
contentrain doctor

Generate the typed SDK client:

contentrain generate

Validate content and create review-branch fixes when possible:

contentrain validate
contentrain validate --fix

Review pending changes:

contentrain diff

Open the local UI:

contentrain serve

🖥 serve Modes

contentrain serve has two roles.

Start the local review UI:

contentrain serve
contentrain serve --port 3333 --host localhost

This serves:

  • REST endpoints for status, content, validation, branches, and normalize data
  • a WebSocket stream for live updates
  • the embedded Vue serve-ui app bundled with the CLI

Start the MCP server for IDE integration:

contentrain serve --stdio

Use 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 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 diff

to understand:

  • how many active review branches exist on the contentrain branch
  • 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.md for Claude Code or generic fallback
  • .cursorrules for Cursor
  • .windsurfrules for 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