Guides setup and configuration of the CrestApps Orchard Core Tenant Hierarchy module for parent/child tenant multi-tenancy with delegated access, isolation guards, and database strategies.
Ships in crestapps-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 accurate setup, configuration, extension and troubleshooting guidance for the CrestApps Tenant Hierarchy module. A tenant the platform marks as a parent creates, manages and opens its own child tenants (for example a bookkeeping firm with one site per client business). The Default tenant stays the platform root and still manages every tenant through Orchard Core's Tenants admin.
CrestApps.OrchardCore.TenantHierarchy (or the CrestApps.OrchardCore.Cms.Core.Targets bundle) in the web/startup project.AddTenantHierarchy() on the Orchard Core builder in Program.cs, after Orchard Core is added. Without it the platform refuses to make parents and a parent refuses to create children.TenantHierarchy section of the application configuration. Tenant configuration cannot change it.__Host- cookies work.ITenantHierarchyBroker. Direct IShellHost calls across tenants throw TenantHierarchyAccessDeniedException, and HTTP calls between tenants are refused by the egress guard.{ "steps": [...] }.sealed modifier, except View Models.| Feature | Feature ID | Where it runs |
|---|---|---|
| Tenant Hierarchy Platform | CrestApps.OrchardCore.TenantHierarchy.Platform | Default tenant only (DefaultTenantOnly). Depends on OrchardCore.Tenants and CrestApps.OrchardCore.Resources |
| Parent Tenant | CrestApps.OrchardCore.TenantHierarchy.Parent | A parent, forced on when the platform makes it one. Depends on OrchardCore.Users, OrchardCore.Roles, CrestApps.OrchardCore.Resources, CrestApps.OrchardCore.Users (user picker) and OrchardCore.AuditTrail |
| Child Tenant | CrestApps.OrchardCore.TenantHierarchy.Child | Every child, forced on through the tenant Features configuration after setup. Depends on OrchardCore.Users and OrchardCore.Roles |
The Parent and Child features never depend on the Platform feature or OrchardCore.Tenants, because a dependency on a Default-only feature would make them unavailable elsewhere. See orchardcore-tenants for Orchard Core multi-tenancy and orchardcore-crestapps-users for the user picker.
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOrchardCms(orchardCore => orchardCore
.AddTenantHierarchy());
var app = builder.Build();
app.UseOrchardCore();
app.Run();
AddTenantHierarchy() (namespace Microsoft.Extensions.DependencyInjection, in CrestApps.OrchardCore.TenantHierarchy.Core) binds TenantHierarchyOptions, replaces IShellHost with GuardedShellHost, registers the built-in database provisioners, the parent removal guards, and per-tenant feature validation, egress guard and __Host- cookie setup, and adds the Fetch Metadata and unavailable-address middlewares. Each guard does nothing for a tenant that is neither a parent nor a child.
{
"TenantHierarchy": {
"PlatformDomain": "platform.com",
"Scheme": "https",
"UseHostPrefixedCookies": true,
"ReservedSlugs": [ "billing" ],
"Egress": {
"Enabled": true,
"BlockPrivateNetworks": true,
"AllowedHosts": [ "ollama.internal" ]
},
"DatabasePools": {
"firms": {
"DatabaseProvider": "Postgres",
"ConnectionString": "Host=db;Username=provisioner;Password=...",
"RetainRemovedDatabases": true
}
}
}
}
| Key | Default | Meaning |
|---|---|---|
PlatformDomain | Host of the request to Default | Parents are {slug}.{PlatformDomain}; may carry a port such as localhost:5000 |
Scheme | https (request scheme in development) | Scheme of addresses the module builds |
UseHostPrefixedCookies | On, except in development | __Host- prefix for parent and child cookies; needs HTTPS |
ReservedSlugs | Empty | Extra slugs no tenant may use (built in: admin, www, api, mail, login and others) |
Egress:Enabled / BlockPrivateNetworks / AllowedHosts | true / true / empty | Outbound HttpClient guard |
DatabasePools:{name}:DatabaseProvider | SqlConnection, Postgres, MySql or Sqlite | |
DatabasePools:{name}:ConnectionString | A login that can create databases, schemas and logins | |
DatabasePools:{name}:RetainRemovedDatabases | true | Rename a removed child database to {name}_removed_{timestamp} instead of dropping it |
Environment variables use __, for example TenantHierarchy__PlatformDomain=platform.com.
The parent policy (ParentTenantPolicy) is written into the parent's shell settings from the platform's Policy screen, or set as OrchardCore:{tenant}:TenantHierarchy:Policy:{key}. Keys and defaults are in references/tenant-hierarchy-reference.md.
TenantHierarchy:Role (Parent or Child), the policy and a child's TenantHierarchy:ParentTenantId are shell settings (tenant admins cannot edit them). The child registry, access grants, one-time codes, delegated sessions and favorites are in the parent's database, collection TenantHierarchy. Activity is in the parent's audit trail, category TenantHierarchy. User links are in the child's database.u_7k2m9q4x1c; its display name goes into the tenant Description and the parent's into Category.ITenantHierarchyBroker is the only path between tenants of a hierarchy. Requests carry an entry id from the parent's own registry, never a tenant name, and the link must hold both ways.GuardedShellHost lets a parent read its children and change them only inside a broker call; a child reaches its parent only inside a broker call; ordinary tenants cannot reach hierarchy tenants. Every tenant may reach Default.delegated-access/open/{entryId}, authorize, enter and callback, accept only top-level navigations, and send Cache-Control: no-store. The code has 256 random bits, is stored hashed, lives 60 seconds and is burned by the first attempt.{parent user name}+{parent slug} with exactly the roles its grants give. Child administrators cannot sign in as, edit, delete, re-role or set a password on a linked user.SessionValidationInterval and ends it when idle, too old, the parent user is disabled or signs out, changes their security stamp, or loses the grant.Hosted links to the parent's picker, Embedded frames it with frame-ancestors for that child only).| Feature | Rule |
|---|---|
| Parent Tenant | Available only in a parent |
| Child Tenant | Never offered; forced on through configuration |
| Tenant Hierarchy Platform | Default only |
OrchardCore.OpenId.Validation | Blocked in parents and children |
OrchardCore.Deployment.Remote | Blocked in children |
OrchardCore.Queries.Sql | Blocked in children sharing a database (schema or table prefix) |
Policy BlockedFeatures | Blocked in that parent's children |
The guard filters what can be enabled; it does not turn off a feature already on (the parent screen lists such features). Setup recipe steps that enable a blocked feature are ignored.
| Permission | Allows |
|---|---|
ManageTenantHierarchy | Platform screens (Default tenant) |
ViewChildTenants | Child tenant list; implied by the next five |
CreateChildTenants | Create, retry and discard children |
ManageChildTenants | Edit, suspend, resume and reload |
ManageChildFeatures | Enable and disable features in a child |
RemoveChildTenants | Remove and restore |
ManageChildAccess | Access grants |
EnterChildTenants | Base gate for opening a child; a grant is still needed |
When a tenant becomes a parent, a parent-wide grant gives the parent's Administrator role the child role Administrator in every child. Activity needs the audit trail's ViewAuditTrail (/Admin/AuditTrail?q=category:TenantHierarchy).
In a parent tenant (Parent Tenant feature), access grants travel with the TenantHierarchyAccessGrants recipe step (TenantHierarchyConstants.Recipes.AccessGrants) and the Child tenant access deployment step, both with CrestApps Recipes schemas. Each grant goes through the access grant manager as on the admin screen: a user is found by user name or email, the role must exist, and a grant for the same principal and child is updated instead of duplicated. A grant without a child covers every child; name a child by ChildEntryId, or by ChildSlug when the entry id is not known on this site. Grants carry no secret.
{
"steps": [
{
"name": "TenantHierarchyAccessGrants",
"Grants": [
{ "PrincipalType": "Role", "Principal": "Administrator", "ChildRoles": [ "Administrator" ] },
{ "PrincipalType": "User", "Principal": "ana", "ChildSlug": "north", "ChildRoles": [ "Editor" ] }
]
}
]
}
Expired delegated sign-in codes are purged by DelegatedAccessCodeRetentionPolicy, a policy on the shared retention building block (DocumentRetentionPolicyBase, AddRetentionPolicy<T>() in CrestApps.OrchardCore.YesSql.Core), five minutes after they expire.
The child tenant create, edit and remove pages and the platform's parent editor put their buttons in Orchard Core's sticky bottom action bar (<div class="action-bar-bottom">); a theme override of those views must render its buttons there too.
Built-in strategies (ChildDatabaseStrategy): SqlitePerChild (default), DatabasePerChild and SchemaPerChild (SQL Server, PostgreSQL), TablePrefixPerChild (any provider). To support another server, implement IChildTenantDatabaseProvisioner and register it as a host singleton after AddTenantHierarchy(). The first provisioner whose CanProvision returns true wins, and built-ins are registered first, so claim only what they do not handle:
builder.Services.AddSingleton<IChildTenantDatabaseProvisioner, MySqlChildDatabaseProvisioner>();
A full sample is in references/tenant-hierarchy-reference.md.
{firm}.platform.com for parents and {business}.{firm}.platform.com for children, with wildcard DNS and certificates for *.platform.com and each *.{firm}.platform.com.platform.com.OrchardCore.Tenants.Distributed, a shared shell settings store and a shared data protection key ring.Not included: federated OpenID Connect for children in another application, custom domains for children, inviting the business owner at creation, idle release of inactive children.
Each operation a parent runs on a child through TenantHierarchyBroker records crestapps.tenanthierarchy.child.operation.duration (operation = create, setup, update, suspend, resume, reload, remove, set_features; outcome = ok, failed, error, cancelled) and a span crestapps.tenanthierarchy.child.<operation> tagged with the registry entry id (crestapps.tenanthierarchy.entry.id), on the CrestApps.OrchardCore.TenantHierarchy meter and source. Tenant names never go on a metric or span tag. ChildTenantMaintenanceBackgroundTask reports on the shared crestapps.background_task.* instruments. See orchardcore-observability.
| Symptom | Cause and fix |
|---|---|
| Screens say The host guards are not installed | Call AddTenantHierarchy() in Program.cs and restart |
| Outbound request fails with it is the address of a tenant of this application | Tenants of a hierarchy do not call each other over HTTP. Use ITenantHierarchyBroker |
| Outbound request to an internal address fails | Add the host to Egress:AllowedHosts |
| Sign-in loops back to the sign-in page | __Host- cookies need HTTPS. Turn UseHostPrefixedCookies off only on a test machine |
TenantHierarchyAccessDeniedException logged | Code reached another tenant outside the broker; the log names both tenants |
| Child setup fails | Read the application log. The pool login must create databases, schemas and logins. Fix it, then Retry |
| Users signed out on another node | Share the data protection key ring and shell settings |
| A suspended child's address shows the platform sign-in | The app runs without AddTenantHierarchy(), so the unavailable-address guard is missing |
What SKILL.md sets; muted values are Claude Code's defaults
/crestapps-orchardcore:orchardcore-tenant-hierarchyfrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcore137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts.Other plugins' skills for the same job