Dev48
Language
  • About
  • Services
  • Industries
  • Technologies
  • Articles
  • Contacts
Book a call
    Home/Articles/Let ai agents extract reusable nx generators
Dev48

© 2026 · All rights reserved.

Let AI Agents Extract Reusable Nx Generators

Источник: Nx

Let AI Agents Extract Reusable Nx Generators

Source: Nx

Agent re-derive your project tructure every time they caffold a library. Encode it once a a local Nx generator and let the agent invoke it in tead.

September 25, 2026

Consistency has become an even bigger problem now that a major part of the code is produced by AI agents. Nx generators were built for an era when writing code was hard, so you could argue they're now obsolete. Turns out they're even better in combination with AI agents.

Using Nx generators for code consistency

In a nutshell, an Nx generator is a parameterized template you can invoke to scaffold code. Nx plugins usually ship them as part of the package so you can generate new plugin-specific packages that are properly wired up.

Built-in plugin generators are all good and nice, but the more powerful part is that you can create your own workspace plugins with their own, so-called "local generators". These live in your monorepo and are designed to automate recurring operations, mostly when it comes to code scaffolding.

So you'd install the @nx/plugin:

Then generate one into your workspace:

And finally create a new generator:

All this does is scaffold the base structure. You then have to implement it with your own logic.

And finally, you can invoke it from within your Nx monorepo just like any other generator:

You can leverage this same mechanism for automating all sorts of things in an Nx monorepo workspace, including adding language support as we discussed in our latest blog series on polyglot Nx monorepos.

Why not just use AI agents to scaffold code

That's what they're great at, right? Let me put it simply:

  • token cost
  • consistency

Scaffolding is a deterministic operation, and I try to move that outside the model as much as I can.

AI agents are non-deterministic. The combination is where the sweet spot is. Since invoking an Nx generator is a CLI command, AI agents are able to read and run it without issues. In addition, an agent is able to interpret the output of the generator and adjust it to the specific workspace situation if needed. That's where the win is, in my opinion.

Have the agent write the Nx generator

At one point, creating and maintaining these generators took time, but now we can let agents take over that part, and they're good at it, because it is a very well-defined task.

You can now point an agent at a library setup you want to standardize and ask it to encode the conventions and configuration as a local generator.

The workspace in the video is a plain pnpm workspace with Vite-based TypeScript libraries. It has one package set up the way I want every future package to look. The prompt is roughly:

Example prompt

Use the Nx Devkit to create a local workspace generator. Take the current project in packages/products as the scaffold: its Vite config, its TypeScript setup, and the way it declares exports. I want new packages in this workspace generated the same way.

There's more

Nx has always been built for customization and extensibility, which has become a major advantage now with AI agents.

Explore the Extending Nx docs page for more examples of how to automate Nx.

Learn More

  • Local generators
  • Extending Nx
  • Nx Community Discord
  • X / Twitter
  • Nx GitHub
  • Nx YouTube Channel
← All articles

More in Software Development

All →
A new skill finds AI agent risks, fixes them, and proves the fix worked
Microsoft

A new skill finds AI agent risks, fixes them, and proves the fix worked

Some Supabase customers are publicly exposing reams of people’s data to the webПресса
Supabase

Some Supabase customers are publicly exposing reams of people’s data to the web

Blazor Basics: SEO Basics for Blazor Web Applications
Telerik

Blazor Basics: SEO Basics for Blazor Web Applications

Affected by layoffs? Don’t miss this $75 deal for your TechCrunch Disrupt 2026 Expo+ PassПресса
Expo

Affected by layoffs? Don’t miss this $75 deal for your TechCrunch Disrupt 2026 Expo+ Pass

Last 24 hours to save up to $200 on TechCrunch Disrupt 2026. Reason 5 of 5 to attend: MomentumПресса
Momentum

Last 24 hours to save up to $200 on TechCrunch Disrupt 2026. Reason 5 of 5 to attend: Momentum

We’re building Copilot as a new OS for work that spans every model, every form factor, and every task. Today, we’re announcing our biggest update to Copilot to date, bringing four things together [Read more]
Microsoft

We’re building Copilot as a new OS for work that spans every model, every form factor, and every task. Today, we’re announcing our biggest update to Copilot to date, bringing four things together [Read more]

More from Nx

How Legora Cut CI Maintenance in Half
Nx

How Legora Cut CI Maintenance in Half

Introducing The Nx Cloud Timeline View
Nx

Introducing The Nx Cloud Timeline View

Why the AWS PACE Team Built Its Full-Stack Scaffolding as an Nx Plugin
Nx

Why the AWS PACE Team Built Its Full-Stack Scaffolding as an Nx Plugin

Nx 23.2 Is Here: Oxlint, Oxfmt, Leaner CLI Output and Better Caching
Nx

Nx 23.2 Is Here: Oxlint, Oxfmt, Leaner CLI Output and Better Caching