Rule Cascade
Get started

Start a new project

rcas init creates the project file, a first ruleset with golden tests, CI, and optionally the instructions and MCP configuration for your AI coding tools.

Create the project

In the repository of your application (or an empty directory):

rcas init --name "Acme Payments" --lang ts,java
rcas init /work/acme-payments (Acme Payments, ids acme.payments.*)
  created      rcas.yaml
  created      rules/example.ruleset.yaml
  created      rules/order.schema.json
  created      rules/LOADING.md
  created      .rcas/.gitignore
  created      .github/workflows/rules.yml
  updated      .gitignore (.rcas/)
FilePurpose
rcas.yamlThe project: where rules live, where bundles go, the languages that load them, the API schemas rules are derived from. See project configuration
rules/example.ruleset.yamlA first ruleset: one blocking rule, one warning, a parameter with an override policy, messages and three golden tests
rules/order.schema.jsonThe entity the example talks about. In your project, point entities at your API's own schemas
rules/LOADING.mdHow each language you chose loads the compiled bundle
.rcas/Proposals waiting for review, and reports; never committed
.github/workflows/rules.ymlCI: rcas check and rcas compile --all on every pull request (written when the directory is in a git repository, or with --ci github)

init never replaces a file that exists and differs, unless you pass --force. --dry-run shows what it would write.

Check and compile

rcas check
acme.payments.example@0.1.0  sha256:ebacd52bdbea...  2 rules (2 client-safe), 1 params
  3 golden tests, 0 failed

check validates every ruleset against the schema, runs the load-time checks of the specification (inheritance, override policies, unknown fields, portable patterns and YAML), and runs the golden tests. Then compile:

rcas compile --all
acme.payments.example@0.1.0  sha256:ebacd52bdbeaee8a903fdd0d636c3e38fd5f4f2d4f5cd9fd493406204ee36910  -> acme.payments.example.bundle.json, acme.payments.example.client.manifest.json

The bundle goes to backends; the client manifest is the part a browser may see.

Evaluate

echo '{"entity":"Order","operation":"create","data":{"quantity":11}}' \
  | rcas evaluate --bundle build/rules/acme.payments.example.bundle.json -

The answer is deny: order.quantity.max blocks (11 is over 10), and order.note.recommended adds a warning, because an order of five or more items has no note. Load the same bundle in your application with the snippet in rules/LOADING.md:

import { readFileSync } from 'node:fs';
import { RuleSet } from '@rules-cascade/core';

const rules = RuleSet.fromBundle(JSON.parse(readFileSync('build/rules/acme.payments.example.bundle.json', 'utf8')));
const result = rules.evaluate({ entity: 'Order', operation: 'create', data: { quantity: 3 } }, 'server');

Connect your AI coding tool (optional)

rcas agent install            # AGENTS.md, CLAUDE.md, GEMINI.md, Copilot and Cursor rules, sub-agents, a skill
rcas mcp install claude       # or codex, cursor, windsurf, gemini, vscode, all

Or in one step: rcas init --agent all --mcp claude. See AI coding tools.

rcas init options

rcas init [dir] [--name <name>] [--id-prefix <prefix>] [--lang ts,python,java,go,other] [--from <path>]
          [--agent claude,codex,cursor,copilot,gemini|all] [--mcp <client>|all] [--ci github|none] [--force] [--dry-run]
FlagMeaning
dirwhere to create the project (default: the current directory)
--namethe project name (default: the directory name)
--id-prefixthe prefix of ruleset ids, dot-separated lower case, e.g. acme.payments (default: from the name)
--langthe languages that load the rules, for LOADING.md and rcas.yaml
--froman existing code base: run rcas analyze on it and propose a ruleset for every API schema found
--agentalso run rcas agent install --for these tools
--mcpalso run rcas mcp install for these tools
--cigithub writes .github/workflows/rules.yml; none writes nothing
--forcereplace files that exist and differ
--dry-runprint what would be written

Exit status 0, or 2 for a usage error.

Next: write your own rules, or generate them from existing code.

On this page