Catalogue TPH Party

VérifiéSûr

Modèle TPH pour dimensions de catalogue simples (Genre, BlogTag, etc.). Utilise une table Party unique avec discriminateur, DTOs hérités et service de base.

Spar Skills Guide Bot
DeveloppementIntermédiaire
24/07/2026
Claude CodeCursorWindsurfCopilotCodex
#party-pattern#tph#ef-core#discriminator#catalog-lookup

Recommandé pour

Synthèse automatique

Ce skill guide l'ajout d'une petite dimension de catalogue (tag, statut, genre) en héritant du modèle Party en TPH plutôt qu'en générant une entité complète.

Points forts

  • Explique la chaîne complète : entité Party, enregistrement du discriminateur, DTOs hérités, service dérivé de BasePartyService et endpoints
  • Rappelle les pièges concrets (clé int, colonnes supplémentaires nullables, oubli du discriminateur qui renvoie des requêtes vides)
  • Fournit un tableau de décision clair pour savoir quand appliquer le motif ou passer à un scaffold complet
  • Couvre les liens entre partis via PartyRelation sans inventer de tables de jointure

Limites

  • Très spécifique à une base de code .NET/EF Core avec les classes Party, BasePartyService et ResourceIdentifiers déjà en place
  • Suppose une familiarité avec TPH, la mise en cache par politiques et les conventions d'endpoints du projet
  • Peu utile hors de ce socle : les noms de classes et d'API ne sont pas génériques
Quand l'utiliser

Utilisez-le quand vous devez ajouter une lookup de type (id + description + état) partageant la table Parties au lieu d'une entité dédiée.

Quand l'éviter

Ne l'utilisez pas pour une entité avec un schéma riche, ses propres relations ou une clé non entière, qui relève d'un scaffold complet.

Analyse de sécurité

Sûr
Score qualité84/100

The skill is pure architectural documentation for an internal C# EF Core TPH pattern. It declares only Read, Grep and Glob — no bash, network, write, or execution capability — and contains no install scripts, curl|sh pipelines, credential handling, obfuscated payloads, or instructions to disable safety. All code blocks are illustrative C# class/registration snippets for a known in-house codebase, so there is no meaningful execution risk.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Add a BlogTag catalog type
Add a BlogTag catalog dimension using the Party TPH pattern: inherit Party with a Slug property, register the discriminator, create the inherited DTOs and a service derived from BasePartyService.
Add a status lookup
I need a new BlogPostStatus lookup (id + description + state). Should I use the party catalog pattern or scaffold a full entity? Walk me through the steps if it fits.
Debug empty type-scoped queries
My SearchByCriteriaByPartyTypeAsync<Gender> returns nothing even though rows exist. Check whether the Party discriminator is registered and SetPolicies is called.

name: "party-tph-catalog" description: "Use when adding a small polymorphic catalog dimension (Gender, BlogTag, BlogPostStatus, statuses, types, categories-as-lookup) instead of scaffolding a full entity. Covers the Party base (TPH, int key, PartyType discriminator), PartyRelation for party-to-party links, DTO inheritance from Info/Create/UpdatePartyDto, BasePartyService with SetPolicies and SearchByCriteriaByPartyTypeAsync, and discriminator registration. Domain: Persistence, Domain Modeling. Level: Intermediate. Tags: party, tph, discriminator, catalog, lookup." allowed-tools: [Read, Grep, Glob]

Activation

ACTIVATION:
  triggers:
    - "party pattern"
    - "catalog dimension"
    - "lookup table"
    - "TPH"
    - "new tag/status/type entity"
  context: decision-point | implementation
  anti-triggers:
    - "Entities with their own rich schema — use scaffold-template-entity"
    - "Anything needing its own table or non-int key"

Detail

Party (TPH) Catalog Pattern

Problem

Small catalog dimensions (Gender, BlogTag, BlogPostStatus, BlogPostVisibility…) each need audit fields, state, soft delete, permissions and CRUD — but giving each its own table + migration + full scaffold is overkill for rows that are basically (id, description).

Solution

All catalog dimensions share one table (Parties) via TPH with a PartyType string discriminator.

  1. Inherit Party (which already implements IEntity<int>, IAuditableEntity, IStateEntity; Description serves as the display name). New properties must be nullable/defaulted so they don't interfere with sibling types:
public class BlogTag : Party
{
    public string Slug { get; set; } = string.Empty;
    public string TagName => Description ?? string.Empty;   // computed alias for clarity
}
public class Gender : Party { }
  1. Register the discriminator in PartyConfiguration (.HasValue<Gender>(ResourceIdentifiers.Gender)), add DbSet<Gender> Genders to AppDbSetter, and the ResourceIdentifiers constant. No new table/migration for the type itself (only if you added columns).
  2. DTOs inherit the Party DTOs in one file: InfoGenderDto : InfoPartyDto, CreateGenderDto : CreatePartyDto, UpdateGenderDto : UpdatePartyDto (reuse DeletePartyDto).
  3. Service inherits BasePartyService<TParty, TInfo, TCreate, TUpdate, TDelete> (int key, extends PayloadService<>): call SetPolicies(_cachePolicies) in the constructor; CreateAsync stamps createDto.PartyType = typeof(TParty).Name automatically; type-scoped reads via SearchByCriteriaByPartyTypeAsync<TDerived>(model) / ExportByPartyTypeAsync<TDerived>(...) which filter by discriminator through _repository.AsQueryableOfType<TDerived>(false).
  4. Party-to-party links use the PartyRelation table (PartyId, RelatedPartyId, RelationshipType, StartDate/EndDate, notes; auditable) — don't invent join tables between dimensions.
  5. Endpoints/permissions follow the standard recipe (GenderEndpoints : IEndpointDefinition, attribute triad).

Applicability

| Condition | Apply? | |---|---| | Small lookup shared-shape dimension (id + description + state) | ✅ Yes | | Dimension with 1-3 extra nullable columns | ✅ Yes | | Entity with rich schema, relations, own lifecycle | ❌ No — full scaffold | | Read-only projection | ❌ No — QueryPayloadService<> |

Gotchas

  1. Key is int (Party owns it) — not the Guid default of full entities.
  2. New properties on a derived type live on the shared table — keep them nullable or defaulted, or sibling inserts break.
  3. Forgetting the discriminator registration makes EF treat rows as base Party — type-scoped queries return empty.
  4. SearchByCriteriaByPartyTypeAsync caches under the first policy (falls back to CacheRoutes.Parties) — call SetPolicies or you share the generic Parties cache.
  5. Root SKILL.md declares this pattern as its anti-trigger — one entry point per flow: full entity → root skill, catalog dimension → this one.

Related Skills

  • scaffold-template-entity, permission-model, cache-policy-eviction

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/party-tph-catalog-mryiqfv1/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/party-tph-catalog-mryiqfv1' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/party-tph-catalog-mryiqfv1/download' --output '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md.part' && mv '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md.part' '.skill-downloads/party-tph-catalog-mryiqfv1/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.

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/party-tph-catalog-mryiqfv1/SKILL.md' && test -s '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/party-tph-catalog' && cp -R '.skill-downloads/party-tph-catalog-mryiqfv1' '.claude/skills/party-tph-catalog'

Cursor
test -f '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md' && test -s '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/party-tph-catalog' && cp -R '.skill-downloads/party-tph-catalog-mryiqfv1' '.cursor/skills/party-tph-catalog'

Codex
test -f '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md' && test -s '.skill-downloads/party-tph-catalog-mryiqfv1/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/party-tph-catalog' && cp -R '.skill-downloads/party-tph-catalog-mryiqfv1' '.agents/skills/party-tph-catalog'

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/party-tph-catalog-mryiqfv1'

openskills read 'party-tph-catalog-mryiqfv1'

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/party-tph-catalog-mryiqfv1/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