"Create or modify a hand-authored contract (DTO/entity) in a CoreEx domain. USE FOR: new root entity contract, new subordinate/request contract, modifying an existing contract (add property, add interface, wire ref-data), extracting a shared base class. DO NOT USE FOR: reference-data contracts (generated via coreex-refdata / *.CodeGen), Infrastructure persistence models (generated by *.Database CodeGen)."
Recursos
1Instal·la
npx skillscat add avanade/coreex/coreex-contract Instal·la des del registre de SkillsCat.
CoreEx: Contract
Guides you through creating or modifying a hand-authored contract (DTO/entity) in *.Contracts. Covers root entities, subordinate types, request/response objects, and base class extraction.
When to Use
- New root entity contract — independently identifiable, persisted, has its own API endpoint
- New subordinate, line-item, or request/response contract (accessed via a parent — may still carry its own identifier)
- Adding or changing properties on an existing contract
- Wiring a ref-data navigation property (
[ReferenceData<T>]) on an existing contract - Extracting a shared base class when ≥2 contracts repeat the same fields and every shared field is meaningful on each (genuine superset) — not for patch/subset request contracts
When Not to Use
- Reference data contracts (generated by
*.CodeGenfromref-data.yaml) — usecoreex-refdata - Infrastructure persistence models (generated by
*.DatabaseCodeGen fromdbex.yaml) - Domain aggregates, entities, value objects — see
coreex-domain.instructions.mdand thecoreex-aggregateskill (DDD domains only)
Quick Reference
Clarifying questions to ask before emitting any code:
0. Resolve from state first. Read the solution-root AGENTS.md Feature Configuration for refdata-enabled (whether [ReferenceData<T>] wiring applies) and check whether a *.Domain project exists (aggregate-mapping context). Only ask for what is unresolved; re-state resolved values for confirmation.
- Root or subordinate? (if not explicit)
- Identifier type? (default
string?— confirm before using any other type) IETagneeded? (default yes for root contracts — omit only on explicit request)IChangeLogneeded? (ask for root contracts — add when created/updated audit trail is required)- Sub-folder within
*.Contracts? (default: flat root — only create one if requested) [Schema]override? (only if user explicitly requests a custom event schema name/version)
Key rules at a glance:
[Contract]+partialon all contract classes by default- Only
[ReferenceData<T>]properties arepartial— never make plain propertiespartial(CS9248) [ReadOnly(true)]on all server-assigned fields (Id,ETag,ChangeLog, computed/derived)[NonNullable]on any property that is mandatory/required (ultimately not nullable) but declared nullable (string?,int?) for DTO flexibility — drivesnullable: falsein OpenAPI; not the same asSystem.Diagnostics.CodeAnalysis.NotNull. Never onId/ETag/ChangeLog; on other[ReadOnly]properties only when the type is never a request body- Every property needs a
<summary>XML doc comment - Same contract type for both API response and event payload — never split them
- Patch/subset contracts (merge-patch, partial-update requests): standalone class with only the needed fields (+
IETag) — never inherit a sibling and suppress the rest; inheritance is for genuine supersets only
For full workflow, decision trees, and code examples see `references/workflow.md`.
Key References
- `/.github/instructions/coreex-contracts.instructions.md` — full contract conventions: interfaces, source generation, property rules, localization, inheritance
- `/.github/instructions/coreex-conventions.instructions.md` — XML doc comments, expression bodies, brace style
- Related skills: `coreex-refdata` (generated ref-data contracts), `coreex-aggregate` (DDD domain object the contract maps to), `coreex-repository` (mapping), `coreex-app-service` (consumes contracts)
- Illustrative examples (CoreEx sample — not present in your project):
- multi-contract examples — base class, root entity, subordinate, ref-data extension
- request/response and subordinate contracts