content-relationships
Use when designing references between content items, content picker fields, many-to-many relationships, or bidirectional links. Covers relationship types, reference integrity, eager/lazy loading, and relationship APIs for headless CMS.
What this skill does
# Content Relationships
Guidance for designing and implementing relationships between content items in headless CMS architectures.
## When to Use This Skill
- Adding content picker fields to content types
- Designing author-article relationships
- Implementing related content features
- Building content hierarchies (parent/child pages)
- Managing bidirectional relationships
- Handling reference integrity on delete
## Relationship Types
### One-to-Many (Parent Reference)
```csharp
// Article has one Author
public class Article
{
public Guid Id { get; set; }
public string Title { get; set; } = string.Empty;
// Foreign key to Author
public Guid AuthorId { get; set; }
public Author? Author { get; set; }
}
public class Author
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
// Navigation property (inverse)
public List<Article> Articles { get; set; } = new();
}
```
### Many-to-Many (Junction Table)
```csharp
// Article has many Categories, Category has many Articles
public class Article
{
public Guid Id { get; set; }
public string Title { get; set; } = string.Empty;
public List<ArticleCategory> ArticleCategories { get; set; } = new();
}
public class Category
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public List<ArticleCategory> ArticleCategories { get; set; } = new();
}
public class ArticleCategory
{
public Guid ArticleId { get; set; }
public Article Article { get; set; } = null!;
public Guid CategoryId { get; set; }
public Category Category { get; set; } = null!;
// Optional: relationship metadata
public int Order { get; set; }
public bool IsPrimary { get; set; }
}
// EF Core configuration
modelBuilder.Entity<ArticleCategory>()
.HasKey(ac => new { ac.ArticleId, ac.CategoryId });
```
### Self-Referential (Hierarchy)
```csharp
// Page hierarchy
public class Page
{
public Guid Id { get; set; }
public string Title { get; set; } = string.Empty;
public Guid? ParentId { get; set; }
public Page? Parent { get; set; }
public List<Page> Children { get; set; } = new();
// Computed path for efficient queries
public string Path { get; set; } = string.Empty;
public int Depth { get; set; }
}
```
### Polymorphic References (Any Content Type)
```csharp
// Reference to any content item
public class ContentReference
{
public Guid ReferencingItemId { get; set; }
public string ReferencingItemType { get; set; } = string.Empty;
public Guid ReferencedItemId { get; set; }
public string ReferencedItemType { get; set; } = string.Empty;
public string RelationshipType { get; set; } = string.Empty; // "related", "featured", "see-also"
public int Order { get; set; }
}
// Usage: Article references Product, Page, or another Article
```
## Content Picker Field Pattern
### Generic Content Picker
```csharp
public class ContentPickerField
{
// Allowed content types for this picker
public List<string> AllowedContentTypes { get; set; } = new();
// Selected content item IDs
public List<Guid> ContentItemIds { get; set; } = new();
// Min/max selection
public int? MinItems { get; set; }
public int? MaxItems { get; set; }
// Display options
public bool ShowContentType { get; set; } = true;
public string DisplayTemplate { get; set; } = "{Title}";
}
// Stored in JSON column
public class ArticleExtensions
{
public ContentPickerField? RelatedArticles { get; set; }
public ContentPickerField? FeaturedProducts { get; set; }
}
```
### Resolved References for API
```csharp
public class ContentPickerFieldDto
{
public List<Guid> ContentItemIds { get; set; } = new();
// Optionally include resolved items
public List<ContentItemSummary>? Items { get; set; }
}
public class ContentItemSummary
{
public Guid Id { get; set; }
public string ContentType { get; set; } = string.Empty;
public string DisplayText { get; set; } = string.Empty;
public string? Url { get; set; }
public string? ThumbnailUrl { get; set; }
}
```
## Relationship Loading Strategies
### Eager Loading
```csharp
// Load relationships with initial query
public async Task<Article?> GetArticleWithRelationsAsync(Guid id)
{
return await _context.Articles
.Include(a => a.Author)
.Include(a => a.ArticleCategories)
.ThenInclude(ac => ac.Category)
.FirstOrDefaultAsync(a => a.Id == id);
}
```
### Explicit Loading
```csharp
// Load relationships on demand
public async Task LoadAuthorAsync(Article article)
{
await _context.Entry(article)
.Reference(a => a.Author)
.LoadAsync();
}
public async Task LoadCategoriesAsync(Article article)
{
await _context.Entry(article)
.Collection(a => a.ArticleCategories)
.Query()
.Include(ac => ac.Category)
.LoadAsync();
}
```
### Projection for API
```csharp
// Only load what's needed for the response
public async Task<ArticleDto?> GetArticleDtoAsync(Guid id)
{
return await _context.Articles
.Where(a => a.Id == id)
.Select(a => new ArticleDto
{
Id = a.Id,
Title = a.Title,
AuthorName = a.Author!.Name,
Categories = a.ArticleCategories
.Select(ac => ac.Category.Name)
.ToList()
})
.FirstOrDefaultAsync();
}
```
## Bidirectional Relationships
### Maintaining Both Directions
```csharp
public class RelatedContent
{
public Guid SourceId { get; set; }
public Guid TargetId { get; set; }
public string RelationType { get; set; } = string.Empty;
public bool IsBidirectional { get; set; }
}
public class ContentRelationshipService
{
public async Task AddRelationshipAsync(
Guid sourceId,
Guid targetId,
string relationType,
bool bidirectional = true)
{
// Add forward relationship
await _repository.AddAsync(new RelatedContent
{
SourceId = sourceId,
TargetId = targetId,
RelationType = relationType,
IsBidirectional = bidirectional
});
// Add reverse relationship if bidirectional
if (bidirectional)
{
await _repository.AddAsync(new RelatedContent
{
SourceId = targetId,
TargetId = sourceId,
RelationType = GetReverseType(relationType),
IsBidirectional = true
});
}
}
private string GetReverseType(string type) => type switch
{
"parent-of" => "child-of",
"child-of" => "parent-of",
"references" => "referenced-by",
_ => type // symmetric relationships like "related-to"
};
}
```
## Reference Integrity
### Delete Behaviors
```csharp
public enum ReferenceDeleteBehavior
{
Restrict, // Prevent delete if referenced
Cascade, // Delete referencing items
SetNull, // Clear the reference
NoAction // Leave orphans (handle in app)
}
// EF Core configuration
modelBuilder.Entity<Article>()
.HasOne(a => a.Author)
.WithMany(a => a.Articles)
.HasForeignKey(a => a.AuthorId)
.OnDelete(DeleteBehavior.Restrict);
```
### Orphan Detection
```csharp
public class OrphanDetectionService
{
public async Task<List<ContentReference>> FindOrphanReferencesAsync()
{
// Find references where target no longer exists
return await _context.ContentReferences
.Where(r => !_context.ContentItems
.Any(c => c.Id == r.ReferencedItemId))
.ToListAsync();
}
public async Task<List<ContentItem>> FindUnreferencedContentAsync(
string contentType)
{
// Find content not referenced by anything
var referencedIds = await _context.ContentReferences
.Where(r => r.ReferencedItemType == conteRelated in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.