Angular signals

From FabianGosebrink/dog-rate-app · View interactive version

Angular signals is an AI agent skill from the GitHub repository FabianGosebrink/dog-rate-app. Use whenever writing or editing an Angular `computed()` or `effect()` — including signal-based derivations inside `signalStore` (`withComputed`), component `computed`s, and any `effect`. Applies even for one-line derivations.

How to use this skill

Skill file

Angular signals — read your dependencies first

When you write a computed() or an effect(), **read every signal the callback

depends on into a const on the first lines of the callback, then work from those

locals below.** Do not call signal getters inline in the middle of the logic.

// Do this
readonly summary = computed(() => {
  const entries = this.entries();
  const rate = this.rate();

  return entries.reduce((sum, e) => sum + e.amount * rate, 0);
});
// Not this
readonly summary = computed(() =>
  this.entries().reduce((sum, e) => sum + e.amount * this.rate(), 0),
);

The same rule applies to effect():

effect(() => {
  const isOpen = this.isOpen();
  const id = this.itemKey();

  this.sync(id, isOpen);
});

Why this matters

computed/effect reacts to by reading the top of the block — no scanning the

whole body to reconstruct the reactive graph.

if it is read during execution. Reading a signal inside a branch (if, &&, a

ternary, an early return) means it is not tracked when that branch is

skipped — a classic "why didn't this recompute?" bug. Reading everything up front

guarantees a stable dependency set on every run.

whole computation sees a single snapshot and you avoid repeated getter calls.

How to apply

signal call.

arrow so the convention is uniform and diffs stay small when logic grows.

signalStore, component-level computed, and effect.

Consistent with the signal guidance in CLAUDE.md (feed a signal into a store and

read it inside a computed) and the state-management skill.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.