/umbraco-cms-backoffice-testing-skills:umbraco-example-generatorfrom umbraco-cms-backoffice-testing-skills
Generates testable Umbraco backoffice extension examples with hot reload, supporting both internal and external extension paths.
Ships in umbraco-cms-backoffice-testing-skills. 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.
Generate complete, testable example extensions for the Umbraco backoffice and run them using the Umbraco source's dev infrastructure.
git clone https://github.com/umbraco/Umbraco-CMS
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
npm install
my-extension/
├── index.ts # REQUIRED - exports manifests
└── my-element.ts # Your element(s)
import './my-element.js';
export const manifests = [
{
type: 'dashboard',
alias: 'My.Dashboard',
name: 'My Dashboard',
element: 'my-element',
meta: { label: 'My Dashboard', pathname: 'my-dashboard' },
conditions: [{ alias: 'Umb.Condition.SectionAlias', match: 'Umb.Section.Content' }]
}
];
// my-element.ts
import { LitElement, html, customElement } from '@umbraco-cms/backoffice/external/lit';
@customElement('my-element')
export class MyElement extends LitElement {
render() {
return html`<uui-box headline="Hello">It works!</uui-box>`;
}
}
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
VITE_EXAMPLE_PATH=/full/path/to/my-extension VITE_UMBRACO_USE_MSW=on npm run dev
Open http://localhost:5173 - your extension appears in the Content section.
The Umbraco source (Umbraco-CMS/src/Umbraco.Web.UI.Client) provides two ways to load extensions:
npm run example)Examples placed in the examples/ folder inside the Umbraco source.
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
npm run example
# Select from list of examples
How it works: Sets VITE_EXAMPLE_PATH and imports ./examples/{name}/index.ts
VITE_EXAMPLE_PATH)Extensions from any location on your filesystem - perfect for developing packages.
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
VITE_EXAMPLE_PATH=/path/to/your/extension VITE_UMBRACO_USE_MSW=on npm run dev
How it works:
VITE_UMBRACO_USE_MSW=on mocks the core Umbraco APIsVITE_EXAMPLE_PATH is served through Vite's /@fs/ prefixindex.ts imports <VITE_EXAMPLE_PATH>/index.ts and registers its exports with umbExtensionsRegistry@umbraco-cms/backoffice, lit and @umbraco-ui/uui to the client's copy (avoids duplicate Lit/UUI)Absolute-path support (steps 2 & 4) needs a v18 client built with external-example support. When
running this repo's mocked E2E suites, the Playwright harness injects that support into the client
at UMBRACO_CLIENT_PATH automatically and reverts afterwards — see the umbraco-mocked-backoffice skill.
// From Umbraco-CMS/src/Umbraco.Web.UI.Client/index.ts
if (import.meta.env.VITE_EXAMPLE_PATH) {
const examplePath = import.meta.env.VITE_EXAMPLE_PATH;
// Absolute paths (external extensions) are served via Vite's /@fs/ prefix; relative paths load from ./
const importPath = examplePath.startsWith('/') ? '/@fs' + examplePath : './' + examplePath;
const js = await import(importPath + '/index.ts');
if (js) {
Object.keys(js).forEach((key) => {
const value = js[key];
if (Array.isArray(value)) {
umbExtensionsRegistry.registerMany(value);
} else if (typeof value === 'object') {
umbExtensionsRegistry.register(value);
}
});
}
}
Key point: Your index.ts must export manifests (arrays or objects) that get registered automatically.
Clone and set up the Umbraco source:
git clone https://github.com/umbraco/Umbraco-CMS
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
npm install
Your extension needs this minimal structure:
my-extension/
├── index.ts # Exports manifests array (REQUIRED)
├── my-element.ts # Your element(s)
├── my-context.ts # Context (if needed)
├── package.json # Optional - for IDE support and tests
├── tsconfig.json # Optional - for IDE support
└── README.md # Documentation
Your index.ts must export manifests that will be registered:
import './my-dashboard.element.js';
export const manifests = [
{
type: 'dashboard',
alias: 'My.Dashboard',
name: 'My Dashboard',
element: 'my-dashboard',
weight: 100,
meta: {
label: 'My Dashboard',
pathname: 'my-dashboard'
},
conditions: [
{
alias: 'Umb.Condition.SectionAlias',
match: 'Umb.Section.Content'
}
]
}
];
{
"name": "my-extension",
"type": "module",
"devDependencies": {
"@umbraco-cms/backoffice": "^18.0.0",
"typescript": "~5.8.0"
}
}
Important: The @umbraco-cms/backoffice dependency is only for IDE TypeScript support. At runtime, imports are resolved from the main Umbraco project.
cd /path/to/Umbraco-CMS/src/Umbraco.Web.UI.Client
VITE_EXAMPLE_PATH=/absolute/path/to/my-extension VITE_UMBRACO_USE_MSW=on npm run dev
Navigate to http://localhost:5173 - your extension is loaded automatically.
Changes to your extension files trigger hot reload - no restart needed.
// my-dashboard.element.ts
import { LitElement, html, css, customElement } from '@umbraco-cms/backoffice/external/lit';
@customElement('my-dashboard')
export class MyDashboardElement extends LitElement {
static override styles = css`
:host {
display: block;
padding: var(--uui-size-layout-1);
}
`;
override render() {
return html`
<uui-box headline="My Extension">
<p>Running in the mocked backoffice!</p>
</uui-box>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'my-dashboard': MyDashboardElement;
}
}
import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { EXAMPLE_MY_CONTEXT } from './my-context.js';
@customElement('example-my-feature-view')
export class ExampleMyFeatureViewElement extends UmbLitElement {
@state()
private _value?: string;
constructor() {
super();
this.consumeContext(EXAMPLE_MY_CONTEXT, (context) => {
this.observe(context.value, (value) => {
this._value = value;
});
});
}
override render() {
return html`
<uui-box headline="My Feature Example">
<p>Current value: ${this._value ?? 'Loading...'}</p>
</uui-box>
`;
}
}
export default ExampleMyFeatureViewElement;
declare global {
interface HTMLElementTagNameMap {
'example-my-feature-view': ExampleMyFeatureViewElement;
}
}
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import { UmbStringState } from '@umbraco-cms/backoffice/observable-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export class ExampleMyContext extends UmbContextBase {
#value = new UmbStringState('initial');
readonly value = this.#value.asObservable();
constructor(host: UmbControllerHost) {
super(host, EXAMPLE_MY_CONTEXT);
}
setValue(value: string) {
this.#value.setValue(value);
}
getValue() {
return this.#value.getValue();
}
public override destroy(): void {
this.#value.destroy();
super.destroy();
}
}
export const EXAMPLE_MY_CONTEXT = new UmbContextToken<ExampleMyContext>(
'ExampleMyContext'
);
export { ExampleMyContext as api };
Add unit tests using @open-wc/testing. See umbraco-unit-testing skill for full setup.
npm install --save-dev @open-wc/testing @web/test-runner @web/test-runner-playwright
Add E2E tests that run against the mocked backoffice. See umbraco-mocked-backoffice skill for patterns.
npm install --save-dev @playwright/test
npx playwright install chromium
Location: ./examples/workspace-feature-toggle/
A complete standalone example demonstrating:
UmbArrayStatecd examples/workspace-feature-toggle
npm install
npm test # Unit tests
npm run test:e2e # E2E tests (requires mocked backoffice running)
Location: Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/
27 official examples covering all extension types. Run any example:
cd Umbraco-CMS/src/Umbraco.Web.UI.Client
npm run example
# Select from list
| Item | Convention | Example |
|---|---|---|
| Directory | kebab-case describing feature | workspace-context-counter |
| Alias prefix | example. | example.workspaceView.counter |
| Element prefix | example- | example-counter-view |
| Context token | EXAMPLE_ + SCREAMING_CASE | EXAMPLE_COUNTER_CONTEXT |
index.ts exports a manifests arrayVITE_EXAMPLE_PATH is absolute📦 Loading external example from: messageImports should use @umbraco-cms/backoffice/*. The Vite plugin resolves these from the main project.
Your extension's node_modules is being used instead of the main project's. The external-example-resolver plugin should handle this, but ensure:
VITE_EXAMPLE_PATH=<abs> VITE_UMBRACO_USE_MSW=on npm run dev@umbraco-cms/backoffice/* not relative paths to node_modulesEnsure the file is within the path specified by VITE_EXAMPLE_PATH. Only files in that directory tree are watched.
examples/workspace-feature-toggle/README.md (opens in a new tab)examples/workspace-feature-toggle/feature-toggle-action.ts (opens in a new tab)examples/workspace-feature-toggle/feature-toggle-context.test.ts (opens in a new tab)examples/workspace-feature-toggle/feature-toggle-context.ts (opens in a new tab)examples/workspace-feature-toggle/feature-toggle-footer.element.ts (opens in a new tab)examples/workspace-feature-toggle/feature-toggle-view.element.ts (opens in a new tab)examples/workspace-feature-toggle/index.ts (opens in a new tab)examples/workspace-feature-toggle/package-lock.json (opens in a new tab)examples/workspace-feature-toggle/package.json (opens in a new tab)examples/workspace-feature-toggle/tests/feature-toggle.spec.ts (opens in a new tab)examples/workspace-feature-toggle/tests/playwright.config.ts (opens in a new tab)examples/workspace-feature-toggle/tests/warmup.setup.ts (opens in a new tab)examples/workspace-feature-toggle/tsconfig.json (opens in a new tab)examples/workspace-feature-toggle/web-test-runner.config.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
umbraco, extension-development, backoffice, example-generator
npx claudepluginhub umbraco/umbraco-cms-backoffice-skills --plugin umbraco-cms-backoffice-testing-skills8 skills in this plugin
/umbraco-e2e-testingE2E testing for Umbraco backoffice extensions using Playwright and @umbraco-cms/acceptance-test-helpers/umbraco-mocked-backofficeRun Umbraco backoffice with mocked APIs for visual extension testing/umbraco-msw-testingMSW (Mock Service Worker) patterns for testing Umbraco backoffice extensions with mocked APIs/umbraco-playwright-testhelpersReference for @umbraco/playwright-testhelpers package - fixtures, API helpers, and UI helpers for E2E testing/umbraco-test-buildersJsonModels.Builders for creating test data in Umbraco tests/umbraco-testingRouter skill for choosing the right testing approach for Umbraco backoffice extensionsOther plugins' skills for the same job