
Angular Core Reference
FreeUnderstand Angular's core architecture and mental model.
Free · Opens the source repo
What Angular Core Reference does
The Angular Core Reference skill provides an in-depth understanding of the architecture and mental model of the packages/core directory in the Angular framework. This skill is essential for developers working with Angular, as it covers the key components that make up the core of the framework, including rendering, dependency injection, change detection, and reactivity. By utilizing this skill, developers can better navigate and modify the core logic of Angular, ensuring they adhere to best practices and performance optimizations.
The skill outlines the high-level architecture of Angular's core, detailing how the rendering engine (Ivy/Render3) transforms templates into DOM updates through a series of instructions. It emphasizes the importance of understanding LView and TView structures, which are crucial for managing the state and static structure of views within Angular applications. This knowledge is fundamental for anyone looking to extend or modify Angular's core functionalities.
Additionally, the skill delves into the dependency injection system, explaining how Angular manages object creation and lifecycle through a hierarchical injector structure. It also covers change detection strategies, including the new reactivity model introduced with signals, which allows for more efficient updates in Angular applications. This comprehensive overview is designed for developers who need to work closely with Angular's core, providing them with the necessary insights to effectively utilize and modify the framework's underlying logic.
When to use it
Use this skill whenever you plan to work with or modify the `packages/core` of Angular to ensure you understand its architecture.
When not to use it
This skill is not suitable for users who are not working directly with Angular's core code or those who do not need to understand the internal workings of the framework.
What you can build with it
Modifying Angular Core
When planning to modify the core logic of Angular, this skill provides the necessary understanding of how to approach changes in the rendering engine and dependency injection.
Understanding Change Detection
Use this skill to gain insights into Angular's change detection strategies, which can help in optimizing application performance.
Learning Angular Internals
For developers looking to deepen their knowledge of Angular, this skill serves as a foundational resource for understanding the framework's architecture.
How to install Angular Core Reference
View source1. Install with the skills CLI
npx skills add angular/angular/reference-core --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by angularAngular Core (packages/core) Mental Model
This document outlines the architecture and mental model for packages/core, the heart of the Angular framework.
1. High-Level Architecture
packages/core contains the runtime logic for Angular. Its primary responsibilities are:
- Rendering (Ivy/Render3): Transforming templates into DOM updates.
- Dependency Injection (DI): Managing object creation and lifetime.
- Change Detection: Synchronizing the model with the view.
- Reactivity: Signals and Zone.js integration.
2. Rendering Engine (Ivy / Render3)
The rendering engine (located in packages/core/src/render3) uses an instruction-based approach.
Key Concepts
-
Instructions: The Angular compiler transforms templates into a sequence of instruction calls (e.g.,
ɵɵelementStart,ɵɵtext,ɵɵproperty). These instructions are executed at runtime to create and update the view.- Location:
packages/core/src/render3/instructions
- Location:
-
LView (Logical View): An array containing the state of a specific view instance. It holds:
- DOM nodes (
RElement,RText). - Binding values (for change detection).
- Directive/Component instances.
- Context:
packages/core/src/render3/interfaces/view.ts
- DOM nodes (
-
TView (Template View): An array containing the static structure of a view. It is shared across all instances (
LViews) of the same component/template. It holds:- Property names for bindings.
- Node relationship information.
- Compiled directive definitions.
- Context:
packages/core/src/render3/interfaces/view.ts
-
Memory Layout:
LViewandTVieware parallel arrays. IndexiinLViewcorresponds to metadata at indexiinTView.HEADER: Fixed size, contains context (Parent, Host, etc.).DECLS: Static nodes (elements, text, pipes).VARS: Binding values.EXPANDO: Dynamic data (host bindings, injectors).
The Render Cycle
- Creation Mode: Instructions create DOM nodes and store them in
LView. - Update Mode: Instructions check current values against previous values stored in
LView. If changed, they update the DOM.
3. Dependency Injection (DI)
DI in Angular is hierarchical and split into two systems that interact:
Module Injector (R3Injector)
- Configured via
@NgModule.providersorprovidedIn: 'root'. - Stored in a hierarchy of
R3Injectorinstances. - Location:
packages/core/src/di/r3_injector.ts
Node Injector
- Configured via
@Component.providersor@Directive.providers. - Not a class, but a data structure embedded in the
LView("Expando" section). - Uses Bloom Filters (
TView.data) to quickly check if a token is present at a specific node index before traversing up the tree. - Resolves tokens starting from the current node, walking up the view tree (Element Injector hierarchy), and falling back to the Module Injector if not found.
4. Change Detection
- Dirty Checking: Angular checks if values bound in templates have changed.
- Strategies:
Default: Checks everything.OnPush: Checks only if inputs change, events fire, or signals update.
- Signals: The new reactivity primitive. Signals notify the scheduler when they change, potentially allowing for fine-grained updates (Zoneless).
5. Key Directories to Know
src/render3: The Ivy rendering engine.instructions: The runtime instructions called by compiled code.interfaces:LView,TView,TNodedefinitions.
src/di: Dependency injection system.src/change_detection: Change detection logic.src/zone: Zone.js integration.src/signal: Signals implementation (if present in this version, otherwise likely inprimitives).
6. Conventions & Gotchas
- Prefixes: Private/Internal exports often start with
ɵ. - Global State: Ivy relies heavily on global state (e.g.,
getLView()) during instruction execution to avoid passing context arguments everywhere. This is for performance and code size. - Performance: The code is highly optimized for performance and memory. You will see arrays used instead of objects, bitmasks, and manual memory management patterns. Respect these patterns.
7. How to Modify Core
- Understand the Instruction: If modifying runtime behavior, find the corresponding instruction in
src/render3/instructions. - Check
LView/TViewImpact: If adding state, understand where it fits in theLViewarray. - Tests: Core has extensive tests. Run them using Bazel.
Frequently asked questions about Angular Core Reference
Similar skills
Markdown to HTML Conversion
Efficiently convert Markdown documents to HTML.
Code Tour
Create structured walkthroughs for codebases.
Acquire Codebase Knowledge
Streamline onboarding with comprehensive codebase documentation.
Documentation & Modernization
Streamline codebase documentation and modernization planning.
Azure Resource Visualizer
Generate architecture diagrams for Azure resources.
CLAUDE.md Improver
Optimize your CLAUDE.md files for better project context.
