stack-nx
Skill0 starsChanged 5 months agoApache-2.0View on GitHub
Nx monorepo implementation patterns for agents working in projects whose docs/TECH_STACK.md lists nx. Load when implementing, testing, or reviewing code on this stack.
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- flow-adoptionSkill
- flow-legacy-migrationSkill
- stack-awsSkill
- stack-azureSkill
- stack-design-systemSkill
- stack-gcpSkill
- stack-javaSkill
- stack-kafkaSkill
- stack-mongodbSkill
- stack-natsSkill
- stack-nestjsSkill
- stack-nextjs-reactSkill
- stack-playwrightSkill
- stack-postgresqlSkill
- stack-quarkusSkill
- stack-react-nativeSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Create new apps/libs via the workspace's generators (pnpm nx g @nx/js:lib … or project-local generators under tools/), never by …
- Very specific: line 37
Check nx.json generators defaults and tools/ for project-local generators before reaching for the stock ones.
- Very specific: line 45
Every pnpm / nx / node / prisma invocation is prefixed: docker compose exec app pnpm nx affected -t test.
- Very specific: line 47
Read-only tools (grep, find, cat, git, gh) run on the host normally.
- Very specific: line 51
When docs/DEV_SETUP.md declares a host-local Node runtime instead, run the bare commands.
- Very specific: line 55
Run tests through the affected graph (pnpm nx affected -t test).
- Distinctive: line 57
Test placement follows lib boundaries: a lib's tests live in that lib and may not import across a forbidden boundary just to arrange …
- Very specific: line 80
All rows must pass before commit per .claude/rules/LIVE_VALIDATION.md.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Stack: Nx
When this applies
Detection markers (any of):
docs/TECH_STACK.md## Detected stackslistsnx- Dependencies:
nx,@nx/*plugins - Files:
nx.json, per-projectproject.json, anapps/+libs/workspace layout
Implementation patterns
Affected-graph commands (default execution mode)
Scope every check to what actually changed — never run the full repo when affected suffices:
pnpm nx affected -t typecheck
pnpm nx affected -t lint
pnpm nx affected -t test
pnpm nx affected -t buildSingle-project scoping when iterating: pnpm nx test <project> --testPathPattern='<pattern>'. Orientation commands: pnpm nx show projects, pnpm nx graph.
Lib / module boundaries
@nx/enforce-module-boundaries(withno-restricted-importsfor intra-project layering) is load-bearing in CI. A disabled boundary rule is itself a review BLOCKER — the architecture arrow can silently invert without it.- This rule is also the fitness function for architectural ACs on this stack (
.claude/rules/BDD_GWT.md§"Architectural ACs"): when a task's deliverable is the boundary itself, thedepConstraintsentry (or ano-restricted-importspath rule) IS the RED test — it fails while a forbidden import or untagged lib exists, and the dev task makes it green by placing/tagging the lib correctly. Contract-existence ACs use the compile-against-the-*-api-libshape: a consumer that fails to typecheck against an absent exported contract is the RED. - Boundaries are declared via
tagsinproject.jsonand thedepConstraintsmatrix in the root ESLint config. New libs get tags at creation; an untagged lib is unbounded. - Contract/API libs pattern:
libs/<domain>-api-lib(or the project's equivalent — seedocs/ARCHITECTURE.md) exports the shared contract (types, schemas, operations). The backend implements it; frontends import it; nobody duplicates it.
Generators
- Create new apps/libs via the workspace's generators (
pnpm nx g @nx/js:lib …or project-local generators undertools/), never by hand-copying folders — generators wire tags, lint, tsconfig paths, and test targets consistently. - Check
nx.jsongeneratorsdefaults andtools/for project-local generators before reaching for the stock ones.
Task pipeline & caching
- Targets are cached (
dependsOn,outputsinnx.json/project.json). Never hand-edit files inside cachedoutputs— rebuild instead. - A surprising "everything affected" result usually means a change to a root config file (
nx.json,tsconfig.base.json) — expected, not a bug.
Docker-as-Runtime pattern (DEV_SETUP-dependent — NOT universal)
Some host projects run Node exclusively inside a container; the host has no Node runtime. Check docs/DEV_SETUP.md first — apply this only when it declares the pattern:
- Every
pnpm/nx/node/prismainvocation is prefixed:docker compose exec app pnpm nx affected -t test. pnpm installMUST run inside the container — native modules (argon2,@prisma/engines,@swc/core) compile for the container OS; host-built binaries won't load.- Read-only tools (
grep,find,cat,git,gh) run on the host normally. - Containers must be up before any agent work (
docker compose up -dor the project'smake up). - Projects often wrap common operations in
maketargets (make test,make migrate,make dev) — prefer them whendocs/DEV_SETUP.mdlists them.
When docs/DEV_SETUP.md declares a host-local Node runtime instead, run the bare commands. Never assume either mode.
Testing on this stack
- Run tests through the affected graph (
pnpm nx affected -t test); scope to one project while iterating (pnpm nx test <project>). - E2E projects follow the
<app>-e2econvention:pnpm nx e2e <app>-e2e --testGrep='AC-<FEATURE>'. - Test placement follows lib boundaries: a lib's tests live in that lib and may not import across a forbidden boundary just to arrange fixtures — if a test needs another lib's internals, the boundary or the test is wrong.
Spec validation checks
Stack-specific checks the spec validators delegate here (Nx concerns are mostly structural, so this list is short):
| Check | Severity |
New modules/components in the spec map to an apps//libs/ placement consistent with docs/ARCHITECTURE.md boundaries | WARNING |
| Shared contracts placed in a contract lib, not duplicated per consumer | WARNING |
Spec does not require an import that the workspace depConstraints forbid | WARNING |
Live validation commands
R-VAL entries for this stack express the LIVE_VALIDATION matrix in Nx terms — exact invocations (and whether they carry the docker compose exec app prefix) live in docs/DEV_SETUP.md:
| Change surface | Obligation |
| Backend/lib code (R-VAL-01) | nx affected -t typecheck lint test green |
| Frontend code (R-VAL-03) | nx affected -t typecheck lint build green + dev-server check |
| Test-only changes (R-VAL-04) | run the affected suite; observe RED-or-GREEN per the task's BDD intent |
Tooling (nx.json, project.json, root tsconfig) (R-VAL-06) | run one representative target end-to-end; confirm the graph still resolves (nx graph --file=/dev/null or nx show projects) |
All rows must pass before commit per .claude/rules/LIVE_VALIDATION.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

