Agent skill
component
Generate an Angular component with signals, OnPush, and host-based styling following Momentum CMS conventions. Use when creating new UI components in any library.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/component
SKILL.md
Generate Angular Component
Create an Angular component following Momentum CMS conventions.
Arguments
- First argument: Library path (e.g., "admin", "ui", "admin/components")
- Second argument: Component name in kebab-case (e.g., "data-table", "field-renderer")
Steps
-
Create component files in
libs/<library>/src/lib/<component>/:<component>.ts(component class)<component>.html(template, if complex)<component>.spec.ts(tests)
-
Use this template for the component:
import { ChangeDetectionStrategy, Component, computed, input, output, signal, inject } from '@angular/core';
@Component({
selector: 'mcms-<component-name>',
host: { class: 'block' },
template: `
<!-- Template here -->
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class <PascalName>Component {
// Signal inputs (use proper types, never `any`)
readonly data = input.required<DataType>();
// Optional inputs with defaults
readonly disabled = input(false);
// Signal outputs
readonly valueChange = output<ValueType>();
// Internal state
private readonly _loading = signal(false);
// Computed values
readonly loading = this._loading.asReadonly();
readonly hasData = computed(() => !!this.data());
// Injected services
private readonly http = inject(HttpClient);
}
- Export from library's
index.ts:
export { <PascalName>Component } from './lib/<component>/<component>';
Key Conventions
- NO
standalone: true— default in Angular 21, redundant (ESLint enforced) - NO
anytypes — use proper interfaces (ESLint enforced) - NO
CommonModuleimport — unnecessary in Angular 21 - Always use
ChangeDetectionStrategy.OnPush - Use
input()andinput.required()for inputs - Use
output()for outputs - Use
signal()for internal state,computed()for derived values - Use
inject()for dependency injection - Use
@for/@if/@switchcontrol flow - Prefix selectors with
mcms-
UI Component Patterns
No Wrapping Divs
Angular components create a host element. Style the host directly — do NOT add wrapper divs:
@Component({
selector: 'mcms-button',
host: { class: 'inline-flex items-center gap-2' },
template: `<ng-content />`,
})
NOT:
// BAD: unnecessary wrapper div
template: `<div class="inline-flex items-center gap-2"><ng-content /></div>`,
Class Configuration
Accept a class input for Tailwind customization via hostClasses() computed:
@Component({
selector: 'button[mcms-button]',
host: { '[class]': 'hostClasses()' },
template: `<ng-content />`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class McmsButtonComponent {
readonly variant = input<'primary' | 'secondary'>('primary');
readonly class = input('');
readonly hostClasses = computed(
() => `${baseClasses} ${variantClasses[this.variant()]} ${this.class()}`,
);
}
Theme Service
Use McmsThemeService for dark mode support:
import { McmsThemeService } from '@momentumcms/admin';
@Component({...})
export class MyComponent {
private readonly theme = inject(McmsThemeService);
toggleDarkMode(): void {
this.theme.toggleTheme();
}
readonly isDark = this.theme.isDark; // computed signal
readonly currentTheme = this.theme.theme; // 'light' | 'dark' | 'system'
}
App Tailwind Setup
Apps using the admin library must:
- tailwind.config.js — Use the admin preset and include library sources:
const adminPreset = require('../../libs/admin/tailwind.preset');
module.exports = {
presets: [adminPreset],
content: [
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,html}'),
join(__dirname, '../../libs/admin/src/**/*.{ts,html}'),
...createGlobPatternsForDependencies(__dirname),
],
};
- styles.css — Include CSS variables inline (Angular's esbuild can't resolve library CSS imports):
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--mcms-background: 0 0% 100%;
--mcms-foreground: 222 47% 11%;
/* ... copy from libs/admin/src/styles/theme.css */
}
.dark {
/* dark mode variables */
}
}
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?