Skip to content

Cratis Screenplay modeling language

Last released · v6.0.0

Cratis Screenplay is a declarative modeling language for describing events, commands, read models (queryable views of recorded facts), screens, and specifications in one portable .play model. People and AI agents read the same model, so a discussion about what a feature should do can refer to the declarations and examples that describe it.

The model is language-neutral: it describes the system rather than a C# implementation. Choose a rendering target separately, and check which declarations and code attachments that target supports.

Start with the behavior: what someone asks the system to do, which facts that produces, and what someone needs to see afterward. Screenplay keeps those connections visible without requiring you to follow them through controllers, storage code, and UI wiring.

Write your first .play model to describe borrowing a library book and try editor highlighting, completions, and live diagnostics. You finish with a model to review, not a running application. If you are deciding whether Screenplay fits your work, read the rationale first; the other guides help you explore an existing model or go deeper into the language.

A slice groups the declarations for one behavior. For employee registration, that could mean the registration command, the event recording that an employee registered, a read model for looking the employee up, and specifications of accepted and rejected requests. A screen describes how someone uses that behavior. You can keep the model in one file or split it across files as it grows.

Selected implementation points can carry inline code or file references when declarations are not enough. Those attachments do not define the portable meaning of the language. Why Screenplay explains when to model a slice and when to keep it hand-written.

Use the reference for the part you are working on:

  • Modules, features, and slices organize behavior into typed slices aligned with Event Modeling.
  • Concepts declare value types and their compliance attributes once, so usages inherit the classification. This does not make an application automatically compliant.
  • Commands and events describe intent, validation, authorization, and the facts produced.
  • Projections and queries turn events into read models using the embedded Projection Declaration Language.
  • Screens describe UI at three abstraction levels, from intent to templates with inline React.
  • Reactions and captures describe event-driven automations; captures turn external data into events.

The compiler turns the .play declarations into an executable semantic model (ESM): a versioned description of what the model means. Cratis Studio and target renderers consume that description rather than define separate meanings for it. Where Cratis Chronicle supplies execution semantics, the ESM preserves that behavior using portable names. The semantic authority decision explains the boundary.

Before choosing a consumer, check which versions and capabilities it admits. A construct can be valid Screenplay without being executable by every target. A consumer must refuse behavior it cannot preserve, not silently skip it.

.play model

Compiler binds to versioned ESM

Reference execution: admitted capabilities

Studio: design and visualization

Renderers: supported realization targets

Target-specific application code

To check scenarios without a target application, use Screenplay’s reference execution. It runs admitted capabilities in memory without starting Arc, Chronicle, a database, or a network service. Passing those checks does not prove that a target application can execute every construct.

For how Cratis Arc and Cratis Chronicle fit into the wider platform, read Why developers choose Cratis.

Give a supported model to Cratis Stage, issue a command, then query the state it changes through its API or Scene screens. Stage is a disposable sandbox, not a production host: its in-memory state does not survive a container restart. Check admission diagnostics and bind published ports to 127.0.0.1.

  • Sub-languages and inline code: PDL and CDL are built-in grammars; csharp, java, typescript, react, html, and sql inline language tags are bounded realization attachments, not a promise of execution support.
  • The grammar: the full EBNF definition of the language.
  • Glossary: module, feature, slice, construct, sub-language, Stage, and Studio.
  • Frequently asked questions: indentation, bounded C#/React escape hatches, and the relationship to Arc and Chronicle.