cratis/samples/cratis-engineering-csharp-conventions
Claude Code and agent skill by cratis/samples
- community
Checking that the SKILL.md file is still in the repository.
Use when writing or reviewing C# house style in a Cratis repository, including naming, formatting and service lifetimes. Not for product API behavior or specification authoring.
Install
npx vskill@latest install cratis/samples/cratis-engineering-csharp-conventionsSKILL.md
The same SKILL.md was published earlier as cratis/samples/cratis-engineering-csharp-conventions.
Cratis C# engineering conventions
These are the house conventions Cratis maintainers apply across every repository. They are conventions, not framework contracts: nothing here is enforced by an analyzer unless this skill says so. Follow them for consistency; do not claim the framework requires them.
Verified product sources
| Package | Purpose | |
|---|---|---|
Cratis.Fundamentals | DI lifetime attributes and IInstancesOf<T> instance resolution |
Route near misses
- The question is what a Cratis product API does: resolve it against the
owning product repository, not against this style guide.
- The subject is a specification file: the specification conventions own the
Establish/Because/should_ pattern and the for_/when_ hierarchy.
- The subject is TypeScript or React: this skill covers C# only.
- The subject is repository structure or documentation: those are separate
workflows.
Quick reference
- Use current C# language features — records, primary constructors, pattern
matching, collection expressions.
varover an explicit type; the right-hand side already names the type.- File-scoped namespace declarations.
usingdirectives alphabetically sorted, single-line, unused ones removed.- No regions. A file that needs them needs refactoring instead.
- No technical postfixes on type names: no
Impl,Service,Manager,
Handler, Base, Async.
- No
Exceptionsuffix on exception types —AuthorNotFound, not
AuthorNotFoundException.
- Never throw a built-in exception type. Always define a domain exception.
recordfor events, commands, read models, concepts, and DTOs.is nullandis not null— never== nullor!= null.- Blank line before the opening
{of every block. - A final
returnsits on its own line. - Private fields are
_camelCase; interfaces take theIprefix. - American English everywhere — initialize, behavior, color, serialize.
- Every file starts with the repository license header.
Formatting
Naming
| Artifact | Convention | Example | |
|---|---|---|---|
| Type, method, public member | PascalCase | RegisterAuthor, AuthorId | |
| Private field | _camelCase | _eventLog | |
| Local variable | camelCase | authorId | |
| Interface | I prefix | IEventLog | |
| Exception type | No Exception suffix | AuthorNotFound | |
| Feature folder | Pluralized domain noun | Authors/ | |
| Concept file | The concept name | AuthorId.cs |
Avoid abbreviations unless they are universally known (Id, Xml, Json, Url). Never add a prefix or postfix that names a technical role — Controller, ViewModel, Handler, Manager, Factory, Base. Name after the domain, not the pattern.
Where the detail lives
| Topic | Reference | |
|---|---|---|
Records, primary constructors, var, collections, nullable, async, pattern matching, XML documentation | code-style.md | |
| Custom exceptions, structured logging, dependency injection, service lifetimes, implementation discovery | exceptions-logging-and-di.md | |
| CUPID, cohesion over layers, ubiquitous language, immutability | domain-philosophy.md |
Read the reference that covers the decision at hand rather than all three.
The two rules most often got wrong
Anything taking a scoped dependency is scoped or transient, never a singleton. A singleton may not depend on anything that belongs to a tenant, a user, or a request. Capturing a scoped collaborator does not throw — it silently binds to the root scope's default namespace forever and returns empty results. The fix is almost always to drop [Singleton], not to reach for IServiceScopeFactory. See exceptions-logging-and-di.md.
Enable it on an existing codebase in this order, or it will simply refuse to start: turn it on locally first, fix everything it names, and only then let it reach the deployed environments. Turning it on before the sweep converts a silent multi-tenant bug into a production outage.
Use `IInstancesOf<T>`, never `IEnumerable<T>`, to enumerate implementations of an abstraction. IEnumerable<T> only works when every implementation is hand-registered, which defeats convention-based discovery.
Verify
- Every file carries the repository license header and a file-scoped namespace.
usingdirectives are sorted, single-line, and free of unused entries.- No regions, no technical postfixes, no
Exceptionsuffix. - Every thrown exception is a domain type deriving from
Exceptionwith a
meaningful message and an XML <exception> or <summary> doc starting with "The exception that is thrown when".
- No
catchblock is empty or silently swallowing. - Null checks use
is null/is not null, and no defensive check contradicts a
non-nullable annotation.
- Every public type, method, property, and operator carries multiline XML
documentation with <param> and <returns> where applicable.
- No
[Singleton]takes a scoped dependency or holds tenant-, user-, or
request-bound state, and the host sets ValidateScopes and ValidateOnBuild in every environment.
- No
services.Add*<TInterface, TImplementation>()registers a type that exists
to be discovered by convention.
- Text is American English.
- The solution builds with zero warnings and zero errors, and the affected
specifications pass.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.cratis/ai/skills/cratis-engineering-csharp-conventions/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 7
Stars and forks are for the whole GitHub repository, not this skill alone. 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/samples/cratis-engineering-csharp-conventions)