You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(@angular-devkit/schematics): add schematics to generate ai context files.
* `ng generate config ai` to prompt support tools.
* `ng generate config ai --tool=gemini` to specify the tool.
Supported ai tools: gemini, claude, copilot, windsurf, cursor.
<% } %>You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices.
4
+
5
+
## TypeScript Best Practices
6
+
7
+
- Use strict type checking
8
+
- Prefer type inference when the type is obvious
9
+
- Avoid the `any` type; use `unknown` when type is uncertain
10
+
11
+
## Angular Best Practices
12
+
13
+
- Always use standalone components over NgModules
14
+
- Must NOT set `standalone: true` inside Angular decorators. It's the default.
15
+
- Use signals for state management
16
+
- Implement lazy loading for feature routes
17
+
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
18
+
- Use `NgOptimizedImage` for all static images.
19
+
- `NgOptimizedImage` does not work for inline base64 images.
20
+
21
+
## Components
22
+
23
+
- Keep components small and focused on a single responsibility
24
+
- Use `input()` and `output()` functions instead of decorators
25
+
- Use `computed()` for derived state
26
+
- Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator
27
+
- Prefer inline templates for small components
28
+
- Prefer Reactive forms instead of Template-driven ones
29
+
- Do NOT use `ngClass`, use `class` bindings instead
30
+
- DO NOT use `ngStyle`, use `style` bindings instead
31
+
32
+
## State Management
33
+
34
+
- Use signals for local component state
35
+
- Use `computed()` for derived state
36
+
- Keep state transformations pure and predictable
37
+
- Do NOT use `mutate` on signals, use `update` or `set` instead
38
+
39
+
## Templates
40
+
41
+
- Keep templates simple and avoid complex logic
42
+
- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
43
+
- Use the async pipe to handle observables
44
+
45
+
## Services
46
+
47
+
- Design services around a single responsibility
48
+
- Use the `providedIn: 'root'` option for singleton services
49
+
- Use the `inject()` function instead of constructor injection
50
+
51
+
## Common pitfalls
52
+
53
+
- Control flow (`@if`):
54
+
- You cannot use `as` expressions in `@else if (...)`. E.g. invalid code: `@else if (bla(); as x)`.
Copy file name to clipboardExpand all lines: packages/schematics/angular/ng-new/schema.json
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,12 @@
144
144
"x-prompt": "Do you want to create a 'zoneless' application without zone.js (Developer Preview)?",
145
145
"type": "boolean",
146
146
"default": false
147
+
},
148
+
"aiConfig": {
149
+
"description": "Create an AI configuration file for the project. This file is used to improve the outputs of AI tools by following the best practices.",
0 commit comments