Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Create Custom Angular Schematics

Build an Angular schematic by implementing a Tree-transforming Rule, registering it in a collection, defining options, and choosing a standalone or library package.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular schematics are reusable instructions for changing project files. To create one, implement a rule that transforms a virtual file tree, register it in a collection, and define its inputs with a JSON schema. You can distribute a standalone collection or package schematics with an Angular library so its installation, generators, and migrations are available through Angular CLI commands.

How Angular schematics work

A schematic describes project transformations. Rather than editing the workspace directly as each operation runs, it stages proposed changes in a virtual file system. Angular’s authoring guide describes a Tree as a base set of files and a staging area. A Rule applies transformations to that tree, while individual Action operations represent file changes such as Create, Rename, Overwrite, and Delete. A SchematicContext carries execution context and utilities. Angular’s authoring guide

As an Amazon Associate I earn from qualifying purchases.

In the guide’s words, “A Rule object defines a function that takes a Tree, applies transformations, and returns a new Tree.” This tree-based workflow lets the schematic stage changes before they are merged into the real workspace; depending on the merge strategy, proposed changes can be accepted, ignored, or cause an exception. Angular: Authoring schematics

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose how to distribute the schematic

Approach Best suited to How it is exposed
Standalone collection Internal tooling or transformations intended for custom projects Develop and distribute a schematic collection; invoke a named schematic through Angular CLI’s collection syntax.
Library-packaged collection Setup, code generation, or migrations that should accompany a library Place schematic files in the library project and expose its collection through the library package’s package.json.

Angular documents both standalone authoring and library integration. For a library, keeping schematics in the library project ties them to the package that needs them. Check generated paths and APIs against the Angular CLI and DevKit versions your library supports; the documentation examples do not establish compatibility with every release. Standalone authoring · Schematics for libraries

Create a schematic collection

Set up the project

For a standalone collection, use the Schematics CLI to develop the collection. When authoring for a library, Angular recommends creating the schematic files inside the library project so they can be packaged with it. Angular: Authoring schematics · Angular: Schematics for libraries

Register named schematics

A collection’s collection.json maps schematic names to their factory entry points and descriptions, and can reference an option schema. For example, a library collection can register an ng-add schematic with a factory and schema:

{
  "ng-add": {
    "factory": "./ng-add/index#ngAdd",
    "schema": "./ng-add/schema.json"
  }
}

The library’s package.json then exposes the collection through its schematics field. The path and entry-point names above are documentation examples; adapt and verify them for the package layout and supported Angular/DevKit versions you use. Angular: Schematics for libraries

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Implement a rule factory

A schematic entry point exports a factory function that accepts options and returns a Rule. The rule receives a Tree, stages transformations, and returns the resulting tree. Keep file operations within this Tree-based workflow so the schematic participates in Angular’s staged change process. The exact implementation depends on what files the schematic should create or modify. Angular: Authoring schematics

Define and validate options

Use a schematic’s schema.json to describe caller inputs, their types, defaults, and constraints. Angular’s examples include string, boolean, and enumerated options. Add x-prompt when an interactive question is useful; schema constraints validate the resulting input. This keeps the supported interface explicit whether values come from a prompt or a CLI invocation. Angular: Schematics for libraries

Match the schematic to the CLI workflow

Workflow Purpose
ng add Install or configure a library in a project.
ng generate Scaffold an artifact, such as project code or files.
ng update Adjust a project for a library release or breaking change.

Choose the schematic type according to the task it performs: initialization belongs in the add workflow, reusable scaffolding in generation, and release-related project changes in update migrations. A library collection can expose these entry points through its package. Angular: Schematics for libraries

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Run a schematic with Angular CLI

Angular CLI’s default ng generate subcommands come from the @schematics/angular collection. Workspaces can configure additional collections with the schematicCollections workspace option. A particular schematic can be invoked using collection-and-name syntax; use the collection and schematic names registered by the package you are invoking. Angular CLI: generate

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a library, exposing the collection in its package metadata makes its named entry points available to the corresponding CLI workflows. Confirm the package’s published files and supported CLI versions when preparing a collection for distribution. Angular: Schematics for libraries

Review staged changes and verify compatibility

  • Keep transformations expressed as rules operating on the schematic’s Tree.
  • Review the proposed tree changes and the configured merge behavior before relying on the schematic in a project workflow.
  • Check collection paths, schemas, and package metadata against the Angular and DevKit versions your library supports; current documentation examples are not a version-specific compatibility guarantee.

Angular’s authoring documentation explains the virtual-tree and merge model, while its library guide shows how a package can connect collections to CLI workflows. Authoring schematics · Schematics for libraries

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.