@contentrain/rules
v0.4.0
Published
AI agent rules for Contentrain — quality standards, architecture conventions, IDE integration
Maintainers
Readme
@contentrain/rules
Shared AI-agent rules for Contentrain.
Start here:
This package is the policy layer of the Contentrain ecosystem. It defines how agents should behave when they work with:
- Contentrain MCP tools (17 operations)
- schema and model design
- content quality (SEO, accessibility, media, i18n)
- normalize workflows (extraction + reuse)
- git-backed review flows
- security guardrails
If @contentrain/mcp is the deterministic execution layer, @contentrain/rules is the behavioral contract.
Install
pnpm add @contentrain/rulesWhat It Contains
Essential guardrails
Published under essential/:
contentrain-essentials.md— compact, always-loaded rules covering architecture, model kinds, MCP tools, mandatory protocols, git workflow, and security basics.
Shared quality rules
Published under shared/ — detailed standards per domain:
content-quality.md— structure, required fields, content completenessseo-rules.md— meta optimization, keywords, canonical URLsaccessibility-rules.md— alt text, ARIA labels, color contrastmedia-rules.md— image optimization, responsive sizing, asset namingschema-rules.md— model design, field types, relations, inheritancei18n-quality.md— translation completeness, locale paritysecurity-rules.md— sensitive data patterns, secret detection, XSS preventionmcp-usage.md— tool invocation patterns, git workflows, trust levelsnormalize-rules.md— extraction and reuse constraints, scope safetyworkflow-rules.md— review mode, approval flows, branch lifecyclecontent-conventions.md— naming, slug generation, status conventions
Prompt layers
Published under prompts/ — mode-specific context the agent loads per task:
common.md— shared preamble for all agent modesgenerate-mode.md— content creation constraintsnormalize-mode.md— string extraction and patching workflowsreview-mode.md— content validation and change review
Context bridge
Published under context/:
context-bridge.md— how to integrate rules into agent context systemstemplates/— framework-specific context JSON fornuxt,next,astro,sveltekit
Public Exports
The package root exports constants for tooling:
FIELD_TYPES— 27 flat field typesMODEL_KINDS—singleton,collection,document,dictionaryMCP_TOOLS— 17 MCP tool names (includescontentrain_mergeandcontentrain_doctor)ESSENTIAL_RULES_FILE— path to essential guardrails markdownSTACKS— supported framework stacks
Quick Example
import { MCP_TOOLS, ESSENTIAL_RULES_FILE, FIELD_TYPES } from '@contentrain/rules'
console.log(MCP_TOOLS.length) // 17
console.log(MCP_TOOLS.includes('contentrain_merge')) // true
console.log(MCP_TOOLS.includes('contentrain_doctor')) // true
console.log(ESSENTIAL_RULES_FILE) // 'essential/contentrain-essentials.md'
console.log(FIELD_TYPES.length) // 27Design Role
@contentrain/rules exists to keep agent behavior aligned across tools and environments.
Typical questions it answers:
- What is acceptable content quality? (shared quality rules)
- How should an agent use MCP tools safely? (mcp-usage + tool reference)
- What is the normalize contract? (normalize-rules)
- What workflow and review constraints exist? (workflow-rules)
Detailed procedures and step-by-step guides live in @contentrain/skills (Agent Skills standard format).
Parity with @contentrain/mcp
@contentrain/rules is kept in lockstep with the MCP tool registry via cross-package parity tests. When a new MCP tool is registered in @contentrain/mcp:
MCP_TOOLSmust include it (otherwisetests/mcp-parity.test.tsfails)- the essentials document must mention it
- the skills reference must have a
### <tool>section
When MCP's branch-naming convention changes (e.g. contentrain/* → cr/*), the rules prose must follow — the parity test scans the rules for the legacy prefix and fails if it reappears.
Relationship To Other Packages
@contentrain/mcpenforces file, validation, and git behavior@contentrain/skillsprovides Agent Skills with progressive disclosure (SKILL.md + references/)contentrain(CLI) installs rules + skills into the IDE duringcontentrain init@contentrain/queryis the generated runtime consumption layer
Rule of thumb:
rules= policy layer (quality standards, constraints, essentials)skills= procedural layer (workflows, detailed reference docs)
See AGENTS.md at the repo root for project-level agent guidance.
Build
From the monorepo root:
pnpm --filter @contentrain/rules build
pnpm --filter @contentrain/rules test
pnpm --filter @contentrain/rules typecheckLicense
MIT
