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.
- AGENTS.mdAGENTS.md
- ai/llms-full.txtllms.txt
- llms.txtllms.txt
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
- Very specific: line 32
Test toolkit and example specs: https://github.com/tomavic/angular-philosophies/blob/main/templates/testing
- Very specific: line 38
Prefer the Angular platform (httpResource, signal APIs, router, forms) over a new dependency.
- Distinctive: line 39
Write a shared abstraction the third time the same code appears, not the first.
- Very specific: line 40
When touching a file, fix nearby smells or leave a TODO with a reason.
- Distinctive: line 42
Treat accessibility and right-to-left support as part of "done", not as follow-up work.
- Very specific: line 48
Never let a domain import another domain, and never let scope:shared import a domain.
- Distinctive: line 49
Keep code inside the app feature until a second consumer exists.
- Very specific: line 52
Import through path aliases (@shop/..., @/...).
- Very specific: line 60
Write components as standalone without standalone: true, and without changeDetection (OnPush is the Angular 22 default).
- Very specific: line 62
Use the host: {} object; never @HostBinding or @HostListener.
- Very specific: line 63
Use input(), model(), output(), viewChild().
- Very specific: line 64
Run zoneless with provideZonelessChangeDetection().
- Very specific: line 65
Use computed or linkedSignal to derive state.
- Very specific: line 66
Use @if, @for (always with track), @switch, @empty, @defer.
- Very specific: line 67
Keep templates free of logic beyond a condition.
- Very specific: line 68
Keep presentational components free of stores and HttpClient.
- Very specific: line 69
Put pages in type:feature libraries and presentational components in type:ui libraries.
- Very specific: line 70
Add data-testid to interactive elements and to elements that tests assert on.
- Very specific: line 71
Use named exports and loadComponent with a .then(m => m.XComponent) for routed components.
- Distinctive: line 72
Use utility classes and design tokens for styling.
- Very specific: line 73
Keep @Injectable({ providedIn: 'root' }) for stateless services.
- Very specific: line 78
Never call .subscribe() in a component.
- Very specific: line 79
Never add a load() method that a component must call after a filter changes.
- Very specific: line 80
Use one store per view (list, detail, form), provided by the component with providers: [XStore].
- Distinctive: line 82
Never let a feature import another feature's store.
- Very specific: line 85
Put derived values in withComputed.
- Very specific: line 88
Never type a store as any.
- Very specific: line 89
Use rxMethod only when operators are needed.
- Very specific: line 95
Read server data with resources derived from state (httpResource via withResource).
- Distinctive: line 98
Keep a resource in its component only while one component uses it.
- Very specific: line 100
Write with withMutations and httpMutation.
- Distinctive: line 102
Check the API's real verbs before choosing PUT or PATCH.
- Very specific: line 103
Never call an endpoint for a compile-time constant.
- Distinctive: line 104
Search the whole repository for other callers before deleting a frontend call or a backend route.
- Very specific: line 106
Never let an interceptor match feature URLs.
- Very specific: line 112
Use withResource, withMutations/httpMutation, guardedDevtools, withMapper and withStorageSync as the standard extensions.
- Very specific: line 113
Add withImmutableState, withReset, withConditional, withUndoRedo or withCallState only when a real need appears, and update the inventory …
- Very specific: line 114
Do not use withDataService, withEntityResources, withPagination, withRedux, createEffects or withFeatureFactory.
- Very specific: line 115
Use withFeature from @ngrx/signals instead of withFeatureFactory, and patchState from @ngrx/signals instead of the toolkit's.
- Very specific: line 116
Never call withDevtools directly.
- Very specific: line 117
Add withMapper to redact secret-shaped keys when a store's tracked state holds a full entity row.
- Very specific: line 122
Write a custom signalStoreFeature only after the same block has been copied between stores three times.
- Very specific: line 123
Use one status field (idle | loading | success | error) instead of separate loading, error and loaded flags in rxMethod stores.
- Very specific: line 124
Do not use withRequestStatus with resources or mutations.
- Very specific: line 127
Use withLinkedState or linkedSignal for state that follows other state instead of an effect that sets signals.
- Very specific: line 128
Use signalMethod for reactions that need no operators, and rxMethod when they do.
- Very specific: line 129
Never inject one store into another.
- Distinctive: line 133
Use Reactive Forms as the default.
- Very specific: line 139
Use withComponentInputBinding() and read route values through input(), not ActivatedRoute.
- Very specific: line 140
Put translation keys in route title.
- Distinctive: line 143
Read the language signal inside a request that depends on language so it refetches on change.
- Very specific: line 145
Use logical properties (ms-*, pe-*, text-start, start-*), never physical left and right.
- Distinctive: line 151
Use brand colours only for fills, borders and large text.
- Distinctive: line 152
Check light and dark themes separately.
- Distinctive: line 153
Never let colour alone carry meaning.
- Very specific: line 155
Use native <button> and <a> for interactive elements.
- Distinctive: line 156
Keep focus visible with at least 3:1 contrast.
- Very specific: line 160
Keep body text at 16px or more, touch targets at 44px or more, and honour prefers-reduced-motion.
- Distinctive: line 165
Test the real file with fakes for everything it injects.
- Very specific: line 167
Never use TestBed.configureTestingModule directly, { provide, useValue } for services, HttpTestingController or as jest.Mock in specs.
- Very specific: line 168
Import every test utility from @/core/test.
- Distinctive: line 173
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 …
- Very specific: line 174
Write one top-level describe per world.
- Very specific: line 179
Wait with await view.whenStable().
- Very specific: line 183
Use pnpm only, and run Nx through it (pnpm nx ...).
- Very specific: line 184
Use pnpm nx affected -t lint,test for CI and pre-push checks.
- Very specific: line 185
Keep Angular and TypeScript at versions listed together on angular.dev/reference/versions.
- Very specific: line 187
Use an ESLint flat config with @nx/enforce-module-boundaries, angular-eslint, and the template accessibility rules.
- Very specific: line 188
Do not use any; if unavoidable, add an eslint-disable comment with the reason beside it.
- Distinctive: line 190
Never raise formatting in review.
- Distinctive: line 191
Write Conventional Commits with an emoji and the project name as scope.
- Distinctive: line 192
Run lint-staged on pre-commit, commitlint on commit-msg, and build and test on pre-push.
- Distinctive: line 194
Commit an AGENTS.md at the root and in areas with their own rules.
≈ “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.
Files
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/signals22,@ngrx-toolkit/core22 - Nx and pnpm, ESLint flat config, Prettier, Jest 30 with
jest-preset-angular
Read first, by task
| Task | Chapter |
| Deciding where code goes, adding a library | Architecture |
| Writing or changing a component or template | Components |
| Writing or changing a store | The signal store |
| Reading or writing server data, interceptors, errors | Data access |
| Choosing a toolkit extension, devtools, storage sync | The toolkit |
| Writing a custom store feature, or stores that must coordinate | Custom store features |
| Forms, routes, translations, right-to-left | Forms, routing, translations and right-to-left |
| Anything visual or interactive | Accessibility |
| Writing a spec | Testing |
| Lint, format, commits, scripts | Tooling |
Reference implementations
Copy these instead of inventing a new pattern:
- View store with a resource and a mutation: https://raw.githubusercontent.com/tomavic/angular-philosophies/main/templates/signal-store/order-list.store.ts
- The page that uses it: https://raw.githubusercontent.com/tomavic/angular-philosophies/main/templates/signal-store/order-list.component.ts
- Custom features: https://github.com/tomavic/angular-philosophies/blob/main/templates/signal-store
- Test toolkit and example specs: https://github.com/tomavic/angular-philosophies/blob/main/templates/testing
- Config files: https://github.com/tomavic/angular-philosophies/blob/main/templates/config
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
TODOwith 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 onetype:*tag in itsproject.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:sharedimport 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 notexport *runtime code. - Import through path aliases (
@shop/...,@/...); never use../../across feature or library boundaries. - Make
type:utilcode free of Angular injection; pass language and configuration as parameters. - Forbid sibling entry points from importing each other with
no-restricted-importsin 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 withoutchangeDetection(OnPush is the Angular 22 default). - Inject dependencies with
inject()in field initialisers; do not use constructors for injection. - Use the
host: {}object; never@HostBindingor@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
computedorlinkedSignalto derive state; useeffect()only for side effects outside Angular. - Use
@if,@for(always withtrack),@switch,@empty,@defer; never*ngIf,*ngFor,ngClassorngStyle. - 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:featurelibraries and presentational components intype:uilibraries. - Add
data-testidto interactive elements and to elements that tests assert on. - Use named exports and
loadComponentwith 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
signalStorethe facade, API layer and state layer for its slice; components never injectHttpClientor a data service. - Never call
.subscribe()in a component; use signals, resources orrxMethod. - 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 exposereset()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 withinject()insidewithProps,withMethodsorwithHooks. - Prefix private store members with
_and expose a deliberate method when callers need them. - Reset
pageto 1 in every filter setter. - Never type a store as
any. - Use
rxMethodonly when operators are needed; chooseswitchMap,exhaustMaporconcatMapdeliberately. - Persist state with
withStorageSync, never with hand-writtenlocalStoragecalls. - Give every store a spec.
Data access
- Read server data with resources derived from state (
httpResourceviawithResource); never with aload()method. - Give every resource a
defaultValueand{ 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
apiStatusso a page has one loading state and one error state. - Write with
withMutationsandhttpMutation; never usehttpResourcefor 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
constin 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
HttpContexttoken for exceptions. - Type backend errors once and show failures through translation keys.
The toolkit
- Install
@ngrx-toolkit/corefor Angular 22 (@angular-architects/ngrx-toolkitfor 21 and earlier), with the same major as Angular. - Use
withResource,withMutations/httpMutation,guardedDevtools,withMapperandwithStorageSyncas the standard extensions. - Add
withImmutableState,withReset,withConditional,withUndoRedoorwithCallStateonly when a real need appears, and update the inventory in the same change. - Do not use
withDataService,withEntityResources,withPagination,withRedux,createEffectsorwithFeatureFactory. - Use
withFeaturefrom@ngrx/signalsinstead ofwithFeatureFactory, andpatchStatefrom@ngrx/signalsinstead of the toolkit's. - Never call
withDevtoolsdirectly; callguardedDevtools(name, ...)from one shared file. - Add
withMapperto redact secret-shaped keys when a store's tracked state holds a full entity row. - Persist state with
withStorageSyncand aselectthat lists only what should survive a reload; place it right afterwithState.
Custom store features
- Write a custom
signalStoreFeatureonly after the same block has been copied between stores three times. - Use one
statusfield (idle | loading | success | error) instead of separateloading,errorandloadedflags inrxMethodstores. - Do not use
withRequestStatuswith 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, notwithFeatureFactory. - Use
withLinkedStateorlinkedSignalfor state that follows other state instead of aneffectthat sets signals. - Use
signalMethodfor reactions that need no operators, andrxMethodwhen they do. - Never inject one store into another; coordinate stores with
@ngrx/signals/eventsevent 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
nonNullablecontrols. - Make validator error messages translation keys keyed by the error name.
- Protect forms with unsaved changes with a
canDeactivateguard. - 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
loadComponentorloadChildren; keep one<feature>.routes.tsper feature. - Use
withComponentInputBinding()and read route values throughinput(), notActivatedRoute. - Put translation keys in route
title; build guards with factory functions such ascreateRoleGuard. - 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
dircomputed 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-invalidand 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"oraria-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.configureTestingModuledirectly,{ provide, useValue }for services,HttpTestingControlleroras jest.Mockin specs. - Import every test utility from
@/core/test. - Fake services with
fakeService(X, () => ({ ... }))in the factory form, at module level, one perinject(). - Fake only what the code uses, and match the real types so the fake cannot drift.
- Fake HTTP, including
httpResource, withfakeHttp; 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
describeper world; use a new top-level describe withoptions.providersfor anything a test cannot change through a fake. - Name tests as sentences, check one behaviour per
it, and useit.eachfor variants of one check. - List the behaviours and branches before writing the spec.
- Make test data
satisfiesthe 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 ofng generateandng buildin an Nx workspace. - Use
pnpm nx affected -t lint,testfor 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,noImplicitReturnsandstrictTemplates; 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.mdat the root and in areas with their own rules; keep the root file short.
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
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.

