AGENTS.md — Angular
Modern Angular conventions, per the official style guide (https://angular.dev/style-guide).
- Components are standalone by default — add them to another component's
importsarray; don't setstandalone: false. - File names use hyphens (
user-profile.ts); the component.ts/.html/.cssshare a base name and directory. - Tests end in
.spec.tsand sit next to the code under test. Organise by feature, not by file type. - Avoid generic file names: no
helpers.ts,utils.ts,common.ts. One concept per file. - Prefer
inject()over constructor parameter injection. - Group Angular members (deps, inputs, outputs, queries) near the top, then methods.
- Declare inputs with
input()/input.required(), outputs withoutput(), two-way withmodel(); mark themreadonly. - Use
protectedfor members only read from the template. - State:
signal()for writable,computed()for derived (read-only),effect()only for side effects — never write signals in an effect. - Templates use built-in control flow:
@if/@for(with a mandatorytrack) /@switch. No*ngIf/*ngFor/*ngSwitch. - Bind with
[class.x]/[style.prop], notNgClass/NgStyle. - Name event handlers by action (
saveUserData()), not by event (handleClick()). - Keep lifecycle hooks short and
implementthe hook interface; delegate to named methods. - Keep components presentation-focused; factor validation and data transforms into separate functions/classes.
- When a rule conflicts with a file's existing style, keep that file internally consistent.