Provides guidance on Orchard Core content item lifecycle, IContentManager API, querying with YesSql, content handlers, recipe import/export, and programmatic access to parts and fields.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an Orchard Core expert. Generate code and configuration for managing content items in Orchard Core.
ContentItemId (stable across versions) and a ContentItemVersionId (unique per version).IContentManager for all content item CRUD operations; do not manipulate the database directly.ValidateAsync returns a ContentValidateResult and does not cancel the
current session. If validation follows a mutation, call
ISession.CancelAsync() explicitly when the result fails.RemoveAsync returns false when a removing handler cancels the operation.Draftable.Versionable.await ISession.SaveChangesAsync() or let the request pipeline flush changes when modifying content outside of IContentManager.IContentHandler to hook into lifecycle events such as creating, publishing, and removing content.OrchardCore.Contents for the content-management UI and API endpoints. Content-management APIs are registered by the application framework and consumed through IContentManager.A content item progresses through the following states:
NewAsync, not yet persisted.Published = true and Latest = true.When a published content item is edited, a new draft version is created while the published version remains live. Publishing the draft replaces the previous published version.
{
"ContentItemId": "{{unique-content-item-id}}",
"ContentItemVersionId": "{{unique-version-id}}",
"ContentType": "{{ContentTypeName}}",
"DisplayText": "{{Display Title}}",
"Latest": true,
"Published": true,
"CreatedUtc": "2025-01-01T00:00:00Z",
"ModifiedUtc": "2025-01-01T00:00:00Z",
"PublishedUtc": "2025-01-01T00:00:00Z",
"Owner": "{{userId}}",
"Author": "{{userName}}",
"TitlePart": {
"Title": "{{Display Title}}"
},
"AutoroutePart": {
"Path": "{{url-slug}}",
"SetHomepage": false
},
"{{ContentTypeName}}": {
"{{FieldName}}": {
"Text": "{{field value}}"
}
}
}
Use IContentManager to perform all content item operations:
public sealed class {{ServiceName}}
{
private readonly IContentManager _contentManager;
public {{ServiceName}}(IContentManager contentManager)
{
_contentManager = contentManager;
}
public async Task ManageContentAsync()
{
// Create a new content item in memory (not yet saved).
var contentItem = await _contentManager.NewAsync("{{ContentTypeName}}");
// Persist the content item as a draft.
await _contentManager.CreateAsync(contentItem, VersionOptions.Draft);
// Retrieve a content item by its ID (latest version).
var latest = await _contentManager.GetAsync(
contentItem.ContentItemId, VersionOptions.Latest);
// Retrieve the published version of a content item.
var published = await _contentManager.GetAsync(
contentItem.ContentItemId, VersionOptions.Published);
// Retrieve several content items in one query (published by default).
var items = await _contentManager.GetAsync(
["{{id1}}", "{{id2}}"], VersionOptions.Published);
// Update an existing content item.
await _contentManager.UpdateAsync(contentItem);
// Publish a draft content item.
await _contentManager.PublishAsync(contentItem);
// Unpublish a published content item (revert to draft).
await _contentManager.UnpublishAsync(contentItem);
// Remove (soft-delete) a content item. The result is false when a
// removing handler cancels the operation.
var removed = await _contentManager.RemoveAsync(contentItem);
}
}
Reads by id (GetAsync(id) and GetAsync(ids)) use the IDX_ContentItemIndex_ContentItemId SQL index added in Orchard Core 4.0 (ContentItemId, DocumentId, Published, Latest). Prefer one batched GetAsync(ids) over a loop of single reads. GetVersionAsync seeks IDX_ContentItemIndex_ContentItemVersionId, and filters on one content type or owner seek IDX_ContentItemIndex_ContentType / IDX_ContentItemIndex_Owner (see orchardcore-content-queries).
When a content type generates its title from a TitlePart pattern, the pattern is also evaluated when a version is published (Orchard Core 4.0), so republishing an item sets its display text from the pattern, at most once per item per request.
/Admin/Contents/ContentItems accepts several content types or stereotypes, as repeated or comma-separated values (Orchard Core 4.0); single values work as before:
/Admin/Contents/ContentItems?contentTypeId=Article&contentTypeId=BlogPost
/Admin/Contents/ContentItems?contentTypeId=Article,BlogPost
/Admin/Contents/ContentItems?stereotype=Widget,Page
Use these URLs in admin menu links (see orchardcore-admin-menu) to give editors a list scoped to a family of types. Column providers of the list receive the filtered types and stereotypes under ContentsAdminList.ContentTypesKey and ContentsAdminList.StereotypesKey (see orchardcore-admin-lists).
Content items store data in parts and fields. Use TryGet<T>() and Get<T>() for reads, and GetOrCreate<T>() when you intentionally need a writable part instance:
public sealed class {{ServiceName}}
{
private readonly IContentManager _contentManager;
public {{ServiceName}}(IContentManager contentManager)
{
_contentManager = contentManager;
}
public async Task ReadPartAndFieldValuesAsync(string contentItemId)
{
var contentItem = await _contentManager.GetAsync(
contentItemId, VersionOptions.Published);
// Access a well-known part using the strongly-typed helper.
var title = contentItem.TryGet<TitlePart>(out var titlePart)
? titlePart.Title
: null;
// Access a named part as a content element.
var customPart = contentItem.Get<ContentPart>("{{ContentTypeName}}");
// Access a field within the named part.
var textField = customPart?.Get<TextField>("{{FieldName}}");
var fieldValue = textField?.Text;
}
public async Task SetPartAndFieldValuesAsync()
{
var contentItem = await _contentManager.NewAsync("{{ContentTypeName}}");
// Set a well-known part value.
contentItem.Alter<TitlePart>(part =>
{
part.Title = "{{Title}}";
});
// Set a field value on a named part.
contentItem.Alter<ContentPart>("{{ContentTypeName}}", part =>
{
part.Alter<TextField>("{{FieldName}}", field =>
{
field.Text = "{{value}}";
});
});
await _contentManager.CreateAsync(contentItem, VersionOptions.Published);
}
}
Use ISession to query content items through YesSql indexes:
public sealed class {{ServiceName}}
{
private readonly ISession _session;
public {{ServiceName}}(ISession session)
{
_session = session;
}
public async Task<IEnumerable<ContentItem>> QueryContentItemsAsync()
{
// Query published content items of a specific type.
var items = await _session
.Query<ContentItem, ContentItemIndex>(index =>
index.ContentType == "{{ContentTypeName}}"
&& index.Published)
.ListAsync();
return items;
}
public async Task<ContentItem?> FindByDisplayTextAsync(string displayText)
{
// Query by display text.
var item = await _session
.Query<ContentItem, ContentItemIndex>(index =>
index.DisplayText == displayText
&& index.Published)
.FirstOrDefaultAsync();
return item;
}
}
Implement IContentHandler to respond to content lifecycle events. Handlers are invoked by IContentManager during create, update, publish, unpublish, and remove operations:
Taxonomy terms and menu items are stored inside their taxonomy or menu, not saved through IContentManager. Their admin editors still raise Creating/Created when a term or menu item is added and Updating/Updated when it is edited (#20232), so handlers (and what is built on them, such as the content workflow events) see those items too. Created/Updated run only when the editor is valid; no Publishing, Removing or versioning events are raised for them. Check ContentType when a handler must ignore them.
public sealed class {{HandlerName}} : ContentHandlerBase
{
private readonly ILogger<{{HandlerName}}> _logger;
public {{HandlerName}}(ILogger<{{HandlerName}}> logger)
{
_logger = logger;
}
public override Task PublishedAsync(PublishContentContext context)
{
if (context.ContentItem.ContentType == "{{ContentTypeName}}")
{
_logger.LogInformation(
"Content item '{DisplayText}' was published.",
context.ContentItem.DisplayText);
}
return Task.CompletedTask;
}
public override Task RemovedAsync(RemoveContentContext context)
{
if (context.ContentItem.ContentType == "{{ContentTypeName}}")
{
_logger.LogInformation(
"Content item '{DisplayText}' was removed.",
context.ContentItem.DisplayText);
}
return Task.CompletedTask;
}
}
Register the handler in a Startup class:
public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IContentHandler, {{HandlerName}}>();
}
}
Common handler methods include:
CreatingAsync / CreatedAsync - Before and after a new content item is persisted.UpdatingAsync / UpdatedAsync - Before and after an existing content item is updated.PublishingAsync / PublishedAsync - Before and after a content item is published.UnpublishingAsync / UnpublishedAsync - Before and after a content item is unpublished.RemovingAsync / RemovedAsync - Before and after a content item is removed.LoadingAsync / LoadedAsync - When a content item is loaded from the store.CreatingAsync and UpdatingAsync run before the corresponding persistence
operation. CreatedAsync and UpdatedAsync run after it. Use the matching
context type (CreateContentContext or UpdateContentContext) and do not
treat an update as a create operation.
ValidateAsync only invokes validation handlers and returns the result. It no
longer cancels the session for an invalid item. Cancel a preceding mutation
explicitly when required:
public sealed class ContentValidationService
{
private readonly IContentManager _contentManager;
private readonly ISession _session;
public ContentValidationService(
IContentManager contentManager,
ISession session)
{
_contentManager = contentManager;
_session = session;
}
public async Task<bool> UpdateAsync(ContentItem contentItem)
{
await _contentManager.UpdateAsync(contentItem);
var result = await _contentManager.ValidateAsync(contentItem);
if (!result.Succeeded)
{
await _session.CancelAsync();
return false;
}
return true;
}
}
When a removing handler sets RemoveContentContext.Cancel, check the boolean
returned by RemoveAsync to detect the canceled operation.
Use the content recipe step to import content items. Use a deployment plan when exporting content.
{
"steps": [
{
"name": "Content",
"data": [
{
"ContentItemId": "{{unique-id-1}}",
"ContentType": "{{ContentTypeName}}",
"DisplayText": "{{Title}}",
"Latest": true,
"Published": true,
"TitlePart": {
"Title": "{{Title}}"
},
"{{ContentTypeName}}": {
"{{FieldName}}": {
"Text": "{{value}}"
}
}
}
]
}
]
}
data array represents a content item to import.ContentItemId to a stable unique value to allow re-importing without duplicates.Published to true to publish the item immediately upon import.ContentElement is the base class for all content components. It exposes the parent ContentItem reference and JSON data access.ContentPart extends ContentElement and represents a composable unit attached to a content type (e.g., TitlePart, AutoroutePart).ContentField extends ContentElement and represents a data field within a part (e.g., TextField, HtmlField, NumericField).ContentPart or ContentField respectively.BlogPost in a content item's JSON can be the synthetic part that holds fields attached directly to the type definition. It is not a CLR ContentPart unless the application defines and registers one.public sealed class {{PartName}} : ContentPart
{
public string? Subtitle { get; set; }
public bool IsFeatured { get; set; }
}
Official Orchard Core videos shown on the documentation page:
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-content-itemsfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard./orchardcore-admin-edit-viewsSkill for writing Orchard Core admin editor views with the ocat CSS classes and cards. Covers Edit views for content parts and fields, field editor variants, part, field and site settings editors, Fields.Edit views, admin pages rendering Model.Editor built with IDisplayManager, the ocat classes and their layout rules, label associations and group captions, part and field wrapper classes, validation, hints and the Hint_Admin shape, cards declared in placement and the Card and CardContainer shapes, split editor shapes, tabs and columns, the edit page action bar, the horizontal form layout, and the UI text casing standard. Use this skill when requests mention Orchard Core admin edit views, admin forms, grouping fields in cards, Edit.cshtml, Fields.Edit.cshtml, Settings.Edit.cshtml, ocat classes, label casing, or field hints. Strong matches include ocat-wrapper, ocat-card, Hint_Admin, PlacementLocationBuilder, IDisplayManager, ContentPartDisplayDriver, SiteDisplayDriver./orchardcore-admin-listsSkill for Orchard Core 4.0 admin index views (list pages) rendered with the AdminList shape. Covers the List and Grid layouts, AdminListContext of TModel, the admin-list and admin-list-column tag helpers, column width and alignment, row display drivers placing shapes for SummaryAdmin and SummaryAdminGrid, row templates and zones, AdminListActions Buttons and Menu layouts, AdminListToolbar, AdminListSearch, the list-management script for select-all and bulk actions, IAdminListColumnsProvider, AdminListOptions, user layout selection, per-list alternates, sortable lists, and upgrading overridden list views. Use this skill when requests mention Orchard Core admin index views, an admin index page, admin lists, converting a hand-written admin listing, grid layout, list columns, row actions menu, or adding a column to the content items list. Strong matches include OrchardCore.Admin.Abstractions, AdminListContext, AdminListColumn, IAdminListColumnsProvider, AdminListOptions, AdminListLayout, ContentsAdminList./orchardcore-admin-menuSkill for creating admin menus in Orchard Core. Covers admin menu content, the link, placeholder, content types, and lists admin node types, the AdminMenu recipe and deployment step, ManageAdminMenu, ViewAdminMenuAll and per-menu ViewAdminMenu permissions from AdminMenuPermissions, custom admin nodes with AdminNode, IAdminNodeNavigationBuilder and AddAdminNode, data localization of node text, rendering in the 4.0 TheAdmin menu, and upgrading from the removed legacy admin menu layout. Use this skill when requests mention Orchard Core Admin Menu, Create and Manage Admin Menus, Admin Menu Deployment Recipe Step, Built-In Admin Node Types, Custom Admin Node Class, LegacyAdminMenuNavigation, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminMenu, OrchardCore.AdminMenu.Abstractions, AdminMenuPermissions, LinkAdminNode, PlaceholderAdminNode, OrchardCore.Lists, OrchardCore.Navigation./orchardcore-admin-schemesSkill for the Orchard Core 4.0 TheAdmin redesign and its admin schemes. Covers scheme records with their four colors, typography, density, corners, horizontal form layout and content width, Design > Themes > Schemes, the default scheme, the per-user scheme picker and its cookie, the seven built-in schemes, the AdminSchemes recipe step and Admin Schemes deployment step, the schemes.css stylesheet, the --ta-* design tokens, ta-content-fluid, dark mode utilities and nested color modes, TheOldAdmin and how to switch to it, and the breaking changes for custom admin themes and Layout overrides. Use this skill when requests mention admin schemes, admin colors, rebranding TheAdmin, dark mode of the admin, the admin content width, the horizontal form layout, TheOldAdmin, or upgrading a custom admin theme to the new TheAdmin. Strong matches include AdminScheme, AdminSchemes, DefaultSchemeId, HorizontalFormLayout, ContentWidth, data-ta-scheme, --ta-primary, ta-content-fluid, TheOldAdmin, and OrchardCore.Themes.TheAdmin.Other plugins' skills for the same job