agentleFS
isabelle-barpisabelle-barp/agent-brain/skills/stack-nx/SKILL.md

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.

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
  1. Very specific:

    Create new apps/libs via the workspace's generators (pnpm nx g @nx/js:lib … or project-local generators under tools/), never by …

    line 36
  2. Very specific:

    Check nx.json generators defaults and tools/ for project-local generators before reaching for the stock ones.

    line 37
  3. Very specific:

    Every pnpm / nx / node / prisma invocation is prefixed: docker compose exec app pnpm nx affected -t test.

    line 45
  4. Very specific:

    Read-only tools (grep, find, cat, git, gh) run on the host normally.

    line 47
  5. Very specific:

    When docs/DEV_SETUP.md declares a host-local Node runtime instead, run the bare commands.

    line 51
  6. Very specific:

    Run tests through the affected graph (pnpm nx affected -t test).

    line 55
  7. Distinctive:

    Test placement follows lib boundaries: a lib's tests live in that lib and may not import across a forbidden boundary just to arrange …

    line 57
  8. Very specific:

    All rows must pass before commit per .claude/rules/LIVE_VALIDATION.md.

    line 80

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Stack: Nx

When this applies

Detection markers (any of):

  • docs/TECH_STACK.md ## Detected stacks lists nx
  • Dependencies: nx, @nx/* plugins
  • Files: nx.json, per-project project.json, an apps/ + 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 build

Single-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 (with no-restricted-imports for 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, the depConstraints entry (or a no-restricted-imports path 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-lib shape: a consumer that fails to typecheck against an absent exported contract is the RED.
  • Boundaries are declared via tags in project.json and the depConstraints matrix 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 — see docs/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 under tools/), never by hand-copying folders — generators wire tags, lint, tsconfig paths, and test targets consistently.
  • Check nx.json generators defaults and tools/ for project-local generators before reaching for the stock ones.

Task pipeline & caching

  • Targets are cached (dependsOn, outputs in nx.json/project.json). Never hand-edit files inside cached outputs — 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 / prisma invocation is prefixed: docker compose exec app pnpm nx affected -t test.
  • pnpm install MUST 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 -d or the project's make up).
  • Projects often wrap common operations in make targets (make test, make migrate, make dev) — prefer them when docs/DEV_SETUP.md lists 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>-e2e convention: 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):

CheckSeverity
New modules/components in the spec map to an apps//libs/ placement consistent with docs/ARCHITECTURE.md boundariesWARNING
Shared contracts placed in a contract lib, not duplicated per consumerWARNING
Spec does not require an import that the workspace depConstraints forbidWARNING

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 surfaceObligation
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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.