Skip to Content
Prism Context Engine v1.2.0 - the CLI works locally with no account. See the Quick Start.
Rules

Rules

Rules live in .prism/rules.json at your project root. prism check and the agent hooks enforce it. prism init generates a starter; prism pull fetches your team’s version from the dashboard. Same file, same schema.

File format

Version 1 schema. An object with a top-level rules array:

{ "version": 1, "rules": [ { "id": "styling/no-magenta", "category": "styling", "severity": "block", "extensions": [".tsx"], "instruction": "Use the design system palette. Never hardcode magenta.", "check": { "type": "forbidden_pattern", "pattern": "#ff00ff", "message": "Use the design system palette, not magenta." } } ] }

This exact example parses and fires — it follows the validator in the CLI source (src/rules/parse.ts).

Rule fields:

FieldRequiredDescription
idYesNon-empty string. Convention: category/name
categoryYesOne of the four categories below
severityNoblock or warn. Defaults to warn
instructionNoAdvisory text for the agent (no check needed)
extensionsNoFile extensions the rule covers (e.g. [".tsx", ".ts"]). Normalized with a leading dot
checkNoThe machine-checkable block (types below). Without it the rule is advisory only

Categories

Exactly four. Any other value fails validation:

CategoryPurpose
architectureFile structure, imports, patterns
stylingDesign tokens, CSS, colors
securityAuth, validation, dangerous calls
testingTest placement, frameworks

Use only the four categories above. An invalid category (or any other schema error) fails validation — and because hook mode fails open, a broken rules.json means the hook logs the error to stderr and skips enforcement entirely until the file is fixed. Run prism check <file> by hand after editing rules to confirm the file still parses.

Severities

SeverityEffect
blockHook exits with code 2 and returns a correction to the agent. The agent must fix the violation
warnReported as a finding, never stops the agent (default when omitted)

Check types

All seven types below are implemented and validated by the CLI (src/rules/types.ts).

forbidden_pattern

Flags any file matching a regular expression.

{ "type": "forbidden_pattern", "pattern": "#[0-9a-fA-F]{6}", "flags": "g", "allowlist": ["#000000", "#ffffff"], "fix": "Use a design token variable instead of a hex literal.", "message": "Hardcoded hex colors are not allowed." }
FieldRequiredDescription
patternYesRegular expression source
flagsNoRegex flags
allowlistNoExact matches to ignore
fixNoSuggested replacement shown in the correction
messageNoCustom message

required_token

Requires raw CSS values to be written as design tokens.

{ "type": "required_token", "tokenSet": "colors", "tokenMap": { "#06b6d4": "var(--color-primary)", "#050505": "var(--color-void)" } }

tokenMap maps each raw value to the token that must replace it. Generated by prism init from your own CSS custom properties.

banned_import

Blocks specific import specifiers.

{ "type": "banned_import", "specifiers": ["lodash", "moment"], "message": "Use the lightweight utils instead." }

arbitrary_value

Flags arbitrary bracket values in Tailwind utilities (e.g. w-[13px]).

{ "type": "arbitrary_value", "properties": ["width", "height", "p", "m"] }

properties are Tailwind utility names (lowercase letters, digits, dashes).

naming_pattern

The file’s base name (without extension) must match the pattern.

{ "type": "naming_pattern", "pattern": "^[A-Z][A-Za-z0-9]*$", "message": "React components must be PascalCase." }

file_placement

Files matching matchPattern must live inside directory.

{ "type": "file_placement", "matchPattern": "^use[A-Z]", "directory": "src/hooks" }

required_import

Every covered file must import the specifier. Optionally scoped by path.

{ "type": "required_import", "specifier": "next-env-types", "includePattern": "\\.d\\.ts$" }

The inverse of banned_import.

Example rule packs

The CLI repository ships executable example packs under examples/ (Flutter, Kotlin, Python). They are loaded by the test suite, so every convention they encode is proven to fire. For instance, the Python pack blocks breakpoint() at block severity and requires snake_case module names.

How findings are reported

prism check <file> prints findings and exits 1 when blocking violations exist, 0 when clean. Hook mode writes a correction message to stderr and exits 2. Every hook run appends one line to .prism/activity.log (observability only).

Last updated on
Prism Context EnginePrism Context Engine

A rules layer for AI coding agents. Prism checks every write against your team's rules and sends corrections back to the agent.

Documentation

Product

Start a Project

Install the CLI and run `prism init`. No account needed.

GET_STARTED ↗
© 2026 Syntaxure Labs.DTI: VL1927082895984