party-tph-catalog
Simplifies small lookup table management by using a shared polymorphic database structure.
Install
mkdir -p .claude/skills/party-tph-catalog && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17378" && unzip -o skill.zip -d .claude/skills/party-tph-catalog && rm skill.zipInstalls to .claude/skills/party-tph-catalog
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
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.Key capabilities
- →Add small polymorphic catalog dimensions
- →Implement Type-Per-Hierarchy (TPH) pattern for entities
- →Manage DTO inheritance for Info, Create, and Update operations
- →Register discriminators for derived types
- →Handle party-to-party links using `PartyRelation` table
How it works
The skill provides a pattern for small catalog dimensions to share a single table via TPH with a string discriminator, managing inheritance for entities, DTOs, and services.
Inputs & outputs
When to use party-tph-catalog
- →Add new lookup status
- →Create shared catalog entity
- →Implement polymorphic party pattern
About this skill
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.
- Inherit
Party(which already implementsIEntity<int>,IAuditableEntity,IStateEntity;Descriptionserves 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 { }
- Register the discriminator in
PartyConfiguration(.HasValue<Gender>(ResourceIdentifiers.Gender)), addDbSet<Gender> GenderstoAppDbSetter, and theResourceIdentifiersconstant. No new table/migration for the type itself (only if you added columns). - DTOs inherit the Party DTOs in one file:
InfoGenderDto : InfoPartyDto,CreateGenderDto : CreatePartyDto,UpdateGenderDto : UpdatePartyDto(reuseDeletePartyDto). - Service inherits
BasePartyService<TParty, TInfo, TCreate, TUpdate, TDelete>(int key, extendsPayloadService<>): callSetPolicies(_cachePolicies)in the constructor;CreateAsyncstampscreateDto.PartyType = typeof(TParty).Nameautomatically; type-scoped reads viaSearchByCriteriaByPartyTypeAsync<TDerived>(model)/ExportByPartyTypeAsync<TDerived>(...)which filter by discriminator through_repository.AsQueryableOfType<TDerived>(false). - Party-to-party links use the
PartyRelationtable (PartyId,RelatedPartyId,RelationshipType,StartDate/EndDate, notes; auditable) — don't invent join tables between dimensions. - 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
- Key is
int(Party owns it) — not theGuiddefault of full entities. - New properties on a derived type live on the shared table — keep them nullable or defaulted, or sibling inserts break.
- Forgetting the discriminator registration makes EF treat rows as base
Party— type-scoped queries return empty. SearchByCriteriaByPartyTypeAsynccaches under the first policy (falls back toCacheRoutes.Parties) — callSetPoliciesor you share the generic Parties cache.- 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
When not to use it
- →When entities have their own rich schema and require a full scaffold
- →When an entity needs its own table or a non-integer key
- →When a read-only projection is needed
Limitations
- →The key for entities implemented with this pattern is always `int`
- →New properties on derived types must be nullable or defaulted
- →Forgetting discriminator registration makes EF treat rows as base `Party`
How it compares
This skill offers a specialized pattern for small catalog entities, reusing a single table and inheritance, which is more efficient than scaffolding a full entity for each.
Compared to similar skills
party-tph-catalog side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| party-tph-catalog (this skill) | 0 | 25d | No flags | Intermediate |
| drizzle-orm | 32 | 1mo | No flags | Intermediate |
| django-pro | 20 | 3mo | No flags | Intermediate |
| event-store-design | 5 | 2mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
drizzle-orm
EpicenterHQ
Drizzle ORM patterns for type branding and custom types. Use when working with Drizzle column definitions, branded types, or custom type conversions.
django-pro
sickn33
Master Django 5.x with async views, DRF, Celery, and Django Channels. Build scalable web applications with proper architecture, testing, and deployment. Use PROACTIVELY for Django development, ORM optimization, or complex Django patterns.
event-store-design
wshobson
Design and implement event stores for event-sourced systems. Use when building event sourcing infrastructure, choosing event store technologies, or implementing event persistence patterns.
senior-backend
davila7
Comprehensive backend development skill for building scalable backend systems using NodeJS, Express, Go, Python, Postgres, GraphQL, REST APIs. Includes API scaffolding, database optimization, security implementation, and performance tuning. Use when designing APIs, optimizing database queries, implementing business logic, handling authentication/authorization, or reviewing backend code.
backend-development
skillcreatorai
Backend API design, database architecture, microservices patterns, and test-driven development. Use for designing APIs, database schemas, or backend system architecture.
postgresql
sickn33
Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features