Développement Backend EasyPlatform .NET

VérifiéPrudence

Guide complet pour le développement backend .NET 9 avec patterns CQRS, entités, validation, migrations et message bus pour la plateforme Easy.Platform.

Spar Skills Guide Bot
DeveloppementAvancé
11/03/2026
Claude Code
#dotnet#cqrs#backend#microservices#easy-platform

Recommandé pour

Synthèse automatique

Guide le développement backend .NET 9 du monorepo EasyPlatform via des commandes/requêtes CQRS, entités, validation, migrations, tâches planifiées et bus de messages.

Points forts

  • Arbre de décision qui oriente vers le bon pattern (commande, requête, événement, migration, job, bus).
  • Applique des règles d'architecture fortes : effets de bord dans les Entity Event Handlers, bus de messages pour le cross-service, mapping porté par les DTO.
  • Définit une organisation de fichiers et des conventions de nommage précises.
  • Renvoie vers des références détaillées pour les patterns CQRS.

Limites

  • Très spécifique au monorepo et au framework EasyPlatform, peu réutilisable ailleurs.
  • Le SKILL.md s'appuie sur des fichiers de référence externes (ex. cqrs-patterns.md) non inclus.
  • Suppose une bonne connaissance des abstractions maison (PlatformValidationResult, IPlatformQueryableRootRepository).
Quand l'utiliser

Pour implémenter ou modifier une fonctionnalité backend .NET dans le monorepo EasyPlatform.

Quand l'éviter

Pour un projet .NET générique ou un autre framework, hors du contexte EasyPlatform.

Analyse de sécurité

Prudence
Score qualité82/100

The skill is a conventional .NET/CQRS development guide. It contains no obfuscated payloads, no curl|sh, no credential or token exfiltration, no destructive filesystem commands, and no instructions to disable safety checks. The only elevated risk is inherent to its declared toolset: Bash plus Write/Edit allows shell execution and broad source modification, which is appropriate for backend scaffolding but warrants the 'caution' rating rather than 'safe'.

Points d'attention
  • •Declared allowed-tools include Bash, Write, and Edit, granting broad filesystem and shell capability within the repository
  • •Skill instructs agents to scaffold/modify CQRS handlers, entities, and migrations without any explicit guardrails on file scope or migration execution
Comment cette analyse est faite

Exemples

Add a CQRS command
Create a SaveEmployeeCommand in the EasyPlatform backend that handles both create and update, with validation requiring a non-empty Name and returning an EmployeeDto.
Add a paged query
Add a GetEmployeeListQuery that supports paging, filters by a list of statuses and an optional search text, and returns EmployeeDto results.
Add an entity event handler
Add an entity event handler that sends a notification when an employee is updated, following the EasyPlatform side-effect pattern instead of putting it in the command handler.

name: easyplatform-backend description: Complete Easy.Platform backend development for EasyPlatform. Covers CQRS commands/queries, entities, validation, migrations, background jobs, and message bus. Use for any .NET backend task in this monorepo. infer: true allowed-tools: Read, Write, Edit, Grep, Glob, Bash

Easy.Platform Backend Development

Complete backend development patterns for EasyPlatform .NET 9 microservices.

Quick Decision Tree

[Backend Task]
├── API endpoint?
│   ├── Creates/Updates/Deletes data → CQRS Command (§1)
│   └── Reads data → CQRS Query (§2)
├── Business entity? → Entity Development (§3)
├── Side effects (notifications, emails)? → Entity Event Handler (§4) - NEVER in command handlers!
├── Data transformation/backfill? → Migration (§5)
├── Scheduled/recurring task? → Background Job (§6)
└── Cross-service sync? → Message Bus (§7) - NEVER direct DB access!

File Organization

{Service}.Application/
├── UseCaseCommands/{Feature}/Save{Entity}Command.cs     # Command+Handler+Result
├── UseCaseQueries/{Feature}/Get{Entity}ListQuery.cs     # Query+Handler+Result
├── UseCaseEvents/{Feature}/*EntityEventHandler.cs       # Side effects
├── BackgroundJobs/{Feature}/*Job.cs                     # Scheduled tasks
├── MessageBusProducers/*Producer.cs                     # Outbound events
├── MessageBusConsumers/{Entity}/*Consumer.cs            # Inbound events
└── DataMigrations/*DataMigration.cs                     # Data migrations

{Service}.Domain/
└── Entities/{Entity}.cs                                 # Domain entities

Critical Rules

  1. Repository: IPlatformQueryableRootRepository<T> -- NEVER throw exceptions for validation
  2. Validation: PlatformValidationResult fluent API
  3. Side Effects: Entity Event Handlers -- NEVER in command handlers
  4. DTO Mapping: DTOs own mapping via PlatformEntityDto<T,K>.MapToEntity()
  5. Cross-Service: Message bus -- NEVER direct database access

§1. CQRS Commands

File: UseCaseCommands/{Feature}/Save{Entity}Command.cs (Command + Result + Handler in ONE file)

public sealed class SaveEmployeeCommand : PlatformCqrsCommand<SaveEmployeeCommandResult>
{
    public string? Id { get; set; }
    public string Name { get; set; } = "";

    public override PlatformValidationResult<IPlatformCqrsRequest> Validate()
        => base.Validate().And(_ => Name.IsNotNullOrEmpty(), "Name required");
}

public sealed class SaveEmployeeCommandResult : PlatformCqrsCommandResult
{
    public EmployeeDto Entity { get; set; } = null!;
}

internal sealed class SaveEmployeeCommandHandler :
    PlatformCqrsCommandApplicationHandler<SaveEmployeeCommand, SaveEmployeeCommandResult>
{
    protected override async Task<SaveEmployeeCommandResult> HandleAsync(
        SaveEmployeeCommand req, CancellationToken ct)
    {
        var entity = req.Id.IsNullOrEmpty()
            ? req.MapToNewEntity().With(e => e.CreatedBy = RequestContext.UserId())
            : await repository.GetByIdAsync(req.Id, ct)
                .EnsureFound().Then(e => req.UpdateEntity(e));
        await entity.ValidateAsync(repository, ct).EnsureValidAsync();
        await repository.CreateOrUpdateAsync(entity, ct);
        return new SaveEmployeeCommandResult { Entity = new EmployeeDto(entity) };
    }
}

⚠️ MUST READ: references/cqrs-patterns.md — full CQRS command patterns


§2. CQRS Queries

File: UseCaseQueries/{Feature}/Get{Entity}ListQuery.cs

public sealed class GetEmployeeListQuery : PlatformCqrsPagedQuery<GetEmployeeListQueryResult, EmployeeDto>
{
    public List<Status> Statuses { get; set; } = [];
    public string? SearchText { get; set; }
}

internal sealed class GetEmployeeListQueryHandler :
    PlatformCqrsQueryApplicationHandler<GetEmployeeListQuery, GetEmployeeListQueryResult>
{
    protected override async Task<GetEmployeeListQueryResult> HandleAsync(
        GetEmployeeListQuery req, CancellationToken ct)
    {
        var qb = repository.GetQueryBuilder((uow, q) => q
            .Where(e => e.CompanyId == RequestContext.CurrentCompanyId())
            .WhereIf(req.Statuses.Any(), e => req.Statuses.Contains(e.Status))
            .PipeIf(req.SearchText.IsNotNullOrEmpty(), q =>
                searchService.Search(q, req.SearchText, Employee.DefaultFullTextSearchColumns())));
        var (total, items) = await (
            repository.CountAsync((uow, q) => qb(uow, q), ct),
            repository.GetAllAsync((uow, q) => qb(uow, q)
                .OrderByDescending(e => e.CreatedDate).PageBy(req.SkipCount, req.MaxResultCount), ct)
        );
        return new GetEmployeeListQueryResult(items.SelectList(e => new EmployeeDto(e)), total, req);
    }
}

⚠️ MUST READ: references/cqrs-patterns.md — full CQRS query patterns


§3. Entity Development

File: {Service}.Domain/Entities/{Entity}.cs

[TrackFieldUpdatedDomainEvent]
public sealed class Employee : RootAuditedEntity<Employee, string, string>
{
    [TrackFieldUpdatedDomainEvent] public string Name { get; set; } = "";
    public string CompanyId { get; set; } = "";

    [ComputedEntityProperty]
    public string DisplayName { get => $"{Code} - {Name}"; set { } }

    public static Expression<Func<Employee, bool>> OfCompanyExpr(string companyId) => e => e.CompanyId == companyId;
    public static Expression<Func<Employee, bool>> UniqueExpr(string companyId, string code) => e => e.CompanyId == companyId && e.Code == code;
    public static Expression<Func<Employee, object?>>[] DefaultFullTextSearchColumns() => [e => e.Name, e => e.Code];

    public async Task<PlatformValidationResult> ValidateAsync(IRepository<Employee> repo, CancellationToken ct)
        => await PlatformValidationResult.Valid()
            .And(() => Name.IsNotNullOrEmpty(), "Name required")
            .AndNotAsync(() => repo.AnyAsync(e => e.Id != Id && e.Code == Code, ct), "Code exists");
}

⚠️ MUST READ: references/entity-patterns.md — full entity patterns


§4. Entity Event Handlers (Side Effects)

CRITICAL: NEVER call side effects in command handlers!

File: UseCaseEvents/{Feature}/Send{Action}On{Event}{Entity}EntityEventHandler.cs

internal sealed class SendNotificationOnCreateEmployeeEntityEventHandler
    : PlatformCqrsEntityEventApplicationHandler<Employee>
{
    public override async Task<bool> HandleWhen(PlatformCqrsEntityEvent<Employee> @event)
        => !@event.RequestContext.IsSeedingTestingData()
           && @event.CrudAction == PlatformCqrsEntityEventCrudAction.Created;

    protected override async Task HandleAsync(PlatformCqrsEntityEvent<Employee> @event, CancellationToken ct)
        => await notificationService.SendAsync(@event.EntityData.Id);
}

⚠️ MUST READ: references/side-effects-patterns.md — side effects patterns

§5-7. Migrations, Jobs, Message Bus

⚠️ MUST READ: migration-patterns.md | job-patterns.md | messaging-patterns.md


Anti-Patterns

| Don't | Do | | --------------------------------- | ----------------------------------------------- | | throw new ValidationException() | PlatformValidationResult fluent API | | Side effects in command handler | Entity Event Handler in UseCaseEvents/ | | Direct cross-service DB access | Message bus | | DTO mapping in handler | PlatformEntityDto.MapToEntity() | | Separate Command/Handler files | ONE file: Command + Result + Handler | | protected bool HandleWhen() | public override async Task<bool> HandleWhen() |

Checklist

  • [ ] Service-specific repository, fluent validation (.And(), .AndAsync())
  • [ ] No side effects in command handlers, DTO mapping in DTO class
  • [ ] Cross-service uses message bus, jobs have maxConcurrent, migrations use dismissSendEvent: true

IMPORTANT Task Planning Notes

  • Always plan and break many small todo tasks
  • Always add a final review todo task to review the works done at the end to find any fix or enhancement needed

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/easyplatform-backend-development-net-mmlj2o1j/download' --output '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md.part' && mv '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md.part' '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Outils déclarés par l’auteur (à vérifier dans votre agent) : Read, Write, Edit, Grep, Glob, Bash

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md' && test -s '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/easyplatform-backend' && cp -R '.skill-downloads/easyplatform-backend-development-net-mmlj2o1j' '.claude/skills/easyplatform-backend'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/easyplatform-backend-development-net-mmlj2o1j'

openskills read 'easyplatform-backend-development-net-mmlj2o1j'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/easyplatform-backend-development-net-mmlj2o1j/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires