Modern Angular
Angular CLI MCP and AI-Generated Angular Code
AI can speed up Angular work, but only if the agent sees current docs, local project shape, and hard review rules. The Angular CLI MCP server shipped experimental in v20.2 (August 2025) and has been default-available since v21, though the docs still label it experimental in v22; the protocol itself is a year old after Anthropic open-sourced MCP in November 2024.
The real problem is stale Angular
The risk with AI-generated Angular is not that an assistant writes code. The risk is that it writes Angular from the wrong year: AppModule everywhere, old structural directives by habit, RxJS conversions with no boundary, or experimental APIs treated as stable.
Minko Gechev (Angular team lead) named the gap directly in his LLM-first Web Framework post: 'Often the LLM will generate code that uses deprecated or missing APIs from previous versions.' The Angular CLI MCP server exists to close that gap by giving compatible tools a path to the Angular CLI, official documentation, and workspace context. This is the dev-time side of Angular's AI surface: it helps the assistant write better code at your desk, where the runtime counterpart, WebMCP, exposes typed tools from your shipped app to a browser agent. That improves the starting point. It does not remove review.
What to allow
| Use case | Allow? | Condition |
|---|---|---|
| Search official Angular docs | Yes | Use current docs before accepting an API claim. |
| Generate a small component | Yes | The prompt states version, style, state boundary, and out-of-scope APIs. |
| Run read-only workspace inspection | Yes | Prefer read-only mode when the task is discovery. |
| Run experimental MCP tools that modify code | Careful | Require explicit review and a small diff. |
| Put AI API secrets in Angular frontend code | No | Secrets belong behind backend, proxy, or managed provider boundary. |
The setup to start with
Start with MCP for documentation and workspace help and ng generate ai-config for repository rules. The server has been default-available since v21, but the official MCP page, built at v22, still calls it experimental and still separates the six standard tools (search_documentation, find_examples, ai_tutor, get_best_practices, list_projects, onpush_zoneless_migration) from seven more behind --experimental-tool: build, e2e, modernize, test, plus a devserver group of three (devserver.start, devserver.stop, devserver.wait_for_build). Since this all runs at dev time, the practical risk is low, but keep policy conservative on anything that can change code.
For code generation, the prompt should state what modern Angular means in this repo. Otherwise the assistant will fill the gaps with whatever pattern it has seen most often.
ng mcp
ng generate ai-config --tool agentsWhat `ng generate ai-config` writes
The command writes a rules file your assistant reads before it touches the code. The --tool flag is an array, defaults to ["none"], and picks which file lands where. The shipped enum in the schematic is exactly these eight values, and each one maps to a path a specific assistant already looks for.
If the target file already exists, the schematic skips it and warns instead of overwriting, so running this on a repo that already has rules is safe. The agents value writes an AGENTS.md; once it exists, the next step is making that file say something useful, which is its own piece.
--tool | Generated file | Use |
|---|---|---|
none | (nothing) | Default. Skips file generation. |
agents | AGENTS.md | Tool-agnostic rules many assistants now read. |
claude | .claude/CLAUDE.md | Claude Code project rules. |
copilot | .github/copilot-instructions.md | GitHub Copilot repo instructions. |
cursor | .cursor/rules/cursor.mdc | Cursor project rules. |
gemini | .gemini/GEMINI.md | Gemini CLI rules. |
jetbrains | .junie/guidelines.md | JetBrains Junie guidelines. |
windsurf | .windsurf/rules/guidelines.md | Windsurf rules. |
Prompt quality is part of the architecture
A vague prompt pushes the assistant toward the most common Angular shape on the internet. A useful prompt names the local architecture, the Angular version, the state boundary, the testing expectation, and the APIs that are out of scope.
I would reject AI output that ignores those constraints even if the component compiles. The review target is not whether the model produced code; it is whether the diff respects the team model.
# Bad prompt
Create an Angular search component.
# Useful prompt
Create a standalone Angular 21 search component.
Use a Signal for the input text, RxJS for debounce and cancellation, and toSignal only at the component boundary.
Use built-in control flow in the template.
Do not use experimental APIs.
Add a small service-level test or explain why no test changed.The review checklist
A generated Angular diff should be reviewed like any other production diff, plus a few AI-specific checks: over-conversion to Signals, misplaced providers, accidental global state, fake accessibility, missing tests, and APIs whose status was not checked.
The win is not 'the agent wrote the feature'. The win is a smaller first draft that still respects the team's Angular model.
# Angular AI rules
Use standalone components for new UI.
Prefer `inject` when it matches local style.
Use built-in control flow in touched templates.
Use Signals for local and derived state.
Keep RxJS for streams, cancellation, and async composition.
Do not use experimental APIs without an explicit decision.
Do not place secrets in Angular frontend code.
Every generated diff needs human review.Reusable artifact
AI-generated Angular review gate
- Current Angular docs checked through official sources.
- Prompt states Angular version, architecture style, and out-of-scope APIs.
- MCP tools that change code are treated as experimental until reviewed.
- No secrets or provider credentials are added to frontend code.
- Generated code passes normal tests and a human Angular review.
FAQ
What does `ng generate ai-config` do?
It writes a rules file that your AI assistant reads before working in the repo, so the assistant follows your conventions instead of guessing. The --tool option decides which assistant's file format it generates. It skips and warns if the file already exists.
Which `--tool` options exist?
On Angular v21.2.x the shipped enum is none, agents, claude, copilot, cursor, gemini, jetbrains, and windsurf; none is the default and skips generation. The full list is in the schematic schema, and --tool is an array, so you can pass more than one.
Does it generate an AGENTS.md?
Yes, ng generate ai-config --tool agents writes an AGENTS.md at the repo root, the tool-agnostic file that several assistants read. What goes inside that file to make it useful for Angular is its own piece.
How is this different from WebMCP?
ng generate ai-config and the Angular CLI MCP server are dev-time: they help an assistant write Angular on your machine. WebMCP is runtime, where your shipped app exposes typed tools to the end user's browser agent. Same AI theme, very different blast radius. I lay the two side by side in WebMCP vs the Angular CLI MCP server.
Sources checked
- https://angular.dev/ai
- https://angular.dev/ai/mcp
- https://angular.dev/cli/generate/ai-config
- https://github.com/angular/angular-cli/blob/v21.2.13/packages/schematics/angular/ai-config/schema.json
- https://angular.dev/ai/develop-with-ai
- https://angular.dev/ai/agent-skills
- https://angular.dev/ai/design-patterns
- https://angular.dev/guide/signals
- https://angular.dev/guide/components
- https://angular.dev/guide/templates/control-flow
- https://blog.angular.dev/angular-summer-update-2025-1987592a0b42
- https://blog.angular.dev/announcing-angular-v21-57946c34f14b
- https://blog.mgechev.com/2025/04/19/llm-first-web-framework/
- https://www.anthropic.com/news/model-context-protocol
- https://modelcontextprotocol.io/specification/2025-11-25
Modern Angular Playbook
This article is one play.
The Modern Angular Playbook collects the diagnostic, the adoption matrix, eleven plays, and the 30-day plan. Free, in English and Portuguese.
You get both PDFs by email, through the Dojo IA list.
André Ramosavailable for remote roles, UTC−3Get in touch →