Skip to content

Language overview

Screenplay is the modeling language for the Cratis platform. It lets developers describe a complete bounded context — events, commands, queries, projections, screens, automations, authorization, validation, constraints, and concepts — in a single declarative file. Stage interprets a Screenplay and runs it as a live application; Studio uses the same contract to visualize and generate.

Screenplay files use the .play extension.

  • Indentation-based — Python-style, no braces. Structure follows the offside rule: a construct owns everything indented beneath it.
  • Declarative first, imperative escape hatch — every construct has a declarative form; any construct can drop into C#, TypeScript, React, or HTML via inline code blocks or file references.
  • Slices are the atom — everything lives inside a typed slice aligned with Event Modeling’s vocabulary.
  • Sub-language pluggability — the Projection Declaration Language (PDL) and Change Data Capture Language (CDL) are embedded sub-grammars. Additional sub-languages can be registered and parsed inside named constructs.
  • Concepts carry compliance — value types declare PII and sensitivity attributes once; all usages inherit them.
<imports>
<concepts>
<policies>
<module>
<layouts>
<feature>+
<feature>* ← sub-features, arbitrarily deep
<slice>+
<construct>+ ← events, commands, queries, projections, captures, reactors, screens, constraints

Cross-module references. Imported types are available by their short name within the module.

import Customers.CustomerRegistered
import Customers.CustomerDetailsReadModel

Line comments start with // and run to the end of the line.

TopicPage
Formalized value types with compliance attributesConcepts
Named authorization rulesPolicies
Modules, features, and the four slice typesModules, Features and Slices
Event type declarationsEvents
Commands, validation, the produces block, and handlersCommands
Read-side entry pointsQueries
PDL-embedded projectionsProjections
CDL-embedded change data captureCaptures
Server-side rules enforced before commitConstraints
Event reaction rulesReactors
UI declarations at three abstraction levelsScreens
Registering additional embedded sub-languagesSub-language Pluggability
The full EBNF grammarGrammar

The @cratis/screenplay-language NPM package provides a Monaco language service for .play files — syntax highlighting (including embedded C#/TypeScript/React/HTML blocks and the PDL/CDL sub-languages), IntelliSense completions, hover documentation, and diagnostics. The screenplay-editor app hosts the editor standalone.

The Screenplay VS Code extension brings the same language support to VS Code — a TextMate grammar with embedded-language and PDL/CDL highlighting, plus IntelliSense, hover, and diagnostics driven by the same shared language logic. .play files carry the Cratis icon.