Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Angular schematics let you define repeatable changes to an Angular project, from creating files to configuring a library after installation. A schematic runs rules against a virtual file tree, so proposed changes can be staged before they are merged into the workspace. You can build a standalone collection for internal tooling or ship schematics with an Angular library.
How Angular schematics work
A schematic is an instruction for transforming a project. Its core pieces are a Tree, a Rule, and a collection. Angular describes a Rule as “a function that takes a Tree, applies transformations, and returns a new Tree.” The Tree represents the existing files and a staging area for proposed changes; the schematic framework applies those changes to the real workspace only when the tree is merged.
A Rule can stage file operations represented by these action types:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Create: add a file.Rename: move or rename a file.Overwrite: replace a file’s contents.Delete: remove a file.
This virtual-tree workflow provides a boundary between a transformation and the actual project. The merge strategy determines whether staged changes are accepted, ignored, or cause an exception. See Angular’s schematic authoring guide for the Tree, Rule, and merge model.
#1 Best Overall
Choose how to distribute the collection
| Approach | Best suited to | How it is exposed |
|---|---|---|
| Standalone collection | Internal tooling or transformations meant to be used independently of a library. | Develop and package a collection using the Schematics CLI; users can invoke a named schematic from its collection. |
| Library-packaged collection | Setup, generated artifacts, or migrations that should travel with a library. | Keep schematic files in the library project, register them in collection.json, and expose the collection through the library package’s package.json. |
Angular documents both approaches and recommends placing schematic files in the library project when the goal is to package them with that library. The library route ties initialization and future migrations to the package that needs them. See schematics for libraries.
Build a schematic step by step
- Create the collection structure. Use the Schematics CLI for a standalone collection, or add the schematic files to the library project. A collection is registered in
collection.json. - Register a named schematic. Add an entry to
collection.jsonwith a description and a factory path. The factory identifies the function Angular should run; an entry may also identify the option schema. - Implement the rule factory. Write an entry function such as
helloWorld(options): Rulethat returns a Rule. The Rule receives a Tree, stages its transformations, and returns the Tree. Keep filesystem changes within this Tree-based workflow rather than making direct file edits. - Define the options. Add a
schema.jsondescribing accepted inputs and defaults. Schemas can define strings, booleans, and enumerated choices. Anx-promptcan request interactive input; schema constraints validate responses. - Expose the collection if it belongs to a library. Set the library package’s
schematicsfield to identify its collection so Angular CLI can discover the named entries. - Review the staged result. Run the schematic in the intended workspace and inspect the proposed changes and merge behavior before relying on it for repeated use.
Angular’s library schematics documentation shows a collection entry with a factory such as ./ng-add/index#ngAdd and an associated schema. Treat these paths as documentation examples, not universal generated paths; confirm them against the Angular CLI and DevKit versions your library supports.
Rank #2
Choose the right CLI workflow
A library can use different schematic types for different lifecycle jobs. Choose the command based on what the transformation is meant to do:
| CLI workflow | Purpose | Typical schematic role |
|---|---|---|
ng add |
Install or configure a package in a project. | Initialize the library’s required configuration or dependencies. |
ng generate |
Scaffold a project artifact. | Create a component, service, or other library-specific structure. |
ng update |
Adjust a project as a library changes across releases. | Apply migration logic, including changes needed for breaking updates. |
These are distinct tasks, not interchangeable labels: use an add schematic for setup, a generator for new artifacts, and an update schematic for release-related changes. Angular explains these library workflows in its library schematic guide.
Rank #3
Run a schematic through Angular CLI
Angular CLI’s default ng generate subcommands come from the @schematics/angular collection. A workspace can configure collections used for generation with the schematicCollections setting. You can also address a particular schematic in collection:name form. The exact command and package resolution depend on how the collection is installed and exposed; consult the Angular CLI generate reference and the collection’s documentation for the invocation appropriate to your setup.
Check compatibility before publishing
Angular’s current documentation describes the authoring model, but its examples do not establish compatibility with every Angular CLI or DevKit release. Before publishing, check the Angular CLI and DevKit versions your library supports, then validate the collection metadata, factory paths, schemas, and generated changes in a workspace using those versions.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools

