Skip to content

Commit

Permalink
docs(nx-dev): article about monorepos being AI future-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
juristr committed Feb 17, 2025
1 parent af930c3 commit b38aea2
Show file tree
Hide file tree
Showing 25 changed files with 153 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,5 @@ You can find an example of such setup on the **Nx Recipe GitHub repository**:
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
- 🥚 [Free Egghead course](https://egghead.io/courses/scale-react-development-with-nx-4038)
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,5 @@ npx nx migrate --run-migrations
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
- 🥚 [Free Egghead course](https://egghead.io/courses/scale-react-development-with-nx-4038)
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ How to enable it? [Read more on the Lerna docs](https://lerna.js.org/docs/featur
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
- 🥚 [Free Egghead course](https://egghead.io/courses/scale-react-development-with-nx-4038)
2 changes: 1 addition & 1 deletion docs/blog/2022-10-14-whats-new-in-nx-15.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,5 @@ npx nx migrate --run-migrations
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
- 🥚 [Free Egghead course](https://egghead.io/courses/scale-react-development-with-nx-4038)
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ So keep an eye on our [Twitter](https://twitter.com/nxdevtools), [Youtube](https
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
- 🥚 [Free Egghead course](https://egghead.io/courses/scale-react-development-with-nx-4038)
2 changes: 1 addition & 1 deletion docs/blog/2023-02-22-whats-new-with-lerna-6-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ You can find [a roadmap for all the features we plan to add in Lerna 7](https://
- [🧠 Lerna Docs](https://lerna.js.org/)
- [👩‍💻 Lerna GitHub](https://github.com/lerna/lerna)
- [💬 Nx Official Discord Server](https://go.nx.dev/community)
- [📹 Nrwl Youtube Channel](https://www.youtube.com/nrwl_io)
- [📹 Nrwl Youtube Channel](https://www.youtube.com/@nxdevtools)
2 changes: 1 addition & 1 deletion docs/blog/2025-01-09-who-gave-js-a-build-step.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ We have an input format we want to work with - and an output format that we want
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nx Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
2 changes: 1 addition & 1 deletion docs/blog/2025-01-28-managing-ts-pkgs-in-monorepos.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,4 @@ Also check out our docs:
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nx Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
2 changes: 1 addition & 1 deletion docs/blog/2025-01-29-new-nx-experience.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,4 @@ If you're working in a large monorepo and **struggling with the performance issu
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nx Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
2 changes: 1 addition & 1 deletion docs/blog/2025-02-03-workspace-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ If you want more insight into this topic, here are other resources we recommend:
- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nx Youtube Channel](https://www.youtube.com/nrwl_io)
- 📹 [Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
143 changes: 143 additions & 0 deletions docs/blog/2025-02-17-monorepos-are-ai-future-proof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
title: 'Monorepos are AI Future-Proof'
slug: monorepos-are-ai-future-proof
authors: ['Juri Strumpflohner']
tags: ['nx']
cover_image:
youtubeUrl: https://youtu.be/RNilYmJJzdk
---

Everyone is constantly pushing to be more productive: delivering more features, reducing overhead, and keeping up with increasing demands. Companies want to move faster, and engineering teams work toward the same goal, looking for ways to streamline development and ship more with fewer resources. LLMs offer a promising way to boost efficiency, whether by assisting individual developers or improving workflows across a team.

However, the quality of an LLM’s response depends entirely on the data and context it has access to. Ask an LLM (in this case, GitHub Copilot with GPT-4o) about the structure of an NPM workspace monorepo, and you probably won’t be satisfied with the result:

![nx-ai-before-workspace-structure.avif](/blog/images/articles/nx-ai-before-workspace-structure.avif)

Now compare that result, using the exact same question, but with additional context provided to the LLM:

![nx-ai-after-workspace-structure.avif](/blog/images/articles/nx-ai-after-workspace-structure.avif)

The difference is huge. Copilot now understands the architectural structure of the workspace. It recognizes that there are apps and libraries, their types (such as "data access" libraries), and how each relates to other projects in the monorepo.

![nx-ai-after-workspace-structure2.avif](/blog/images/articles/nx-ai-after-workspace-structure2.avif)

**So what changed?** Let’s break it down.

{% toc /%}

## Monorepos Break Down Barriers

When we (at Nx) [work with large enterprises](/enterprise), we often see patterns that lead to inefficiencies:

- **Siloed knowledge** – Developers only have visibility into the areas they actively work on. Without a broader view, duplication increases, communication slows down, and collaboration suffers.
- **Fragmentation** – Code is spread across multiple repositories with little integration. LLMs don’t automatically understand how different projects connect or who owns what.
- **Lack of integration** – Many productivity bottlenecks come from friction at integration points between teams.

LLMs face the same challenges. They operate on a small scope, usually a few files at a time, but **lack architectural awareness**. They don’t know how projects relate to each other, where the integration points are, or which team owns a given project.

Monorepos solve visibility and fragmentation issues by consolidating related projects into a single repository. This gives teams a shared view, removes communication barriers, reduces duplication, and improves collaboration.

**The same visibility that helps developers also helps an LLM.** Think about it: when you open your monorepo in VSCode or Cursor, you can see multiple related projects in one place. That’s very different from working across scattered repositories.

The problem? Even though your entire codebase is accessible, an LLM still only sees files and their contents. It doesn’t understand which project a file belongs to or how that project interacts with others. It simply lacks that knowledge.

This is where Nx comes in.

## Nx Understands Your Monorepo

Monorepos don’t come for free. While they improve visibility and collaboration, they introduce scaling challenges. This is where tools like Nx step in, helping you get the benefits of a monorepo while managing the complexity that comes with it.

Over the years, we’ve built features like [Nx Replay](/ci/features/remote-cache) and [Nx Agents](/ci/features/distribute-task-execution) to keep CI fast, while [conformance rules](/nx-enterprise/powerpack/conformance), [ownership](/nx-enterprise/powerpack/owners), and [local repository automation](/extending-nx/intro/getting-started) help manage and scale a monorepo in the long run.

To power these features, **Nx collects metadata about your workspace**, understanding relationships between projects, ownership, technology types, available tasks, and more. The [Nx daemon](/concepts/nx-daemon) runs in the background, keeping this metadata up to date and making sure Nx operates efficiently.

**Nx understands project relationships down to the file level**, tracking dependencies. For example, in the image below, `src/app/app.tsx` imports a component from `@aishop/feat-create-order`, and Nx knows exactly how these projects connect.

![nx-ai-project-relationships.avif](/blog/images/articles/nx-ai-project-relationships.avif)

**Nx also tracks available targets for each project**. If you’re using [Code Owners](/nx-enterprise/powerpack/owners), it **knows who owns what within your monorepo**.

![nx-ai-project-detail-view.avif](/blog/images/articles/nx-ai-project-detail-view.avif)

It **identifies relevant files for each target** based on the input and output properties defined in the [cache configuration](/features/cache-task-results#finetune-caching-with-inputs-and-outputs).

![nx-ai-cache-inputs.avif](/blog/images/articles/nx-ai-cache-inputs.avif)

Nx also knows about **project tags, helping classify domains, project types, or any other custom attributes** you’ve applied.

![nx-ai-project-tags.avif](/blog/images/articles/nx-ai-project-tags.avif)

Nx plugins come with **[code generators](/features/generate-code)** that can scaffold entire projects. These generators have well-defined [schemas](https://github.com/nrwl/nx/blob/804df721a729da41d804c57a829828c96d265d79/packages/js/src/generators/library/schema.json) that describe the available properties, their descriptions, and which ones are required. This structured metadata makes them an ideal data source for LLMs, allowing them to provide more accurate and meaningful suggestions when interacting with your monorepo.

![nx-ai-generator-schema.avif](/blog/images/articles/nx-ai-generator-schema.avif)

These are just some examples of the metadata Nx maintains about your monorepo.

Beyond that, the [Nx documentation already includes an AI-powered chat](/ai-chat), and its data can be injected directly into your LLM conversations as well.

![nx-ai-docs-assistant.avif](/blog/images/articles/nx-ai-docs-assistant.avif)

## Nx Makes Your LLM Way Smarter

All of this data is a goldmine for enhancing your LLM. Luckily we're kinda obsessed with good DX which is why we had an editor for a long time: [Nx Console](/getting-started/editor-setup).

While you could build your own chat-based LLM integration, the best approach is to make it work where developers already spend their time: inside the editor. Nx Console is the perfect fit for this. It already enhances your monorepo workflow by providing IntelliSense, running code generators, and [integrating with CI](/blog/nx-cloud-pipelines-come-to-nx-console). Now, we've taken it a step further.

We extended Nx Console with an integration for Copilot that preprocesses Nx metadata and provides the LLM with details about:

- The workspace structure, including applications and libraries.
- How projects are connected.
- A project’s technology stack.
- Tasks and which files are relevant for each task (e.g., spec files for test runs).
- Categorization via tags and dependency rules.
- Project ownership information.
-

The result: **your LLM just got significantly smarter**, moving beyond basic file-level reasoning to understanding your workspace at an architectural level.

Let's go through some concrete examples. You can try these yourself by [installing Nx Console](/getting-started/editor-setup) or updating to the latest version.

Here, we ask Copilot about projects, their dependencies, and ownership details:

![nx-ai-example-project-data.avif](/blog/images/articles/nx-ai-example-project-data.avif)

We can also go deeper, asking where to best implement certain types of functionality:

![nx-ai-example-data-access-feature.avif](/blog/images/articles/nx-ai-example-data-access-feature.avif)

In a larger enterprise, this also means you can ask about who to talk to when implementing or planning a new feature. Thanks to Nx metadata, the LLM understands ownership:

![nx-ai-example-ownership.avif](/blog/images/articles/nx-ai-example-ownership.avif)

And since we made the LLM aware of [Nx generators](/features/generate-code), we can ask it to help set up a new project. Notice how it not only suggests the correct command but also places the new project in the `packages/products` subfolder. We even added action buttons to either run the command immediately or open it in [Nx Console's generator UI](/recipes/nx-console/console-generate-command).

![nx-ai-example-generate-code.avif](/blog/images/articles/nx-ai-example-generate-code.avif)

Beyond that, since we also feed documentation data into the LLM, it can now answer questions about Nx itself:

![nx-ai-example-cache-config.avif](/blog/images/articles/nx-ai-example-cache-config.avif)

## Nx Monorepos Are AI Future-Proof

Right now, most LLM editor extensions operate at the file level, unless you manually feed them additional context. But this is going to change. LLMs will continue to improve, and most importantly, their context windows will grow.

That's why **we strongly believe monorepos are AI future-proof**. They provide a consolidated view of multiple projects, and when enhanced with Nx metadata, they allow an LLM to reason at a higher architectural level. Instead of just answering file-specific questions, it can assist with broader development workflows, project structure, and cross-project interactions.

And this is just the beginning. While Nx already understands your local monorepo, [Nx Cloud](/nx-cloud) holds valuable CI-related data, tracking which tasks take the longest, where failures are most common, identifying flaky tasks, and even mapping project relationships beyond a single monorepo. Combining local workspace metadata with Nx Cloud insights creates an even richer foundation for LLMs, unlocking more meaningful suggestions and optimizations.

## Wanna Try It Yourself?

If you want to test this out, [create a new Nx workspace](/getting-started/intro#try-nx-yourself) and make sure you have [Nx Console](/getting-started/editor-setup) installed or updated to the latest version.

> If you already have an existing NPM/Yarn/PNPM workspace, you can add Nx with `nx init`. Check out [our free course](/courses/pnpm-nx-next) to learn more.
While Nx Console is also available for WebStorm, the AI-powered extensions currently only work with VSCode and Copilot.

---

Learn more:

- 🧠 [Nx Docs](/getting-started/intro)
- 👩‍💻 [Nx GitHub](https://github.com/nrwl/nx)
- 💬 [Nx Official Discord Server](https://go.nx.dev/community)
- 📹 [Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/blog/images/articles/nx-ai-cache-inputs.avif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/blog/images/articles/nx-ai-project-tags.avif
Binary file not shown.

0 comments on commit b38aea2

Please sign in to comment.