cratis/ai.distribution/cratis-command
Claude Code and agent skill by cratis/ai.distribution
- community
Checking that the SKILL.md file is still in the repository.
Step-by-step guidance for creating a Cratis Arc command — [Command] record, Handle() method, CommandValidator, proxy generation, and React .use() hook with CommandDialog. Use when adding or creating a command, wiring up a form or button to the backend, working with IEventLog, CommandResult, CommandValidator, CommandDialog, or [Command] attribute.
Install
npx vskill@latest install cratis/ai.distribution/cratis-commandSKILL.md
The same SKILL.md was published earlier as cratis/ai.distribution/cratis-command.
Creating a Cratis Command
A command represents a user action that changes state. In Cratis Arc the path is:
The command record owns its own handler — no separate controller class required. Follow the steps in order. Jump to the reference files for deeper detail on any step.
Step 1 — Define the C# command record
A command is a record decorated with `[Command]` that contains its own Handle() method. No separate controller is needed.
Rules:
[Command]attribute is required — it makes the type discoverable and the analyzer will warn without itHandle()returns the event (or events) to append — Arc's Chronicle integration automatically appends them; never inject `IEventLog` to append the primary event[EventType]takes no arguments — the identifier is generated from the type name- Name the command as an imperative action —
OpenDebitAccount, notOpenDebitAccountCommand - All backend artifacts for the slice live in this one file; place it in the slice folder, not an
API/orCommands/folder (see vertical-slices.md) - Use concept wrappers for every domain value — identity concepts derive from
EventSourceId<T>, value concepts fromConceptAs<T>; never rawGuid/string
Generating a new ID and returning it
Appending multiple events
Return IEnumerable<object>. Events never carry the event-source id — for events that belong to different streams, wrap each in EventForEventSourceId(id, @event):
For multiple events on the same event source, return the bare event records.
Step 2 — Fetch data the handler needs with Provide()
When Handle() needs fetched or computed data before it can build the event, add a Provide() method. It runs after authorization and validation, resolves its parameters from DI, and binds its return value to Handle(...) parameters by type. It may short-circuit with a ValidationResult.Error(...) when the data is missing or unusable — do not throw for that.
- Keep IO in
Provide()and event construction inHandle(). - For uniqueness, use
[Unique]/IConstraint(race-safe) — not a read-model pre-check or a throwing service. See theadd-business-ruleskill. - For a concurrency-sensitive state rule, inject the read model into
Handle()and returnResult<TEvent, ValidationResult>(seeadd-business-rule).
Arc automatically wraps the return in CommandResult / CommandResult<T>. See references/command-result.md.
Step 3 — Add validation (optional but recommended)
FluentValidation rules run on the server as part of the command pipeline; the proxy generator also extracts them so the same rules run client-side as pre-flight validation in CommandForm. Put the validator beside the command in the slice file:
- Extends
CommandValidator<T>(notAbstractValidator<T>) — this makes it discoverable automatically - No registration needed; omit the validator entirely when there are no rules
- Arc also creates a
/validateendpoint automatically; the frontendcommand.validate()calls it without executing the handler - Single-property intrinsic rules (format, range, required) belong on a
ConceptValidator<T>for the value concept, so they travel with the value everywhere
Step 4 — Generate the TypeScript proxy
The Cratis.Arc.ProxyGenerator.Build MSBuild package runs during the build and writes TypeScript files to the path configured in your .csproj:
This produces Web/src/api/Accounts/OpenDebitAccount.ts. For first-time setup see references/proxy-setup.md.
Step 5 — Use the command in React
Inline form (full control)
Key properties on the command instance:
| Property / method | What it does | |
|---|---|---|
command.propName | Get/set the property value | |
command.hasChanges | true when any value differs from the initial | |
command.execute() | Send the POST, returns CommandResult | |
command.validate() | Call the validate endpoint (no side effects) | |
setValues(obj) | Set multiple properties at once (e.g. from a query result) |
With initial values (edit scenario)
Using CommandDialog (quickest path for modal forms)
See Step 6 and references/command-dialog.md.
Step 6 — Wrap in a CommandDialog (optional)
For modal dialogs, create a dialog component using DialogProps and wire it up with useDialog:
How it works:
useDialog(OpenAccountDialog)returns a wrapper component and ashowfunctionshowOpenAccount()opens the dialog; it returns a Promise that resolves when the dialog closesCommandDialogexecutes the command when the user confirms; it closes automaticallyDialogPropsprovidescloseDialog— needed when you want to pass a response back or handle cancel explicitly
Edit dialog (pre-populate with existing values):
initialValues— sets the change-tracking baseline (e.g. IDs that must be present for the command but are not user-entered)currentValues— pre-populates the visible field values
CommandDialog calls onConfirm only after a successful command.execute(), so you don't need to check isSuccess yourself. See references/command-dialog.md for the full props list.
Reference files
| File | What's in it | |
|---|---|---|
references/command-result.md | Full CommandResult shape, error handling patterns | |
references/command-dialog.md | CommandDialog props, CommandForm fields, edit dialogs | |
references/validation.md | FluentValidation, Data Annotations, client-side pre-flight | |
references/proxy-setup.md | First-time proxy generator setup |
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cratis-command/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cratis/ai.distribution/cratis-command)