cratis-specs-csharp

Guidance for writing C# tests in Cratis using Specification by Example, where each test describes a real situation in a readable form. It covers the Establish/Because/should pattern: set up the situation, perform one action, and check the result.

In plain words
What is it for?
Testing commands, event handling, projections, reducers, reactors, isolated logic, and host or transport boundaries with C#.
Why use it?
It helps developers write focused tests that also serve as documentation, while choosing suitable test types and reusable test setup.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cratis/ai/cratis-specs-csharp
Any agent
npx skills add Cratis/AI --skill cratis-specs-csharp
Clone the repo
git clone --depth 1 https://github.com/Cratis/AI

Made for: Claude Code, Codex.

Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,952 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00101 $0.01952
Opus 5 $0.00051 $0.00976
Sonnet 5 $0.00020 $0.00390
Haiku 4.5 $0.00010 $0.00195

Measured 2d ago against content hash fbde383f9b9f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cratis-specs-csharp scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.ai/skills/cratis-specs-csharp/SKILL.md · 207 lines

How it starts

The opening of the file, as written. The whole thing — 207 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Core philosophy

Specs are executable documentation — the folder tree reads like a spec sheet. Favor readability over DRY. Each spec file has:

  • One action under test (Because)
  • One setup (Establish)
  • One or more focused assertions (should_*)

Step 1 — Choose the spec type

Lead with the in-process scenario family (fast, infrastructure-free — the default for slice behavior); reserve out-of-process Chronicle integration specs for host/transport boundaries they can't reach. Every spec file is wrapped in #if DEBUG … #endif. Full reference: the universal base in specs.csharp.md and the application *Scenario family in specs.scenarios.csharp.md.

Scenario Spec type
State Change slice (command → events) CommandScenario<TCommand> — runs validators + Provide() + Handle() + appended events
State View slice (projection / reducer) ReadModelScenario<TReadModel>
Constraints / raw append & concurrency semantics EventScenario
Automation / Translation (reactor) ReactorScenario<TReactor>
Isolated unit logic (no I/O) Unit spec in for_<ClassName>/
Host / transport / real-infra boundary (advanced) out-of-process Chronicle integration spec
Complex setup shared across many specs Reusable context in given/

Step 2 — Create the folder structure

for_<ClassName>/
├── given/
│   ├── all_dependencies.cs       ← mocks all deps, inherits Specification
│   └── a_<system_under_test>.cs  ← creates SUT, inherits all_dependencies
├── when_<behavior>/              ← behavior with multiple outcomes
│   ├── and_<condition>.cs
│   └── with_<state>.cs
└── when_<simple_behavior>.cs     ← single outcome = single file

Folder/file names read as English sentences:

  • for_Changeset / when_adding_changes / and_there_are_differences
  • for_AuthorService / when_registering / and_name_already_exists

Step 3 — Write a spec

Read the full file on GitHub · 207 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 207 lines · 101 tokens per session scan A fbde383f9b9f

Subscribe to this mod's changes

cratis-specs-csharp is a skill published in the GitHub repository Cratis/AI (2 stars, last pushed 5d ago), licensed MIT. It adds 101 tokens to every session and 1,952 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

cratis-specs-csharp

Step-by-step guidance for writing C# specs in Cratis with BDD Specification by Example — the Establish/Because/should pattern, for/when/and folder hierarchy, reusable given/ contexts, NSubstitute mocking, and the in-process scenario family. Use when writing C# unit or integration specs or structuring the for/when/and…

Cratis/VerticalSlices · 101 tokens

add-concept

Use this skill when asked to create a strongly-typed domain identifier or value (such as ProjectId, AuthorName, InvoiceNumber) in a Cratis-based project. Produces a ConceptAs record with the correct conversions and sentinel values.

Cratis/VerticalSlices · 54 tokens

cratis-specs-typescript

Step-by-step guidance for writing TypeScript specs in Cratis using BDD-style Specification by Example — the given()/describe/it pattern, for/when/ folder hierarchy, reusable context classes, Sinon mocking, and Chai assertions. Use whenever writing TypeScript specs or tests, creating spec files/folders, using the…

Cratis/VerticalSlices · 100 tokens

cratis-csharp-standards

Reference for Cratis C# coding conventions — formatting, naming, records, nullable handling, exceptions, logging, and DI. Use whenever writing C# in a Cratis project, deciding between record vs class, checking naming rules, applying formatting conventions, handling null safety, creating exception types, or asking "how…

Cratis/VerticalSlices · 101 tokens

write-specs-events

Use this skill when asked to write tests or specs for event appending, event log behavior, constraint violations, or concurrency violations using EventScenario in a Cratis-based project. Produces infrastructure-free in-process specs using EventScenario and AppendResult Should extensions.

Cratis/VerticalSlices · 57 tokens

write-specs-readmodels

Use this skill when asked to write tests or specs for read model projections, reducers, or model-bound projections using ReadModelScenario in a Cratis-based project. Produces infrastructure-free in-process specs using ReadModelScenario .

Cratis/VerticalSlices · 53 tokens