Orchardcore recipes

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore recipes is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for authoring Orchard Core recipes and custom recipe steps. Covers recipe discovery, recipe manifests, setup recipes with issetuprecipe and step ordering, variables and the js and file expressions (uuid, variables, parameters, configuration, file text), execution and cancellation, built-in ste

How to use this skill

Skill file

Orchard Core Recipes

Recipes are JSON documents that configure a tenant through ordered steps. Use a recipe for repeatable setup, environment provisioning, deployment imports, or migration updates. Steps are processed in order and their names are case-insensitive at handler dispatch, but use the registered casing below and in the schemas.

Recipe location, discovery, and execution

Use .recipe.json, not arbitrary .json, for discovered extension recipes. Recipes can contain JSON comments, but generated automation should emit strict JSON unless comments are intentionally needed.

Authoring rules

Required reference workflow

  1. Start with references/recipe-schemas/recipe.schema.json for the root document.
  2. Open references/recipe-schemas/index.json and locate the schema for every planned step.
  3. Validate every step against that exact schema. Do not invent a step name, property, casing, or enum value.
  4. For ContentDefinition, combine its schema with orchardcore-content-fields and orchardcore-content-parts guidance, then validate the final JSON again.

Recipe schema references

Recipe structure

{
  "name": "MyModule.Baseline",
  "displayName": "My Module Baseline",
  "description": "Creates the baseline configuration.",
  "author": "My Team",
  "website": "https://example.invalid",
  "version": "1.0.0",
  "issetuprecipe": false,
  "categories": [ "Configuration" ],
  "tags": [ "baseline" ],
  "variables": {
    "now": "[js: new Date().toISOString()]"
  },
  "steps": []
}

Variables and expressions

A string value of the form [prefix: script] is evaluated before the step runs. Only two prefixes exist: js (JavaScript, the default scripting engine) and file.

| Expression | Result |

|------------|--------|

| [js: uuid()] | A new unique id (use for ContentItemId, WorkflowTypeId and similar). |

| [js: variables('name')] | A value from the recipe variables object. |

| [js: parameters('AdminUsername')] | A recipe environment value. The built-in providers supply SiteName, AdminUsername and AdminUserId (from setup or the site settings). |

| [js: configuration('Admin:AdminUrlPrefix', 'Admin')] | A tenant configuration value with a default. Keys are relative to the OrchardCore section (this reads OrchardCore:Admin:AdminUrlPrefix). Environment variables reach recipes only when they are under that section, for example OrchardCore__MY_SETTING read with configuration('MY_SETTING'); a root-level MY_SETTING is not exposed. |

| [js: base64('...')], [js: gzip('...')], [js: html('...')] | Decode base64, gzip plus base64, or HTML-encoded text. |

| [file:text('Snippets/home.liquid')] | The text of a file, relative to the recipe file. |

| [file:base64('Assets/logo.png')] | A file's bytes as base64 (for the media step Base64 property). |

{
  "variables": {
    "homeContentItemId": "[js: uuid()]"
  },
  "steps": [
    {
      "name": "Content",
      "data": [
        {
          "ContentItemId": "[js: variables('homeContentItemId')]",
          "ContentType": "Page",
          "DisplayText": "Home",
          "Latest": true,
          "Published": true,
          "TitlePart": { "Title": "Home" },
          "AutoroutePart": { "Path": "home", "SetHomepage": true }
        }
      ]
    },
    {
      "name": "Settings",
      "HomeRoute": {
        "Action": "Display",
        "Controller": "Item",
        "Area": "OrchardCore.Contents",
        "ContentItemId": "[js: variables('homeContentItemId')]"
      }
    }
  ]
}

Setup recipes

A setup recipe is an ordinary recipe with "issetuprecipe": true; it is listed on the setup screen (and in the tenant creation form) and provisions a new tenant. Ship it in the Recipes folder of your theme or module, or in the web project's Recipes folder.

Order the steps so each one finds what it needs:

  1. Feature, enabling every module and the site theme's own feature.
  2. Themes, setting site and admin.
  3. Settings (site name, time zone, home route, feature settings) and Roles.
  4. ContentDefinition, then index profiles (CreateOrUpdateIndexProfile) and Queries.
  5. Content, Media, Layers, Templates, AdminMenu, WorkflowType, and other data.
{
  "name": "MySite",
  "displayName": "My Site",
  "description": "Provisions a My Site tenant.",
  "author": "My Team",
  "website": "https://example.invalid",
  "version": "1.0.0",
  "issetuprecipe": true,
  "categories": [ "default" ],
  "tags": [ "mysite" ],
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Admin",
        "OrchardCore.Contents",
        "OrchardCore.ContentTypes",
        "OrchardCore.Title",
        "OrchardCore.Autoroute",
        "OrchardCore.HomeRoute",
        "OrchardCore.Themes",
        "TheAdmin",
        "MySite.Theme"
      ]
    },
    {
      "name": "Themes",
      "admin": "TheAdmin",
      "site": "MySite.Theme"
    }
  ]
}

Common built-in steps

The schema references remain the authority for each payload. These examples show the registered handler names and common casing.

Enable features, set site settings, and define content

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.ContentTypes",
        "OrchardCore.Title"
      ],
      "disable": []
    },
    {
      "name": "Settings",
      "SiteName": "Example",
      "TimeZoneId": "UTC"
    },
    {
      "name": "ContentDefinition",
      "ContentTypes": [
        {
          "Name": "Article",
          "DisplayName": "Article",
          "Settings": {
            "ContentTypeSettings": {
              "Creatable": true,
              "Listable": true,
              "Draftable": true,
              "Versionable": true
            }
          },
          "ContentTypePartDefinitionRecords": [
            {
              "PartName": "TitlePart",
              "Name": "TitlePart",
              "Settings": {}
            }
          ]
        }
      ],
      "ContentParts": []
    }
  ]
}

Import content and compose recipes

{
  "variables": {
    "now": "[js: new Date().toISOString()]"
  },
  "steps": [
    {
      "name": "Content",
      "data": [
        {
          "ContentItemId": "[js: uuid()]",
          "ContentItemVersionId": "[js: uuid()]",
          "ContentType": "Article",
          "DisplayText": "Welcome",
          "Latest": true,
          "Published": true,
          "CreatedUtc": "[js: variables('now')]",
          "ModifiedUtc": "[js: variables('now')]",
          "PublishedUtc": "[js: variables('now')]",
          "TitlePart": {
            "Title": "Welcome"
          }
        }
      ]
    },
    {
      "name": "Recipes",
      "Values": [
        {
          "executionid": "MyModule.Extras",
          "name": "MyModule.Extras"
        }
      ]
    }
  ]
}

Recipes runs a harvested recipe by its root name; executionid distinguishes that execution from other runs.

Run commands

The command step runs built-in commands, one per entry, as the command name followed by /Switch:value arguments. createUser is the one most useful in recipes (see orchardcore-users-roles).

{
  "steps": [
    {
      "name": "command",
      "Commands": [
        "createUser /UserName:editor /Password:{{EditorPassword}} /Email:editor@example.com /Roles:Editor"
      ]
    }
  ]
}

Other common registered steps

Use the matching schema before emitting any of these registered names: Themes, Layers, Queries, media, MediaProfiles, Roles, Users, Templates, AdminTemplates, ShortcodeTemplates, AdminMenu, Placements, WorkflowType, deployment, CreateOrUpdateIndexProfile, RebuildIndex, ResetIndex, Translations, Sitemaps, UrlRewriting, FeatureProfiles, custom-settings, custom-user-settings, DeleteContentDefinition, ReplaceContentDefinition, move-attached-media-fields, CreateOrUpdateRateLimitPolicies (see orchardcore-rate-limits), and provider-specific authentication settings. The provider-specific index steps lucene-index, lucene-index-reset, lucene-index-rebuild, ElasticIndexSettings, elastic-index-reset, elastic-index-rebuild and azureai-index-* are obsolete; use CreateOrUpdateIndexProfile, ResetIndex and RebuildIndex (see orchardcore-indexing).

The media step imports files listed under Files; each entry has a TargetPath plus one of SourcePath (relative to the recipe), SourceUrl or Base64.

{
  "steps": [
    {
      "name": "media",
      "Files": [
        {
          "TargetPath": "images/logo.png",
          "SourcePath": "../wwwroot/images/logo.png"
        }
      ]
    }
  ]
}

Reload the tenant

Some settings are cached at tenant start (for example CORS policies written by Settings) and otherwise take effect only after a feature change or restart. Orchard Core 4.0 adds a ReloadTenant step that requests a shell release when the recipe completes; place it after the steps whose settings must become live.

{
  "steps": [
    {
      "name": "ReloadTenant"
    }
  ]
}

DataPipelines (Orchard Core 4.0, OrchardCore.DataPipelines feature) imports data pipeline definitions under a Pipelines array. Validate it against references/recipe-schemas/DataPipelines.schema.json; for anything beyond a simple pipeline, export the pipelines with the Data Pipelines deployment step and reuse that payload (see orchardcore-data-pipelines).

Secrets (Orchard Core 4.0, OrchardCore.Secrets feature) creates or updates secrets. Use references/recipe-schemas/Secrets.schema.json: it accepts an array of { "Name", "Store", "Value" } entries or the encrypted object an export produces. Settings then reference a secret through their *SecretName properties, which only the generic Settings step accepts (see orchardcore-secrets).

Built-in recipes worth knowing

| Recipe name | Module | Purpose |

|---|---|---|

| OpenApiPkce | OrchardCore.OpenApi | Enables OpenID Server, Validation, and Management, the authorization-code flow with PKCE, local token validation, and a public openapi client for the Swagger and Scalar UIs. |

| OpenApiGeneration | OrchardCore.OpenApi | Enables every API-exposing feature and anonymous schema access for client generation (see orchardcore-openapi). |

| MediaApiPkce | OrchardCore.Media | Provisions a public media_gallery PKCE client so the Media Gallery can call api/media with bearer tokens (see orchardcore-media-gallery). |

| MediaApiStandalone | OrchardCore.Media | Configures the gallery as a standalone app on its own origin, with interactive login and CORS. |

The PKCE recipes contain a https://localhost:5001 origin in RedirectUris/PostLogoutRedirectUris and Default as the validation Tenant; copy the recipe and replace both before running it on a real tenant. Run them with the Recipes step or from Tools → Recipes.

Content definitions and features in 4.0

Define workflow types and deployment plans

WorkflowType imports serialized workflow definitions. Create workflows in the workflow designer, export them through the workflow deployment step, and use that exported data payload instead of hand-authoring activity IDs and transitions. Importing a WorkflowTypeId that already exists updates it as its next version (its instances are kept and its designer draft is discarded) instead of deleting and recreating it. See orchardcore-workflows for variables, expression syntaxes and the other properties.

{
  "steps": [
    {
      "name": "WorkflowType",
      "data": [
        {
          "WorkflowTypeId": "[js: uuid()]",
          "Name": "Example workflow",
          "IsEnabled": true,
          "Activities": [],
          "Transitions": []
        }
      ]
    }
  ]
}

The lowercase deployment step creates deployment plans. Its Type values must match enabled deployment step factories.

{
  "steps": [
    {
      "name": "deployment",
      "Plans": [
        {
          "Name": "Configuration",
          "Steps": [
            {
              "Type": "AllFeaturesDeploymentStep",
              "Step": {
                "Id": "[js: uuid()]",
                "Name": "AllFeatures"
              }
            }
          ]
        }
      ]
    }
  ]
}

Write a custom recipe step

Implement IRecipeStepHandler when a handler must inspect several names. For one named step, derive from NamedRecipeStepHandler; it compares context.Name case-insensitively and invokes HandleAsync only when the name matches. There is no [RecipeStep] attribute for handler discovery: registration is explicit.

RecipeExecutionContext provides ExecutionId, Name, Step as a JsonObject, RecipeDescriptor, nested recipes, and an Errors collection. Add a user-actionable error to context.Errors when input cannot be applied; do not silently ignore malformed required data.

using System.Text.Json.Nodes;
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using OrchardCore.Settings;

namespace MyModule.Recipes;

public sealed class MySettingsStep : NamedRecipeStepHandler
{
    private readonly ISiteService _siteService;

    public MySettingsStep(ISiteService siteService)
        : base("MySettings")
    {
        _siteService = siteService;
    }

    protected override async Task HandleAsync(RecipeExecutionContext context)
    {
        var enabled = context.Step["Enabled"]?.GetValue<bool>();

        if (enabled is null)
        {
            context.Errors.Add("MySettings requires an Enabled value.");
            return;
        }

        var site = await _siteService.LoadSiteSettingsAsync();
        site ??= new SiteSettings();
        site.Properties["MyModuleSettings"] = new JsonObject
        {
            ["Enabled"] = enabled.Value,
        };

        await _siteService.UpdateSiteSettingsAsync(site);
    }
}
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
using OrchardCore.Recipes;

namespace MyModule;

public sealed class Startup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddRecipeExecutionStep<MySettingsStep>();
    }
}

The exact API is AddRecipeExecutionStep<TImplementation>(); it registers the handler as a scoped IRecipeStepHandler. Add the feature that contains this startup before the custom step in a consuming recipe.

Upgrading from 3.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.