Skip to content

LazyCats-dev/ao3-podfic-posting-helper / .agent/skills/angular-developer

angular-developer

Verified

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, services, or HTTP communication, or for best practices on reactivity (signals, linkedSignal, resource, httpResource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, naming conventions, or CLI tooling.

FileKindSize
SKILL.mdskill md10.5 KB
references/angular-animations.mdmarkdown3.9 KB
references/angular-aria.mdmarkdown18.2 KB
references/cli.mdmarkdown3.6 KB
references/component-harnesses.mdmarkdown2.7 KB
references/component-styling.mdmarkdown2.5 KB
references/components.mdmarkdown3.8 KB
references/creating-services.mdmarkdown3.2 KB
references/data-resolvers.mdmarkdown1.6 KB
references/define-routes.mdmarkdown2.1 KB
references/defining-providers.mdmarkdown2.2 KB
references/di-fundamentals.mdmarkdown3.4 KB
references/e2e-testing.mdmarkdown884 B
references/effects.mdmarkdown2.7 KB
references/environment-configuration.mdmarkdown3.3 KB
references/hierarchical-injectors.mdmarkdown2.1 KB
references/host-elements.mdmarkdown2.1 KB
references/http-client.mdmarkdown5.4 KB
references/injection-context.mdmarkdown1.9 KB
references/inputs.mdmarkdown2.4 KB
references/linked-signal.mdmarkdown2.6 KB
references/loading-strategies.mdmarkdown1.5 KB
references/mcp.mdmarkdown3.2 KB
references/migrations.mdmarkdown2.0 KB
references/naming-conventions.mdmarkdown5.4 KB
references/navigate-to-routes.mdmarkdown1.6 KB
references/outputs.mdmarkdown2.6 KB
references/pipes.mdmarkdown3.8 KB
references/reactive-forms.mdmarkdown3.5 KB
references/rendering-strategies.mdmarkdown1.8 KB
references/resource.mdmarkdown2.6 KB
references/route-animations.mdmarkdown1.6 KB
references/route-guards.mdmarkdown1.4 KB
references/router-lifecycle.mdmarkdown1.5 KB
references/router-testing.mdmarkdown3.7 KB
references/show-routes-with-outlets.mdmarkdown1.6 KB
references/signal-forms.mdmarkdown27.0 KB
references/signals-overview.mdmarkdown2.8 KB
references/tailwind-css.mdmarkdown1.8 KB
references/template-driven-forms.mdmarkdown3.7 KB
references/testing-fundamentals.mdmarkdown2.5 KB

references/pipes.md

View on GitHub
# Pipes

Pipes transform data declaratively inside Angular templates using the `|` operator.

## Using pipes in templates

Import the pipe class and add it to the component's `imports` array.

```ts
import {Component} from '@angular/core';
import {DatePipe, CurrencyPipe} from '@angular/common';

@Component({
  selector: 'app-invoice',
  imports: [DatePipe, CurrencyPipe],
  template: `
    <p>Date: {{ issuedOn | date: 'mediumDate' }}</p>
    <p>Total: {{ amount | currency }}</p>
  `,
})
export class Invoice {
  issuedOn = new Date();
  amount = 49.99;
}
```

## Using pipe logic outside templates

**Do NOT inject pipe classes into services or other classes.** Pipes are template operators, not injectable services. Injecting them causes DI errors in standalone contexts and creates unnecessary coupling.

### Custom pipes — extract the transformation function

Extract the logic into a plain function. The pipe delegates to it; services import the function directly.

```ts
// kebab-case.ts
export function toKebabCase(value: string): string {
  return value.toLowerCase().replace(/ /g, '-');
}
```

```ts
// kebab-case.pipe.ts
import {Pipe, PipeTransform} from '@angular/core';
import {toKebabCase} from './kebab-case';

@Pipe({name: 'kebabCase'})
export class KebabCasePipe implements PipeTransform {
  transform(value: string): string {
    return toKebabCase(value);
  }
}
```

```ts
// formatter.service.ts — import the function, NOT the pipe
import {Service} from '@angular/core';
import {toKebabCase} from './kebab-case';

@Service()
export class FormatterService {
  toSlug(title: string): string {
    return toKebabCase(title);
  }
}
```

### Built-in locale-aware pipes — use standalone formatting functions

`@angular/common` exports a standalone function for each locale-aware built-in pipe:

| Pipe           | Standalone function |
| -------------- | ------------------- |
| `DatePipe`     | `formatDate`        |
| `CurrencyPipe` | `formatCurrency`    |
| `DecimalPipe`  | `formatNumber`      |
| `PercentPipe`  | `formatPercent`     |

Inject `LOCALE_ID` to get the current locale and pass it to the function.

```ts
// CORRECT — use formatNumber instead of injecting DecimalPipe
import {Service, LOCALE_ID, inject} from '@angular/core';
import {formatNumber} from '@angular/common';

@Service()
export class PriceService {
  private locale = inject(LOCALE_ID);

  formatQuantity(value: number): string {
    return formatNumber(value, this.locale, '1.0-0');
  }
}
```

```ts
// WRONG — do not inject pipe classes
import {Service, inject} from '@angular/core';
import {DecimalPipe} from '@angular/common';

@Service()
export class PriceService {
  // ❌ DecimalPipe is not designed to be injected
  private pipe = inject(DecimalPipe);
}
```

## Creating custom pipes

Use the Angular CLI to generate a pipe:

```bash
ng generate pipe path/to/my-pipe
```

A pipe needs a `@Pipe` decorator with a `name` and a `transform` method implementing `PipeTransform`.

```ts
import {Pipe, PipeTransform} from '@angular/core';

@Pipe({name: 'truncate'})
export class TruncatePipe implements PipeTransform {
  transform(value: string, limit = 50): string {
    return value.length > limit ? value.slice(0, limit) + '…' : value;
  }
}
```

- **`name`**: camelCase. Do not use hyphens.
- **Class name**: PascalCase version of `name` with `Pipe` appended (e.g., `TruncatePipe`).

## Impure pipes

Mark a pipe `pure: false` only when you need to detect mutations inside arrays or objects. Impure pipes run on every change-detection cycle and can hurt performance.

```ts
@Pipe({name: 'filterItems', pure: false})
export class FilterItemsPipe implements PipeTransform {
  transform(items: string[], query: string): string[] {
    return items.filter((i) => i.includes(query));
  }
}
```

IMPORTANT: Avoid impure pipes unless absolutely necessary.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 321kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 321kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 321kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall