Skip to content
Agentmart
Submit a tool

angular-state

Use when designing a store or state service in an Angular app, choosing between signals, RxJS, and NgRx, modeling state shape, writing selectors/derived…

Skill by CreativeCodersTeam

IndexedApache-2.0
Write a review

Chalk Labs

Need help deploying angular-state?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/creativecodersteam-angular-state

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when designing a store or state service in an Angular app, choosing between signals, RxJS, and NgRx, modeling state shape, writing selectors/derived state, optimizing change detection, handling optimistic updates and concurrency conflicts, persisting/hydrating state, or troubleshooting over-fetching and re-render performance.

Use cases: frontend, writing

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/angular-state

What's inside

Skill name
angular-state
Description
Use when designing a store or state service in an Angular app, choosing between signals, RxJS, and NgRx, modeling state shape, writing selectors/derived state, optimizing change detection, handling optimistic updates and concurrency conflicts, persisting/hydrating state, or troubleshooting over-fetching and re-render performance.
License
Apache-2.0
Instructions
108 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • concurrency-control.md · references/

SKILL.md (first lines)

# Angular Reactive Data & State Best Practices

## When to Use

- Designing or restructuring a store, state service, or facade (the client analogue of a data layer)
- Choosing a state approach: signals, RxJS services, NgRx Store, or NgRx Component Store
- Modeling state shape, normalizing collections, or keeping state immutable
- Writing selectors / derived state, or troubleshooting over-fetching, redundant requests, and re-render performance
- Implementing optimistic updates and handling server-side concurrency conflicts
- Persisting and hydrating state (localStorage/sessionStorage) with versioning

## Store / State-Container Design

- Keep stores **focused and cohesive** — one feature's state per store, not a single god-store.
- Treat state as the **single source of truth**; components read from it and dispatch changes, they don't hold duplicate copies.
- Use **constructor/`inject()`** for dependencies (HTTP services, config).
- Expose **read-only** views (`signal.asReadonly()`, `Observable`) and mutate only through explicit methods/actions.
- **Pick the narrowest tool:**
  | State | Use |
  |-------|-----|
  | Local component view state | `signal()` / `computed()` in the component |
  | Feature state shared across a routed area | a `providedIn`-scoped service exposing signals or `BehaviorSubject` |
  | Feature state, signal-first, with less boilerplate than the full Redux flow | **NgRx SignalStore** (`signalStore`, `withState`/`withComputed`/`withMethods`) |
  | Complex, app-wide, multi-source state with strict traceability | **NgRx Store** (actions/reducers/selectors/effects) |
  | Local, self-contained reactive workflows | **NgRx Component Store** |

## Async Data: `resource()` / `httpResource()`

For **reactive reads** (load-on-signal-change), prefer the resource APIs over hand-rolled `subscribe`/`toSignal` plumbing. They expose `value`, `status`, `error`, and `isLoading` as signals and auto-cancel superseded requests when their reactive params change.

- **`resource()`** — wraps any async loader (a `Promise`-returning function); the `request`/`params` signal drives reloads. Use for non-HTTP or custom async sources.
- **`rxResource()`** — same, but the loader returns an `Observable` (integrates an existing RxJS service).
- **`httpResource()`** — declarative, signal-driven `HttpClient` GET; returns `HttpResourceRef` whose `value` is a signal. Use for reactive reads that depend on signals.

```typescript
export class OrderDetail {
  readonly id = input.required<number>();
  // refetches whenever id() changes; exposes value()/isLoading()/error()
  readonly order = httpResource<Order>(() => `/api/orders/${this.id()}`);
}
```

Keep using **`HttpClient`** directly for commands/mutations (POST/PUT/DELETE), streaming, and interceptor-heavy flows — resources are for reactive reads, not write operations.

## State Shape (Model) Design

- Use stable identifiers (`id`) and **normalize** collections (`Record<id, Entity>` + `id[]`) instead of nested arrays when items are referenced in multiple places.
- Keep state **immutable** — replace, don't mutate (`signal.update(s => ({ ...s, ... }))`); enable `readonly` types.
- Model relationships by id reference, not by embedding mutable copies.
- Keep derived data **out** of stored state — compute it (see Selectors).

## Performance

- Use `ChangeDetectionStrategy.OnPush` everywhere; prefer **signals** so views update only when read values change.
- In `@for`, always provide `track` (and `trackBy` in legacy `*ngFor`) to avoid re-rendering unchanged rows.
- Derive with **memoized** `computed()` / NgRx selectors instead of recomputing in templates.
- **Avoid over-fetching:** dedupe in-flight requests (`shareReplay({ bufferSize: 1, refCount: true })`), cache reads, and load only the fields/pages you need (pagination with page/size).
- Use `async` pipe or `toSignal()` rather than manual `subscribe` to prevent leaks and redundant change detection.
- **Zoneless change detection** (`provideZonelessChangeDetection()`, stable since v20.2, default for new apps since v21) removes Zone.js and updates the view only from signal reads, `markForCheck`, and async pipe — the end state of a signal-first app; new v21+ apps start zoneless. For existing apps adopt it deliberately: ensure state flows through signals/`OnPush`, test in staging, and don't flip a large production app in one step.

## Persistence & Hydration

- The client has no schema migrations, but persisted state **does** have a shape that evolves. Version persisted blobs (`{ version, data }`) and migrate or discard on mismatch when hydrating.
- Persist deliberately (localStorage/sessionStorage/IndexedDB) — only what must survive reloads, never large or sensitive data.
- Hydrate at startup (e.g. in a `provideAppInitializer`) and guard against malformed/stale payloads.

## Selectors & Derived State

- Compute derived values with `computed()` (signals) or memoized selectors (NgRx); don't store what you can derive.
- For **writable** derived state that resets when its source changes, use **`linkedSignal()`** (e.g. a selected-item signal that defaults from a list but can be overridden) instead of syncing with an `effect()`.
- Compose selectors from smaller selectors; keep them pure.
- For RxJS-derived data, choose operators deliberately (`map`, `filter`, `combineLatest`, `switchMap` for cancel-previous, `exhaustMap` to ignore-while-busy, `concatMap` to queue).

## Updates & Concurrency

- Update state **immutably**; batch related changes into one update/action.
- Prefer **optimistic updates** for snappy UX, with rollback on failure.
- Implement concurrency control for multi-user scenarios (see below).
- Use cancellation-aware operators (`switchMap`) so superseded requests don't clobber newer state.

### Optimistic Updates & Concurrency

See [concurrency-control.md](./references/concurrency-control.md) for optimistic-update-with-rollback, ETag/`If-Match` version tokens, and handling `409 Conflict` responses.

## Security

- **Never store secrets or sensitive personal data in client state or localStorage** — it is fully visible to the user and to any XSS payload.
- Treat all server data as untrusted for rendering; rely on Angular's built-in sanitization and avoid `bypassSecurityTrust*` unless unavoidable.
- Scope per-user state and clear it on logout (don't leak one user's cached data to the next).

## Testing

- Test stores/services by asserting emitted state after actions — assert **behavior/output**, not internal fields.
- Use marble testing (`TestScheduler`) for non-trivial RxJS operator chains.
- Mock HTTP with `provideHttpClient()` + `provideHttpClientTesting()` and inject `HttpTestingController`; mock dependencies with spies.
- For NgRx, test reducers as pure functions, selectors with `projector`, and effects with `provideMockActions`.
- Use the `angular-tester` skill for generating unit tests after state changes.

## Related Skills

- **[angular-fundamentals](../angular-fundamentals/SKILL.md)** — DI scopes for stores, typed config, signals, and `DestroyRef` teardown used in state code
- **[angular-tester](../angular-tester/SKILL.md)** — Generates unit tests for stores, selectors, and effects (marble testing, HttpTestingController)
- **[angular-components](../angular-components/SKILL.md)** — Consumes state via signals/async pipe; wires HTTP and interceptors
- **[angular-reviewer](../angular-reviewer/SKILL.md)** — Reviews state/data code for performance and correctness issues
- **[angular-package-manager](../angular-package-manager/SKILL.md)** — Adds RxJS, NgRx, or component-store packages
- **[angular-dev](../angular-dev/SKILL.md)** — Gated end-to-end implementation workflow that invokes this skill as a mandatory binding

From CreativeCodersTeam/ai-store, Apache-2.0.

More from CreativeCodersTeam/ai-store

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Jul 28, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from CreativeCodersTeam

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get angular-state running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying angular-state?

CallGet help
Cite this page

angular-state skill. Agent Mart. https://agentmart.dev/skills/creativecodersteam-angular-state (last updated 2026-10-24)