component-structure-new

Enforces Angular component decorator order, import grouping, template conventions, and qa-dataid attributes.

1|Updated Jan 14, 2024
One-click install
npx skills add https://github.com/Eyhenij/rt-tools --skill component-structure-new-eyhenij
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-structure-new
Source: https://github.com/Eyhenij/rt-tools/tree/main/.claude/skills/component-structure-new
Command: npx skills add https://github.com/Eyhenij/rt-tools --skill component-structure-new-eyhenij

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Angular components drift into inconsistent shapes across a codebase: decorator properties in random order, ungrouped imports, wrapper divs that duplicate :host layout, and missing test anchors. This Skill defines a single canonical structure for every *.component.ts file so reviews and refactors stay predictable. ## Core Features & Use Cases - Decorator property order: Mandates selector, templateUrl, styleUrl (singular), changeDetection OnPush, grouped imports, providers, and host bindings in a fixed sequence. - Import grouping: Requires labeled groups in the imports array — // angular, // rt-tools, // components, // directives, // pipes. - Template conventions: Self-closing tags, no redundant wrappers, conditional bindings instead of duplicated components in @if branches, and router-based fragment scrolling. - qa-dataid anchors: Every interactive element carries a kebab-case qa-dataid unique within the screen, with qa-skip for decorative elements and rules for component vs directive hosts. - Use Case: When creating a new calendar component, apply this pattern to produce the decorator skeleton, signal-based class fields (input.required, output, viewChild, computed), and a template with proper qa-dataid anchors ready for end-to-end tests. ## Quick Start Ask the AI to create or refactor an Angular component following the component-structure pattern with ordered decorator properties, grouped imports, and qa-dataid anchors on interactive elements.

Frequently Asked Questions about component-structure-new

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure an Angular component decorator correctly?

Order the properties as selector, templateUrl, styleUrl (singular), changeDetection with OnPush, imports, providers, then host bindings. Group the imports array with labeled comments: angular, rt-tools, components, directives, pipes.

How to add test anchors to Angular templates for e2e tests?

Add a qa-dataid attribute in kebab-case to every interactive element, unique within the screen and named by the element's meaning. Mark decorative elements with qa-skip, and use data-* attributes to distinguish repeated list items.

Should I use styleUrl or styleUrls in Angular components?

Use styleUrl (singular) with a single stylesheet path. The plural styleUrls is flagged as a common miss in this pattern and should be replaced during refactoring.

Why are method calls in Angular template bindings rejected?

Method calls like {{ getTotal() }} re-run on every change detection cycle and are refused by the linter. Replace them with a computed() signal, or use a pure pipe when the value derives from template context.

When should I avoid wrapper divs in Angular component templates?

Avoid wrappers that exist only as flex or grid containers around children. Move that layout to the :host selector and set the block class via host: { class: ... } in the decorator.