600-angular-ngrx-signal-store

600-angular-ngrx-signal-store is a cursor rule for Cursor from JrPribs/SmarterStarter. It costs 0 tokens per session (3,892 once invoked), scanned A, original, MIT.

Coding guidelines for Angular applications that use NgRx Signal Store, a way to organize shared application state with reactive values and update methods. The example covers state, derived values, asynchronous work, and error handling.

In plain words
What is it for?
Use it when creating or reviewing Angular signal stores, including state definitions, computed values, service calls, loading and error states, and reactive updates.
Why use it?
It gives the coding agent a consistent structure for storing and updating data such as loading status, errors, and todo items. This can reduce inconsistent state-management code across an Angular project.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when creating or reviewing Angular signal stores, including state definitions, computed values, service calls, loading and error states, and reactive updates.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/JrPribs/SmarterStarter

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 600-angular-ngrx-signal-store

README.md
[![agentmods](https://agentmods.dev/badge/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store/github.svg)](https://agentmods.dev/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store)
Your own site
<a href="https://agentmods.dev/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store"><img src="https://agentmods.dev/badge/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for 600-angular-ngrx-signal-store

Your own site · 80×15
<a href="https://agentmods.dev/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store"><img src="https://agentmods.dev/badge/rules/jrpribs/smarterstarter/600-angular-ngrx-signal-store.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,892 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.03892
Opus 5 $0.00000 $0.01946
Sonnet 5 $0.00000 $0.00778
Haiku 4.5 $0.00000 $0.00389

Measured 9d ago against content hash acb09e64adb7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

600-angular-ngrx-signal-store scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/600-angular-ngrx-signal-store.mdc · 608 lines

How it starts

The opening of the file, as written. The whole thing — 608 lines — stays where its author put it; the contents beside it link to each section on GitHub.

NGRx Signal Store Best Practices

  • Creating Signal Stores: Use the createStore function from @ngrx/signals to create a signal store as part of the global state layer.
import { createStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { pipe, switchMap, map, catchError } from 'rxjs';
import { inject } from '@angular/core';
import { tapResponse } from '@ngrx/operators';

export interface TodosState {
  todos: Todo[];
  status: 'idle' | 'loading' | 'error';
  error: string | null;
}

export const initialState: TodosState = {
  todos: [],
  status: 'idle',
  error: null
};

export const TodosStore = createStore(
  { providedIn: 'root' },
  withState(initialState),
  withComputed(({ todos }) => ({
    completedTodos: computed(() => todos().filter(todo => todo.completed)),
    incompleteTodos: computed(() => todos().filter(todo => !todo.completed)),
    todoCount: computed(() => todos().length)
  })),
  withMethods((store, todosService = inject(TodosService)) => ({
    loadTodos: rxMethod(
      pipe(
        switchMap(() => {
          patchState(store, { status: 'loading', error: null });
          
          return todosService.getTodos().pipe(
            tapResponse(
              (todos) => patchState(store, { todos, status: 'idle' }),
              (error) => patchState(store, { 
                status: 'error', 
                error: error instanceof Error ? error.message : 'Unknown error' 
              })
            )
          );
        })
      )
    ),
    
    addTodo: (title: string) => {
      const newTodo: Todo = { 
        id: Date.now().toString(), 
        title, 
        completed: false 
      };
      
      patchState(store, ({ todos }) => ({
        todos: [...todos, newTodo]
      }));
    },
    
    removeTodo: (id: string) => {
      patchState(store, ({ todos }) => ({
        todos: todos.filter(todo => todo.id !== id)
      }));
    },
    
    toggleTodo: (id: string) => {
      patchState(store, ({ todos }) => ({
        todos: todos.map(todo =>
          todo.id === id ? { ...todo, completed: !todo.completed } : todo
        )
      }));
    }
  }))
);
  • Store Methods Are Not Services: Methods in the store should focus on state updates only, not business logic.
// ❌ AVOID: Business logic in store methods
export const BadUserStore = createStore(
  { providedIn: 'root' },
  withState<UserState>(initialUserState),
  withMethods((store) => ({
    updateUser: (userData: UserUpdateDto) => {
      // Business validation doesn't belong in the store
      if (!userData.name || userData.name.length < 3) {
        throw new Error('Name must be at least 3 characters');
      }
      
      // Business transformations should be in services
      const formattedUser = {
        ...userData,
        name: userData.name.trim(),
        updatedAt: new Date().toISOString()
      };
      
      // The state update itself is appropriate
      patchState(store, { user: formattedUser });
    }
  }))
);

// ✅ GOOD: Store methods focused on state updates
export const GoodUserStore = createStore(
  { providedIn: 'root' },
  withState<UserState>(initialUserState),
  withMethods((store) => ({
    // Store methods should be simple state operations
    updateUser: (user: User) => {
      patchState(store, { user });
    },
    
    setLoading: (loading: boolean) => {
      patchState(store, { loading });
    },
    
    setError: (error: string | null) => {
      patchState(store, { error });
    }
  }))
);

// Services handle business logic before updating store
@Injectable({ providedIn: 'root' })
export class UserService {
  constructor(private userStore: typeof GoodUserStore) {}
  
  updateUser(userData: UserUpdateDto): Observable<User> {
    // Business validation
    if (!userData.name || userData.name.length < 3) {
      return throwError(() => new Error('Name must be at least 3 characters'));
    }
    
    // Business transformation
    const updatedUser = {
      ...userData,
      name: userData.name.trim(),
      updatedAt: new Date().toISOString()
    };
    
    // Update loading state
    this.userStore.setLoading(true);
    
    // API call
    return this.http.put<User>(`/api/users/${userData.id}`, updatedUser).pipe(
      tap(user => {
        // State update happens after business logic
        this.userStore.updateUser(user);
        this.userStore.setLoading(false);
      }),
      catchError(error => {
        this.userStore.setError(error.message);
        this.userStore.setLoading(false);
        return throwError(() => error);
      })
    );
  }
}

Read the full file on GitHub · 608 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 608 lines · 0 tokens per session scan A acb09e64adb7

Subscribe to this mod's changes

600-angular-ngrx-signal-store is a cursor rule published in the GitHub repository JrPribs/SmarterStarter (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,892 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.