agentleFS
joaoguimaraesprojoaoguimaraespro/personal-finance/.cursor/rules/angular-patterns.mdc

personal-finance / rules

Cursor rule1 starsChanged todayMITView on GitHub

Angular patterns: smart and presentational components, API service, resources, interceptors, routing and guards, overlays, accessibility

The file

We split this angular-patterns.mdc into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every list view handles loading, empty and error states explicitly.

    line 15
  2. Very specific:

    Use HttpClient (with withFetch()), never raw fetch, so interceptors apply.

    line 21

≈ “Common” is an estimate: at least 1 in 5 of the 6,809 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
angular-patterns.mdc
---
description: "Angular patterns: smart and presentational components, API service, resources, interceptors, routing and guards, overlays, accessibility"
globs: **/src/app/**/*.ts,**/src/app/**/*.html,**/*.component.ts,**/*.service.ts,**/*.interceptor.ts,**/*.routes.ts
alwaysApply: false
---
<!-- Generated by armature from stack-angular/rules/angular/patterns.md. Edit the source rule, not this file. -->
# Angular patterns

## Components

- Pages (smart) own data loading and mutations; presentational components take inputs, emit outputs and hold only
  UI state.
- Shared building blocks (page header, empty state, status badge, modal, select, date field) live once in `shared/`
  and are reused; a second copy is a review finding.
- Every list view handles loading, empty and error states explicitly; a reload keeps the previous data on screen
  and shows a quiet indicator instead of blanking.

## Data access

- One API service in `core/` wraps `HttpClient` and returns typed results; components never build URLs.
- Use `HttpClient` (with `withFetch()`), never raw `fetch`, so interceptors apply.
- The backend computes business figures; the UI only displays them.

## Interceptors (functional, `withInterceptors([...])`)

- Session expiry: a 401 sends the user to sign in and back to the same page.
- Timeouts on API calls, longer for uploads, with a clear message.
- XSRF: `withXsrfConfiguration` when the API issues an XSRF cookie.
- Interceptors never log request or response bodies.

## Routing

- Lazy-load features with `loadComponent` / `loadChildren`; `withComponentInputBinding()` binds route params to
  inputs.
- Functional guards; `canMatch` for routes a user may not load at all. Hiding a link is not access control.

## Overlays

CDK overlays (dialogs, selects, menus) render in the browser top layer by default in recent CDK versions, which hides
toasts behind open dialogs. Provide `{ provide: OVERLAY_DEFAULT_CONFIG, useValue: { usePopover: false } }` once in the
app config when the app shows toasts, and show a form's errors inside its dialog.

## RxJS

`switchMap` for "latest wins" (search), `concatMap` for ordered writes, `exhaustMap` for submit buttons; no nested
subscribes.

## Accessibility

Semantic elements, labelled controls, focus moved into dialogs and back on close, keyboard paths for every action,
visible focus.

<!-- Adapted from affaan-m/ECC rules/angular/patterns.md (MIT) at d2ef268; merged with the owner's conventions from personal-finance-sdd (core/api service, functional interceptors for 401, timeouts and XSRF, shared page components, liveResource keeping data on reload, backend computes figures) and NEXUS knowledge/angular/cdk-overlay-top-layer.md. -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.