Skip to content
Back to skills

Csharp Conventions

ASecurity

General C# conventions for the hexagonal .NET services — record commands/queries, Result-based error handling, async, multi-tenancy, DI registration, and naming. Apply whenever writing or editing C# code under src/.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 11, 2026
developmentgoc#

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add makigjuro/cloud-app-blueprint --skill csharp-conventions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Csharp Conventions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Csharp Conventions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/makigjuro-csharp-conventions/badge)](https://www.skillsdirectory.com/skills/makigjuro-csharp-conventions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: csharp-conventions
description: General C# conventions for the hexagonal .NET services — record commands/queries, Result-based error handling, async, multi-tenancy, DI registration, and naming. Apply whenever writing or editing C# code under src/.
user-invocable: false
paths:
  - "src/**/*.cs"
---

# C# General Rules

## Commands & Queries
- Define as `record` types (immutable): `public record CreateOrderCommand(Guid TenantId, string Name);`
- Handlers return `Result<T>` or `Result`, never throw exceptions for business logic
- Handler signature: `public async Task<Result<TResponse>> Handle(TCommand command, CancellationToken cancellationToken)`

## Error Handling
- Use `Result<T>` from the shared infrastructure layer (`Shared.Infrastructure/Results/`), never from Domain
- Error codes in SCREAMING_SNAKE_CASE: `"ORDER_ALREADY_EXISTS"`, `"CUSTOMER_NOT_FOUND"`
- Use typed `ErrorType` enum: Validation, NotFound, Conflict, Unauthorized, Forbidden, Failure, Unexpected
- Never throw exceptions for expected business failures

## Async
- All I/O is async with `CancellationToken` propagated
- Suffix async methods with `Async`: `GetByIdAsync()`, `AddAsync()`
- Always await or return tasks, never fire-and-forget without explicit intent

## Multi-tenancy
- `TenantId` is a first-class value object, present on commands and entities
- The endpoint fills the command's `TenantId` from the authenticated user's tenant claim (`user.GetTenantId()`), never from the request body or query string
- Filter queries by tenant where applicable

## DI Registration
- Services registered as scoped: `services.AddScoped<IService, Service>()`

## Naming
- `_camelCase` for private fields
- Folders match namespace segments

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.