agentleFS
tomavictomavic/angular-philosophies/ai/AGENTS.md

angular-philosophies / ai

AGENTS.md8 starsChanged 14 days agoMITView on GitHub

Generated from https://github.com/tomavic/angular-philosophies. These rules apply to Angular 22 projects using TypeScript 6.0, zoneless change detection, signals and NgRx SignalStore. Where this project's own rules above this heading disagree, the project wins. Do not edit the rules below; change the chapter they come from. Copy these instead of inventing a new pattern:

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,196 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

73 rules. About 0 are common, 20 are distinctive, and 53 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈20

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 53

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test toolkit and example specs: https://github.com/tomavic/angular-philosophies/blob/main/templates/testing

    line 32
  2. Very specific:

    Prefer the Angular platform (httpResource, signal APIs, router, forms) over a new dependency.

    line 38
  3. Distinctive:

    Write a shared abstraction the third time the same code appears, not the first.

    line 39
  4. Very specific:

    When touching a file, fix nearby smells or leave a TODO with a reason.

    line 40
  5. Distinctive:

    Treat accessibility and right-to-left support as part of "done", not as follow-up work.

    line 42
  6. Very specific:

    Never let a domain import another domain, and never let scope:shared import a domain.

    line 48
  7. Distinctive:

    Keep code inside the app feature until a second consumer exists.

    line 49
  8. Very specific:

    Import through path aliases (@shop/..., @/...).

    line 52
  9. Very specific:

    Write components as standalone without standalone: true, and without changeDetection (OnPush is the Angular 22 default).

    line 60
  10. Very specific:

    Use the host: {} object; never @HostBinding or @HostListener.

    line 62
  11. Very specific:

    Use input(), model(), output(), viewChild().

    line 63
  12. Very specific:

    Run zoneless with provideZonelessChangeDetection().

    line 64
  13. Very specific:

    Use computed or linkedSignal to derive state.

    line 65
  14. Very specific:

    Use @if, @for (always with track), @switch, @empty, @defer.

    line 66
  15. Very specific:

    Keep templates free of logic beyond a condition.

    line 67
  16. Very specific:

    Keep presentational components free of stores and HttpClient.

    line 68
  17. Very specific:

    Put pages in type:feature libraries and presentational components in type:ui libraries.

    line 69
  18. Very specific:

    Add data-testid to interactive elements and to elements that tests assert on.

    line 70
  19. Very specific:

    Use named exports and loadComponent with a .then(m => m.XComponent) for routed components.

    line 71
  20. Distinctive:

    Use utility classes and design tokens for styling.

    line 72
  21. Very specific:

    Keep @Injectable({ providedIn: 'root' }) for stateless services.

    line 73
  22. Very specific:

    Never call .subscribe() in a component.

    line 78
  23. Very specific:

    Never add a load() method that a component must call after a filter changes.

    line 79
  24. Very specific:

    Use one store per view (list, detail, form), provided by the component with providers: [XStore].

    line 80
  25. Distinctive:

    Never let a feature import another feature's store.

    line 82
  26. Very specific:

    Put derived values in withComputed.

    line 85
  27. Very specific:

    Never type a store as any.

    line 88
  28. Very specific:

    Use rxMethod only when operators are needed.

    line 89
  29. Very specific:

    Read server data with resources derived from state (httpResource via withResource).

    line 95
  30. Distinctive:

    Keep a resource in its component only while one component uses it.

    line 98
  31. Very specific:

    Write with withMutations and httpMutation.

    line 100
  32. Distinctive:

    Check the API's real verbs before choosing PUT or PATCH.

    line 102
  33. Very specific:

    Never call an endpoint for a compile-time constant.

    line 103
  34. Distinctive:

    Search the whole repository for other callers before deleting a frontend call or a backend route.

    line 104
  35. Very specific:

    Never let an interceptor match feature URLs.

    line 106
  36. Very specific:

    Use withResource, withMutations/httpMutation, guardedDevtools, withMapper and withStorageSync as the standard extensions.

    line 112
  37. Very specific:

    Add withImmutableState, withReset, withConditional, withUndoRedo or withCallState only when a real need appears, and update the inventory …

    line 113
  38. Very specific:

    Do not use withDataService, withEntityResources, withPagination, withRedux, createEffects or withFeatureFactory.

    line 114
  39. Very specific:

    Use withFeature from @ngrx/signals instead of withFeatureFactory, and patchState from @ngrx/signals instead of the toolkit's.

    line 115
  40. Very specific:

    Never call withDevtools directly.

    line 116
  41. Very specific:

    Add withMapper to redact secret-shaped keys when a store's tracked state holds a full entity row.

    line 117
  42. Very specific:

    Write a custom signalStoreFeature only after the same block has been copied between stores three times.

    line 122
  43. Very specific:

    Use one status field (idle | loading | success | error) instead of separate loading, error and loaded flags in rxMethod stores.

    line 123
  44. Very specific:

    Do not use withRequestStatus with resources or mutations.

    line 124
  45. Very specific:

    Use withLinkedState or linkedSignal for state that follows other state instead of an effect that sets signals.

    line 127
  46. Very specific:

    Use signalMethod for reactions that need no operators, and rxMethod when they do.

    line 128
  47. Very specific:

    Never inject one store into another.

    line 129
  48. Distinctive:

    Use Reactive Forms as the default.

    line 133
  49. Very specific:

    Use withComponentInputBinding() and read route values through input(), not ActivatedRoute.

    line 139
  50. Very specific:

    Put translation keys in route title.

    line 140
  51. Distinctive:

    Read the language signal inside a request that depends on language so it refetches on change.

    line 143
  52. Very specific:

    Use logical properties (ms-*, pe-*, text-start, start-*), never physical left and right.

    line 145
  53. Distinctive:

    Use brand colours only for fills, borders and large text.

    line 151
  54. Distinctive:

    Check light and dark themes separately.

    line 152
  55. Distinctive:

    Never let colour alone carry meaning.

    line 153
  56. Very specific:

    Use native <button> and <a> for interactive elements.

    line 155
  57. Distinctive:

    Keep focus visible with at least 3:1 contrast.

    line 156
  58. Very specific:

    Keep body text at 16px or more, touch targets at 44px or more, and honour prefers-reduced-motion.

    line 160
  59. Distinctive:

    Test the real file with fakes for everything it injects.

    line 165
  60. Very specific:

    Never use TestBed.configureTestingModule directly, { provide, useValue } for services, HttpTestingController or as jest.Mock in specs.

    line 167
  61. Very specific:

    Import every test utility from @/core/test.

    line 168
  62. Distinctive:

    Keep a store real when it is plain state with no dependencies or when its state holds a nullable object, and seed it through its own …

    line 173
  63. Very specific:

    Write one top-level describe per world.

    line 174
  64. Very specific:

    Wait with await view.whenStable().

    line 179
  65. Very specific:

    Use pnpm only, and run Nx through it (pnpm nx ...).

    line 183
  66. Very specific:

    Use pnpm nx affected -t lint,test for CI and pre-push checks.

    line 184
  67. Very specific:

    Keep Angular and TypeScript at versions listed together on angular.dev/reference/versions.

    line 185
  68. Very specific:

    Use an ESLint flat config with @nx/enforce-module-boundaries, angular-eslint, and the template accessibility rules.

    line 187
  69. Very specific:

    Do not use any; if unavoidable, add an eslint-disable comment with the reason beside it.

    line 188
  70. Distinctive:

    Never raise formatting in review.

    line 190
  71. Distinctive:

    Write Conventional Commits with an emoji and the project name as scope.

    line 191
  72. Distinctive:

    Run lint-staged on pre-commit, commitlint on commit-msg, and build and test on pre-push.

    line 192
  73. Distinctive:

    Commit an AGENTS.md at the root and in areas with their own rules.

    line 194

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md 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
AGENTS.md

Angular Philosophies: rules for AI agents

Generated from https://github.com/tomavic/angular-philosophies. These rules apply to Angular 22 projects using TypeScript 6.0, zoneless change detection, signals and NgRx SignalStore. Where this project's own rules above this heading disagree, the project wins. Do not edit the rules below; change the chapter they come from.

Stack

  • Angular 22 (standalone, zoneless, signals), TypeScript 6.0 strict, @ngrx/signals 22, @ngrx-toolkit/core 22
  • Nx and pnpm, ESLint flat config, Prettier, Jest 30 with jest-preset-angular

Read first, by task

TaskChapter
Deciding where code goes, adding a libraryArchitecture
Writing or changing a component or templateComponents
Writing or changing a storeThe signal store
Reading or writing server data, interceptors, errorsData access
Choosing a toolkit extension, devtools, storage syncThe toolkit
Writing a custom store feature, or stores that must coordinateCustom store features
Forms, routes, translations, right-to-leftForms, routing, translations and right-to-left
Anything visual or interactiveAccessibility
Writing a specTesting
Lint, format, commits, scriptsTooling

Reference implementations

Copy these instead of inventing a new pattern:

Philosophy

  • Build only what the current task needs; do not add flags, options or abstractions for hypothetical cases.
  • Prefer the Angular platform (httpResource, signal APIs, router, forms) over a new dependency.
  • Write a shared abstraction the third time the same code appears, not the first.
  • When touching a file, fix nearby smells or leave a TODO with a reason; never rewrite inside a feature branch.
  • Express every rule a machine can check as a lint rule or a type, not as documentation.
  • Treat accessibility and right-to-left support as part of "done", not as follow-up work.

Architecture

  • Give every library exactly one scope:* tag and one type:* tag in its project.json.
  • Enforce module boundaries with @nx/enforce-module-boundaries; dependencies flow only downward through util, data-access, core, ui, feature, shell.
  • Never let a domain import another domain, and never let scope:shared import a domain.
  • Keep code inside the app feature until a second consumer exists; then promote it to a library.
  • Split a library with secondary entry points, not with extra libraries.
  • Export by name from each index.ts; do not export * runtime code.
  • Import through path aliases (@shop/..., @/...); never use ../../ across feature or library boundaries.
  • Make type:util code free of Angular injection; pass language and configuration as parameters.
  • Forbid sibling entry points from importing each other with no-restricted-imports in the library's own ESLint config.
  • Duplicate small code instead of adding an if (guest)-style mode flag to a shared function.
  • Name files <name>.component.ts, <name>.store.ts, <name>.service.ts, <name>.model.ts, <feature>.routes.ts, and keep each spec beside its source.

Components

  • Write components as standalone without standalone: true, and without changeDetection (OnPush is the Angular 22 default).
  • Inject dependencies with inject() in field initialisers; do not use constructors for injection.
  • Use the host: {} object; never @HostBinding or @HostListener.
  • Use input(), model(), output(), viewChild(); do not use the decorator forms in new code.
  • Run zoneless with provideZonelessChangeDetection(); every value a template reads must be a signal.
  • Use computed or linkedSignal to derive state; use effect() only for side effects outside Angular.
  • Use @if, @for (always with track), @switch, @empty, @defer; never *ngIf, *ngFor, ngClass or ngStyle.
  • Keep templates free of logic beyond a condition; move the rest into a computed.
  • Keep presentational components free of stores and HttpClient; they take inputs and emit outputs.
  • Put pages in type:feature libraries and presentational components in type:ui libraries.
  • Add data-testid to interactive elements and to elements that tests assert on.
  • Use named exports and loadComponent with a .then(m => m.XComponent) for routed components.
  • Use utility classes and design tokens for styling; no hex colours and no per-component stylesheets.
  • Keep @Injectable({ providedIn: 'root' }) for stateless services; put shared state in a signal store.

The signal store

  • Make a signalStore the facade, API layer and state layer for its slice; components never inject HttpClient or a data service.
  • Never call .subscribe() in a component; use signals, resources or rxMethod.
  • Never add a load() method that a component must call after a filter changes; derive reads from state with resources.
  • Use one store per view (list, detail, form), provided by the component with providers: [XStore].
  • Provide a feature store for shared reference data with { providedIn: 'root' }; put cross-feature state in a library store.
  • Never let a feature import another feature's store.
  • Type state with an interface, name the starting value initialState, and expose reset() when the store outlives its page.
  • Change state only with patchState; never mutate arrays or objects in place.
  • Put derived values in withComputed; inject dependencies with inject() inside withProps, withMethods or withHooks.
  • Prefix private store members with _ and expose a deliberate method when callers need them.
  • Reset page to 1 in every filter setter.
  • Never type a store as any.
  • Use rxMethod only when operators are needed; choose switchMap, exhaustMap or concatMap deliberately.
  • Persist state with withStorageSync, never with hand-written localStorage calls.
  • Give every store a spec.

Data access

  • Read server data with resources derived from state (httpResource via withResource); never with a load() method.
  • Give every resource a defaultValue and { errorHandling: 'previous value' }; never write ?. or ?? on a resource value in a component.
  • Design pages for both failure cases: a failed reload keeps the last value, a failed changed request falls back to the defaultValue.
  • Keep a resource in its component only while one component uses it; move it into a store when a second needs it.
  • Fold several resource statuses into one with apiStatus so a page has one loading state and one error state.
  • Write with withMutations and httpMutation; never use httpResource for POST, PATCH, PUT or DELETE.
  • Reload the affected reads in a mutation's onSuccess.
  • Check the API's real verbs before choosing PUT or PATCH.
  • Never call an endpoint for a compile-time constant; keep it as a const in the model file.
  • Search the whole repository for other callers before deleting a frontend call or a backend route.
  • Implement cross-cutting HTTP behaviour as functional interceptors registered by one provider function.
  • Never let an interceptor match feature URLs; use an HttpContext token for exceptions.
  • Type backend errors once and show failures through translation keys.

The toolkit

  • Install @ngrx-toolkit/core for Angular 22 (@angular-architects/ngrx-toolkit for 21 and earlier), with the same major as Angular.
  • Use withResource, withMutations/httpMutation, guardedDevtools, withMapper and withStorageSync as the standard extensions.
  • Add withImmutableState, withReset, withConditional, withUndoRedo or withCallState only when a real need appears, and update the inventory in the same change.
  • Do not use withDataService, withEntityResources, withPagination, withRedux, createEffects or withFeatureFactory.
  • Use withFeature from @ngrx/signals instead of withFeatureFactory, and patchState from @ngrx/signals instead of the toolkit's.
  • Never call withDevtools directly; call guardedDevtools(name, ...) from one shared file.
  • Add withMapper to redact secret-shaped keys when a store's tracked state holds a full entity row.
  • Persist state with withStorageSync and a select that lists only what should survive a reload; place it right after withState.

Custom store features

  • Write a custom signalStoreFeature only after the same block has been copied between stores three times.
  • Use one status field (idle | loading | success | error) instead of separate loading, error and loaded flags in rxMethod stores.
  • Do not use withRequestStatus with resources or mutations; they already track their own status.
  • Declare what a feature needs from the store with type<>() as its first argument so the compiler checks order.
  • Connect a reusable feature to a store's own signals with withFeature, not withFeatureFactory.
  • Use withLinkedState or linkedSignal for state that follows other state instead of an effect that sets signals.
  • Use signalMethod for reactions that need no operators, and rxMethod when they do.
  • Never inject one store into another; coordinate stores with @ngrx/signals/events event groups.

Forms, routing, translations and right-to-left

  • Use Reactive Forms as the default; build validators and input directives in a shared library and reuse them.
  • Type every form control; use nonNullable controls.
  • Make validator error messages translation keys keyed by the error name.
  • Protect forms with unsaved changes with a canDeactivate guard.
  • Trim and reject unwanted markup in form input in code, and ignore a second submit while a request is pending.
  • Lazy-load every feature with loadComponent or loadChildren; keep one <feature>.routes.ts per feature.
  • Use withComponentInputBinding() and read route values through input(), not ActivatedRoute.
  • Put translation keys in route title; build guards with factory functions such as createRoleGuard.
  • Provide an entry for every key in every language file; keep keys camelCase and nested by feature.
  • Carry translation keys in stores, interceptors and services; translate only in templates.
  • Read the language signal inside a request that depends on language so it refetches on change.
  • Expose a dir computed from the language store and bind it on the root element.
  • Use logical properties (ms-*, pe-*, text-start, start-*), never physical left and right.
  • Mirror directional icons in right-to-left; do not mirror numerals, logos or code.

Accessibility

  • Measure contrast with a function or tool; require 7:1 for small text, 4.5:1 for other text, and 3:1 for large text, icons, borders and focus rings.
  • Use brand colours only for fills, borders and large text; give small text a neutral token with a measured ratio.
  • Check light and dark themes separately.
  • Never let colour alone carry meaning; pair it with text, an icon or a pattern.
  • Mark invalid controls with aria-invalid and show the error as text.
  • Use native <button> and <a> for interactive elements; never a clickable <div>.
  • Keep focus visible with at least 3:1 contrast; never remove the outline without replacing it.
  • Move focus into a dialog on open, trap it while open, and return it on close; move focus to the heading after a route change.
  • Give every control an accessible name; prefer native elements over ARIA.
  • Announce dynamic errors and status changes with role="alert" or aria-live.
  • Keep body text at 16px or more, touch targets at 44px or more, and honour prefers-reduced-motion.
  • Enable the Angular ESLint template accessibility rules and do not switch them off to ship.

Testing

  • Test the real file with fakes for everything it injects; start every test from a fresh world.
  • Assert on behaviour (DOM, public signals, calls on fakes), never on private fields.
  • Never use TestBed.configureTestingModule directly, { provide, useValue } for services, HttpTestingController or as jest.Mock in specs.
  • Import every test utility from @/core/test.
  • Fake services with fakeService(X, () => ({ ... })) in the factory form, at module level, one per inject().
  • Fake only what the code uses, and match the real types so the fake cannot drift.
  • Fake HTTP, including httpResource, with fakeHttp; let unknown URLs fail loudly.
  • Satisfy every injection in the tree, including ones the code never calls.
  • Keep a store real when it is plain state with no dependencies or when its state holds a nullable object, and seed it through its own methods.
  • Write one top-level describe per world; use a new top-level describe with options.providers for anything a test cannot change through a fake.
  • Name tests as sentences, check one behaviour per it, and use it.each for variants of one check.
  • List the behaviours and branches before writing the spec.
  • Make test data satisfies the real model.
  • Give every store, service, guard and component a spec beside it.
  • Wait with await view.whenStable(); for stores flush effects and then settle the resource.

Tooling

  • Use pnpm only, and run Nx through it (pnpm nx ...); use Nx generators and targets instead of ng generate and ng build in an Nx workspace.
  • Use pnpm nx affected -t lint,test for CI and pre-push checks.
  • Keep Angular and TypeScript at versions listed together on angular.dev/reference/versions; never move TypeScript ahead of Angular.
  • Enable strict, noImplicitOverride, noPropertyAccessFromIndexSignature, noImplicitReturns and strictTemplates; never disable a strict flag to pass a build.
  • Use an ESLint flat config with @nx/enforce-module-boundaries, angular-eslint, and the template accessibility rules.
  • Do not use any; if unavoidable, add an eslint-disable comment with the reason beside it.
  • Format with Prettier: 120 columns, single quotes, trailingComma: all, arrowParens: avoid, one attribute per line, imports sorted @angular, rxjs, third-party, relative.
  • Never raise formatting in review; let the pre-commit hook format.
  • Write Conventional Commits with an emoji and the project name as scope; enforce with commitlint.
  • Run lint-staged on pre-commit, commitlint on commit-msg, and build and test on pre-push.
  • Hold a global coverage threshold of 80% and give every new spec full coverage of its own file.
  • Commit an AGENTS.md at the root and in areas with their own rules; keep the root file short.

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.