Skip to main content
skill CX Codex

angular-performance — Claude Code skill: speed up Angular

An Angular skill that tells the agent how to load images with NgOptimizedImage, defer heavy components with @defer, and set up SSR with hydration.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Gentleman-Programming/Gentleman-Skills --skill angular-performance -a claude-code
npx skills add Gentleman-Programming/Gentleman-Skills --skill performance -a claude-code
Open on GitHub

What angular-performance does

The skill fires when you ask the agent to work on Angular app performance, images or lazy loading. Inside are rules across four areas: image optimization, deferred components, lazy routes, and SSR with hydration.

Image rules are strict: use ngSrc instead of src, always set width and height or switch to fill, and mark the LCP image with priority. A fill image needs a parent with position: relative, fixed or absolute. For @defer the skill lists the triggers — on viewport for below-the-fold content, on interaction, on idle, on timer(500ms), when condition — along with @placeholder, @loading and @error blocks.

It also warns against triggering reflows or repaints inside ngOnInit and ngAfterViewInit, a common slowdown that is easy to miss. For heavy computations the advice is to optimize the algorithm first and only then reach for pure pipes, memoization or computed().

What it helps with

  • stop images from shifting the layout while they load
  • defer a heavy component until it scrolls into view
  • split routes into lazy chunks
  • turn on SSR with hydration for SEO pages
  • get reflows out of lifecycle hooks

Example prompts for the agent

  • go through the components and switch every img to NgOptimizedImage
  • defer the comments block with an on viewport trigger
  • make the admin route lazy with loadComponent

How to install angular-performance

1Skills CLI (Vercel)

npx skills add Gentleman-Programming/Gentleman-Skills --skill angular-performance -a claude-code
npx skills add Gentleman-Programming/Gentleman-Skills --skill performance -a claude-code

2Manually: put the files in place

~/.claude/skills/performance/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/performance/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about angular-performance

How do I install angular-performance in Claude?

Run npx skills add Gentleman-Programming/Gentleman-Skills --skill angular-performance -a claude-code. The skill file lands at ~/.claude/skills/performance/SKILL.md.

What does angular-performance do?

It gives the agent Angular performance rules: NgOptimizedImage, @defer, lazy routes, SSR with hydration, and handling of slow computations.

When does the skill actually trigger?

On tasks about Angular app performance, images or lazy loading. It does not load for unrelated topics.

Source text

SKILL.md · MIT
---
name: angular-performance
description: >
  Angular performance: NgOptimizedImage, @defer, lazy loading, SSR.
  Trigger: When optimizing Angular app performance, images, or lazy loading.
metadata:
  author: gentleman-programming
  version: "1.0"
---

## NgOptimizedImage (REQUIRED for images)

```typescript
import { NgOptimizedImage } from '@angular/common';

@Component({
  imports: [NgOptimizedImage],
  template: `
    <!-- LCP image: add priority -->
    <img ngSrc="hero.jpg" width="800" height="400" priority>
    
    <!-- Regular: lazy loaded by default -->
    <img ngSrc="thumb.jpg" width="200" height="200">
    
    <!-- Fill mode (parent needs position: relative) -->
    <img ngSrc="bg.jpg" fill>
    
    <!-- With placeholder -->
    <img ngSrc="photo.jpg" width="400" height="300" placeholder>
  `
})
```

### Rules
- ALWAYS set `width` and `height` (or `fill`)
- Add `priority` to LCP (Largest Contentful Paint) image
- Use `ngSrc` not `src`
- Parent of `fill` image must have `position: relative/fixed/absolute`

---

## @defer - Lazy Components

```html
@defer (on viewport) {
  <heavy-component />
} @placeholder {
  <p>Placeholder shown immediately</p>
} @loading (minimum 200ms) {
  <spinner />
} @error {
  <p>Failed to load</p>
}
```

### Triggers

| Trigger | When to Use |
|---------|-------------|
| `on viewport` | Below the fold content |
| `on interaction` | Load on click/focus/hover |
| `on idle` | Load when browser is idle |
| `on timer(500ms)` | Load after delay |
| `when condition` | Load when expression is true |

```html
<!-- Multiple triggers -->
@defer (on viewport; on interaction) {
  <comments />
}

<!-- Conditional -->
@defer (when showComments()) {
  <comments />
}
```

---

## Lazy Routes

```typescript
// Single component
{
  path: 'admin',
  loadComponent: () => import('./features/admin/admin').then(c => c.AdminComponent)
}

// Feature with child routes
{
  path: 'users',
  loadChildren: () => import('./features/users/routes').then(m => m.USERS_ROUTES)
}
```

---

## SSR & Hydration

```typescript
bootstrapApplication(AppComponent, {
  providers: [
    provideClientHydration()
  ]
});
```

| Scenario | Use |
|----------|-----|
| SEO critical (blog, e-commerce) | SSR |
| Dashboard/Admin | CSR |
| Static marketing site | SSG/Prerender |

---

## Slow Computations

| Solution | When |
|----------|------|
| Optimize algorithm | First choice always |
| Pure pipes | Cache single result |
| Memoization | Cache multiple results |
| `computed()` | Derived signal state |

**NEVER** trigger reflows/repaints in lifecycle hooks (`ngOnInit`, `ngAfterViewInit`).

---

## Resources

- https://angular.dev/guide/image-optimization
- https://angular.dev/guide/defer
- https://angular.dev/best-practices/runtime-performance
- https://angular.dev/guide/ssr

© gentleman-programming · MIT · Gentleman-Programming/Gentleman-Skills

Similar skills

Everything for Frontend and UI →

From the same set4

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor