Automated summary
A guide to using Nx for creating, structuring and building JavaScript/TypeScript monorepos with task caching, a project graph and affected-only task execution.
Strengths
- Covers the full workflow: workspace creation, plugin installation, library and app generation, task execution and caching
- Provides concrete copy-pasteable commands, including non-interactive flags suited to automation
- Explains nx.json tuning (namedInputs, targetDefaults) and warns that non-deterministic tasks must not be cached
- Mentions remote caching with Nx Cloud, cache resets via nx reset and version migration
Limitations
- Plugin configuration is only shown through a few generator examples, not explained in depth
- Assumes familiarity with the underlying tooling (TypeScript, bundlers, Jest) and does not teach it
- The content cuts off mid-example, so cache and graph troubleshooting are not covered end to end
Use it when a user wants to set up an Nx monorepo, add Nx to an existing repo, or speed up builds and tests with caching and affected commands.
Not suitable for simple single-package projects, or for questions purely about a framework that do not involve organizing an Nx workspace.
Security analysis
SafeThe content is ordinary Nx documentation: it recommends standard scaffolding, generator, task-runner and CI commands (npx create-nx-workspace, nx g, nx build, nx affected, nx migrate). There is no destructive or exfiltration behavior (no rm -rf, curl|sh, no reading/sending credentials, no obfuscated payloads), no attempt to disable safety controls, and no embedded instructions aimed at the auditing model. The only mild surface is that `npx` fetches and executes published npm packages and `nx reset` clears the local cache, both normal and explicitly scoped to the workspace; the skill even warns against caching non-deterministic tasks and against putting secrets in shared remote-cache outputs.
No concerns found
How this analysis is madeExamples
Set up an Nx monorepo in TypeScript with a shared utils library, then build it twice to confirm the second build is served from cache.Configure my Nx workspace so CI runs only the tests and builds affected since origin/main, and explain what to put in the pipeline.Add Nx to my existing pnpm repository and make the build and lint targets cacheable.name: nx description: >- Builds and manages JavaScript/TypeScript monorepos with Nx, a build system with task caching, a project graph, code generators and affected commands. Use when a user asks to set up a monorepo, manage multiple packages or apps, cache builds, run only affected tests in CI, or add Nx to an existing repo. license: Apache-2.0 compatibility: 'Node.js 20+ and npm, pnpm, yarn or bun; any framework (React, Angular, Node, Next.js and more)' metadata: author: terminal-skills version: 1.1.0 category: development repository: https://github.com/nrwl/nx tags: "nx, monorepo, build, cache, workspace"
Nx
Overview
Nx is a build system for monorepos. It reads your workspace into a project graph, runs tasks in dependency order, caches results (locally, and remotely with Nx Cloud or a self-hosted cache), and can run only the tasks affected by a change. Plugins (@nx/js, @nx/react, @nx/node, @nx/next, ...) infer tasks from the tool configs they find (tsconfig, vite config, jest config), so most projects need no hand-written project.json. Checked against Nx 23.2.
Instructions
Step 1: Create a workspace or add Nx to an existing repo
# New workspace: pick a preset with --preset, skip the Nx Cloud prompt, no questions
npx create-nx-workspace@latest acme-platform --preset=ts --nxCloud=skip --no-interactive --packageManager=npm
# Existing repo (any package manager): installs nx and creates nx.json
cd acme-platform && npx nx@latest init
Other presets include react-monorepo, next, node-monorepo, angular-monorepo, vue-monorepo, nest, expo. With --no-interactive, --preset is required.
Step 2: Add plugins and projects
npx nx add @nx/react # install + initialize a plugin
npx nx g @nx/js:lib packages/shared-utils --bundler=tsc # new library
npx nx g @nx/react:app apps/storefront # new app (answers prompts if interactive)
New projects are named from their package.json (for example @org/shared-utils); nx build shared-utils still works with the short name when it is unique.
Step 3: Run tasks
npx nx build shared-utils # one project, dependencies built first (^build)
npx nx run-many -t build test lint # everything
npx nx affected -t test --base=origin/main # only projects changed since main
npx nx graph # open the project graph; nx show projects lists them
npx nx show project shared-utils # inferred targets, cache flags, inputs and outputs
Rerun a cached task and Nx replays the output ("1/1 hit (100%)") instead of running it.
Step 4: Tune nx.json
Plugin-inferred tasks (build, typecheck, test) are already cacheable. Use targetDefaults for your own targets or to change inputs:
{
"namedInputs": {
"production": ["default", "!{projectRoot}/**/*.spec.ts"]
},
"targetDefaults": {
"build": { "dependsOn": ["^build"], "cache": true, "inputs": ["production", "^production"] },
"lint": { "cache": true }
}
}
Tasks that are not deterministic (deploy, dev servers) must not be cached.
Step 5: Remote cache and CI
npx nx@latest connect # link the workspace to Nx Cloud for a shared cache
npx nx reset # clear local cache and the daemon state when results look stale
npx nx migrate latest && npx nx migrate --run-migrations # upgrade; one major version at a time
Examples
Example 1: Start a TypeScript monorepo with a shared library
Request: "Set up a monorepo with a shared utils package and build it."
npx create-nx-workspace@latest acme-platform --preset=ts --nxCloud=skip --no-interactive
cd acme-platform
npx nx g @nx/js:lib packages/shared-utils --bundler=tsc --unitTestRunner=none --linter=none
npx nx build shared-utils && npx nx build shared-utils
The first build prints Cache: 0/1 hit (0%); the second replays from the cache and prints 1/1 hit (100%) in a few milliseconds.
Example 2: Only test what a pull request touched
Request: "CI takes 25 minutes, make it run only what changed."
git fetch origin main
npx nx affected -t lint test build --base=origin/main --head=HEAD --parallel=3
Nx finds the changed files, maps them to projects through the graph, and also runs dependents of those projects. Untouched packages are skipped; if nothing is affected it prints "No tasks were run". In GitHub Actions use a full checkout (fetch-depth: 0) so the base commit exists.
Guidelines
- Cache correctness depends on declared inputs and outputs: if a task reads an env var or a file outside the project, add it to
inputs, or stale results will be replayed. nx affectedneeds git history; a shallow clone gives wrong or empty results.- Remote caches are shared: do not put secrets in task outputs, and restrict write access to CI.
- Keep Nx and all
@nx/*packages on the same version; upgrade withnx migrate, not by editing versions. - A single small package does not need Nx; it pays off with several projects, shared libraries or slow CI.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/nx-javascript-typescript-monorepos-mwirmdxd/download' --output '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md.part' && mv '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md.part' '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Environment declared by the author: Node.js 20+ and npm, pnpm, yarn or bun; any framework (React, Angular, Node, Next.js and more)
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && test -s '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nx' && cp -R '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd' '.claude/skills/nx'Cursor
test -f '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && test -s '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/nx' && cp -R '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd' '.cursor/skills/nx'Codex
test -f '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && test -s '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/nx' && cp -R '.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd' '.agents/skills/nx'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd'openskills read 'nx-javascript-typescript-monorepos-mwirmdxd'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/nx-javascript-typescript-monorepos-mwirmdxd/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.