Skip to content
Back to skills

Nx Tasks Reference

ASecurity

What each nx.json target does and when to add it to project.json

  • 9 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 5, 2026
testingjavascripttypescriptrustgojavashellsqlnodetestinggit

Works with

  • terminal
  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned November 25, 2026

npx -y skills add JacobLey/leyman --skill nx-tasks-reference --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nx Tasks Reference?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nx Tasks Reference
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jacobley-nx-tasks-reference/badge)](https://www.skillsdirectory.com/skills/jacobley-nx-tasks-reference)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nx-tasks-reference
description: What each nx.json target does and when to add it to project.json
---

# Nx Task Reference

Every package in this repo is wired into the same lifecycle via `nx.json` `targetDefaults`. When adding or modifying a `project.json`, declare the targets the package needs as `{}` — the full implementation comes from the targetDefault.

The TypeScript targets (`biome`, `eslint`, `check-package`, `update-ts-references`, `tsc`, `tsc-test`, `mocha-unit-test`, `mocha-integration-test`, `vitest-unit-test`, `coverage-report`, `sync-injected`), their named inputs (`dependency-files`, `package-files`, `eslint-input`, `ts-source`, `dependency-builds`, `test-source`) and which projects declare them are generated by [`@leyman/nx-plugin`](../../../leyman/nx-plugin/) from [`leyman/main/nx-plugin.json`](../../../leyman/main/nx-plugin.json): change that file, not `nx.json` (only their `dependsOn` stays nx-lifecycle's), and a project's files rather than its `project.json` (`test/unit` with mocha installed gets `mocha-unit-test`...). `nx run @leyman/main:lifecycle` runs it first, and fails on drift in CI. A declaration with options of its own is kept, as an override.

The orchestration targets (`check:_`, `check:lint`, `check`, …) are no-ops that only enforce ordering. `nx run @leyman/main:lifecycle` adds them to `project.json` and generates their `dependsOn` from [`lifecycle.json`](../../../leyman/main/lifecycle.json). See the [lifecycle skill](../../../leyman/main/.agents/skills/lifecycle/SKILL.md).

### Project layout and caching

Cache inputs are globs, so they only work if every package puts things in the same place. A file outside these locations is invisible to caching: changing it will not rerun anything.

| Path                                                              | Tracked | Role                                                                                | Hashed as                              |
| ----------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------- | -------------------------------------- |
| `src/`                                                            | yes     | Shipped source. Only the package itself reads it                                    | `ts-source`                            |
| `test/`                                                           | yes     | Tests, fixtures (any file type) and `test/tsconfig.json`                            | `test-source`                          |
| `dist/`                                                           | no      | Build output (`tsc`): exactly what ships. The only built code dependents may import | `dependency-builds`, for dependents    |
| `dist-test/`                                                      | no      | Compiled tests (`tsc-test`). Never seen by dependents                               | —                                      |
| `out/`                                                            | yes     | Generated files that ship (`populate-files`, e.g. JSON schemas)                     | `package-files`                        |
| `data/`                                                           | yes     | Static files that ship and are read at runtime or by dependents                     | `package-files`                        |
| `migrations/`                                                     | yes     | Database migrations                                                                 | `schema-snapshot`, `drizzle-kit-check` |
| `schema.sql`                                                      | yes     | What the migrations build, generated by `schema-snapshot`                           | `test-source`                          |
| `package.json`, `bin.mjs`, `executors.json`, `*.d.ts` at the root | yes     | Package entry points                                                                | `package-files`                        |

Named inputs in [`nx.json`](../../../nx.json):

- `ts-source`: the project's own source and build config, and the shared configs it reads from [`@leyman/configs`](../../../leyman/configs/). A change rebuilds the project. The shared configs are hashed at `{workspaceRoot}/leyman/configs/`: tools read each package's installed copy, which no build writes for Nx to hash as an output.
- `dependency-builds`: the `.js` and `.d.ts` files in dependencies' `dist/`, and their `package-surface.json`, via `dependentTasksOutputFiles`. Dependents rebuild when a dependency's build output changes, not when its source changes. This is why tests compile to `dist-test/` rather than `dist/tests/`: `dependentTasksOutputFiles` ignores negated outputs, so tests inside `dist/` would rebuild every dependent when they change.
- `package-files`: the project's own tracked entry points (`package.json`, `bin.mjs`, `out/`, `data/`…).
- `^dependency-files`: dependencies' `package-files`, minus `package.json`. Targets list it directly, because Nx does not allow `^` inside a named input. A dependency's `package.json` reaches dependents through its `package-surface.json` instead, written by [`sync-injected`](#sync-injected), which drops fields that can't affect them (`version`, `description`, `scripts`, `devDependencies`…), so a release's version bump reruns only the bumped package's tasks. A task whose result reads one of those fields of a dependency lists `^package-files` instead, as `vitepress-build` does for `homepage`.
- `test-source`: `ts-source` plus `test/`, `tsconfig.test.json`, the project's own `package-files`, the builds of its dependencies and itself, and the c8 config.
- `goSource`: a Go project's `go.mod`, `go.sum` and `.go` files, defined per project by gonx. Go targets also hash `^goSource` and the Go version.
- `rustSource`: a Rust project's `Cargo.toml`, `src/**/*.rs` and `tests/**/*.rs`, with the root `Cargo.toml` and `Cargo.lock`. Rust targets also hash `^rustSource`, `^dependency-files` (`include_str!` reads files like `data/`, that `rustSource` does not cover) and the Rust version.
- `shared-globals`: the Node version. The cache is shared between worktrees through the `nx-cache` sidecar.
- `postgres` and `valkey`: the versions of the services a task runs against (and of `pg_dump`), read from the running server, since the same image in the devcontainer and in Dagger is only pinned by convention. A project whose integration tests use one adds it to the target defaults' inputs with Nx's spread, rather than copying the list: `"mocha-integration-test": { "inputs": ["...", "valkey"] }`. Any other tool from outside the repository that a task's result depends on needs a `runtime` input like these, or a cached result outlives a change to it.

Gotchas, all verified on Nx 23:

- Nx hashes the root `tsconfig.base.json` into every task, or the root `tsconfig.json` if there is none. So `tsconfig.base.json` stays empty, and shared compiler options go in [`@leyman/configs`](../../../leyman/configs/): an edit to `tsconfig.base.json` misses the cache on every task. The root `tsconfig.json` is free to change, as its `references` do with each new package.
- **Never hash `dist/` with a file glob.** `dist/` is gitignored, and Nx only sees git-visible files, so a glob like `^{projectRoot}/dist/**` silently matches nothing. Use `dependentTasksOutputFiles`.
- **`dependentTasksOutputFiles` does not support extglobs** like `*.(c|m)?js`. Use one entry per extension. Plain file inputs do support them.
- **A generator's inputs must include everything it reads,** not just the files it writes. `barrelify` hashes all of `src/`, since adding a sibling module changes the barrel.
- **Clean output inside the task that writes it** (as `tsc` and the test targets do), not in a separate uncached target. An uncached cleanup runs every time and forces every cached output to be copied back.

Nx hashes each project's npm dependencies (direct and transitive, resolved from `pnpm-lock.yaml`) through the project graph, so a lockfile change only invalidates projects that depend on the changed package. `ts-source` sets `{ "externalDependencies": [] }` to opt out of Nx's default for `nx:run-commands` targets, which hashes _every_ external package in the workspace (`AllExternalDependencies`) and busts all caches on any lockfile change.

Use `nx show target inputs <project>:<target>` to list the files a target hashes. Add `--check <path>` to test a single file. Neither shows `dependentTasksOutputFiles`, so test those by changing a dependency and checking that the dependent reruns.

---

## Work Targets

Every work target except repo-wide commands (like `lifecycle` itself) must be bound in `lifecycle.json`.

### `biome`

Formats with Biome ([`biome-format.sh`](../../../leyman/nx-plugin/scripts/biome-format.sh)). Writes changes, except in CI where it only checks. `-c check` checks without writing.

**Add when:** Every package.

---

### `dagger-develop`

Runs `dagger develop` (`scripts/nx/dagger-develop.sh`), writing the gitignored code the Dagger module compiles against. Takes a few seconds, so it runs every time, and needs the engine. Does nothing in CI, where `New` in `dagger/main.go` overlays the same code.

**Add when:** Only `dagger/`.

---

### `gofmt`

Formats Go source with `golangci-lint fmt` (`scripts/nx/gofmt.sh`), which runs the formatters in `.golangci.yml`. Like `biome`, writes changes, except in CI where it fails showing the diff.

**Add when:** Go projects (has `go.mod`).

---

### `rustfmt`

Formats Rust source with `cargo fmt` (`scripts/nx/rustfmt.sh`). Like `biome`, writes changes, except in CI where it fails.

**Add when:** Rust projects (has `Cargo.toml`).

---

### `eslint`

Lints with the project's `eslint.config.js`. `-c fix` auto-fixes.

**Add when:** Add to all TypeScript packages (has `tsconfig.json`).

---

### `drizzle-kit-check`

Fails if the package's Drizzle schema has changes that no migration covers, or its migrations conflict (`drizzle-kit check`). It never writes a migration: they are reviewed files with names, generated by hand with `drizzle-kit generate --name <name>`. Runs `scripts/nx/drizzle-kit-check.sh`, which generates into a temporary copy of `migrations/` and compares, never touching the real one. Any error output fails it, as drizzle-kit exits 0 when it fails (e.g. when it can't ask about a rename without a terminal). Expects `drizzle.config.js` at the package root (JavaScript, so ESLint and c8 treat it as a config file).

**Add when:** The package has a Drizzle schema. Pair it with `schema-snapshot` (`drizzle-kit migrate`).

---

### `check-package`

Packs the package with `pnpm pack`, exactly as it would be published, and checks the tarball, with [`@leyman/check-package`](../../../apps/check-package/) (`--profile esm-only --floor-tsconfig '@leyman/configs/tsconfig.node-{major}.json'`):

- [publint](https://publint.dev/), in strict mode: `exports`, `bin` and other entry points exist in the tarball and are well formed.
- [Are The Types Wrong](https://arethetypeswrong.github.io/): every entry point resolves to JavaScript and types for ESM consumers, under both Node.js (`node16`) and bundler resolution. CommonJS and `node10` resolution are expected to fail for ESM-only packages, so they are not checked.
- Declarations: `tsc` type checks the published `.d.ts` files as a strict consumer with `skipLibCheck: false` would. A `@ts-expect-error` in `src/` doesn't reach the declarations, so the error it hid fails here. Errors in dependencies' declarations are ignored.
- Support floor: `tsconfig.json` extends `@leyman/configs/tsconfig.node-<major>.json` and the installed `@types/node` has that major version (so `catalog:node-<major>`), for the major version of `engines.node` (see [Support floors](../typescript/SKILL.md#support-floors)). Every runtime dependency's `engines.node` must allow the oldest version the package's allows, so lowering a floor fails while a dependency still needs newer, and raising a dependency's fails until its dependents follow.
- Published files: every top-level path not ignored by `.gitignore` is either published, or on check-package's list of paths never published (`src`, `test`, `project.json`, ...; more with `--not-published`), and nothing on that list is published. A new path, like `data/`, fails until it is added to one or the other.

Every package that isn't `private` gets it, built or not. One with no entry point (no `main`, `exports`, `bin` or types), like `@leyman/configs`, is checked as files only: publint and the published files, with no `engines.node` needed.

It hashes everything in the project but `test/`, `CHANGELOG.md` and `eslint.config.js`, whose contents can't change the result, so a new top-level path still reruns it.

`e2e/published-entrypoints` complements it at runtime, importing every entry point from the published files.

Runs in `check:lint`, after the package's own build, so a packaging mistake fails CI on the PR rather than after a release.

**Add when:** The package is published (not `"private"`).

---

### `check-fork-manifest`

Fails if a file under one of `leyman/main/fork-manifest.json`'s `roots`, or at the top of the workspace, isn't classified exactly once, or if the manifest names a path, condition or target that doesn't exist (`leyman/main/scripts/check-fork-manifest.mjs`). It then applies the manifest to a temporary directory, with no optional conditions and with all of them, and fails if the result names a script, target, input, patch, catalog entry or config that didn't come along. It also fails if the [fork-manifest skill](../fork-manifest/SKILL.md)'s generated table is out of date. Runs in `check:lint`. It lists files with git and skips inside Dagger, whose source leaves out `.git` and most of the roots, so CI's `test` job runs the script from the checkout before Dagger starts.

**Add when:** Never: only `@leyman/main` has it. A new file under a root goes in the manifest.

---

### `fork-manifest-audit`

Applies the manifest with `tools/parse-cwd` as a sample package, installs that from nothing, runs `verify` there and checks `lifecycle` generates no drift (`leyman/main/scripts/audit-fork-manifest.mjs`). Defined in `@leyman/main`'s `project.json` and bound to no stage, so `verify` never runs it. It is one target in one project, and it needs the network and a run from nothing, so it is never cached. The weekly `Adoption audits` workflow runs it, and failing there blocks nothing.

**Add when:** Never: only `@leyman/main` has it.

---

### `starter-audit`

Runs every `sh` block of the [getting-started page](../../../docs/src/framework/getting-started.md) in order in a temporary directory, as a new user would with the published packages, then declares `sync-injected` on the dependency and runs `verify` again (`leyman/main/scripts/audit-starter.mjs`). `--local` installs this repository's builds of those packages instead, for a change before its release. Defined in `@leyman/main`'s `project.json` and bound to no stage, like `fork-manifest-audit`, and for the same reasons never cached. The weekly `Adoption audits` workflow runs it, and failing there blocks nothing.

**Add when:** Never: only `@leyman/main` has it.

---

### `check-parity`

Fails if the versions the devcontainer and CI pin separately differ (`leyman/main/scripts/check-parity.mjs`), naming each location and its value. Runs in `check:lint`. It skips inside Dagger, whose source leaves out `.devcontainer`, `.github` and `dagger`, so CI's `test` job runs the script from the checkout before Dagger starts.

**Add when:** Never: only `@leyman/main` has it. A new pin goes in the script's `checks`.

---

### `check-skills`

Fails if a skill that a package of this workspace ships (`<package>/skills/<name>/SKILL.md`) isn't linked into `.agents/skills/<name>`, or a link there names a skill no package ships (`leyman/main/scripts/link-skills.mjs --check`). pnpm links an installed dependency's skills once approved, but never a workspace package's, which is where all of this repository's are. Runs in `check:lint`. Fix it with `node leyman/main/scripts/link-skills.mjs`. It skips inside Dagger, whose source leaves out `.agents`, so CI's `test` job runs the script from the checkout before Dagger, as it does `check-parity` and `check-fork-manifest`.

**Add when:** Never: only `@leyman/main` has it.

---

### `check-workspace-dependencies`

Fails if a `package.json` or catalog takes a package in this workspace from npm rather than `workspace:` (`leyman/main/scripts/check-workspace-dependencies.mjs`), including through an `npm:` alias. pnpm's `disallowWorkspaceCycles` fails on a cycle, and a published copy is the only way around it. Runs in `check:lint`.

**Add when:** Never: only `@leyman/main` has it.

---

### `drop-when-check`

Fails on a malformed [`drop-when`](../../../apps/drop-when/) marker (the line beside a workaround naming the upstream fix or the date that ends it) in any file of the workspace that no `.gitignore` ignores, naming the file and line. It leaves out `apps/drop-when`, whose sources, tests and README hold the token as examples. Runs in `check:lint`, cached on every file of the workspace. It reads no Git metadata, so it runs the same in Dagger, whose source has no `.git`.

**Add when:** Never: only `@leyman/main` has it.

---

### `drop-when-report`

Resolves every marker against GitHub and prints which workarounds are due, as Markdown (`leyman/main/scripts/drop-when-report.sh`): those whose fix is in a release at least 7 days old, matching `minimumReleaseAge`. It takes `GITHUB_TOKEN`, or else `gh auth token`, which only raises the rate limit. Defined in `@leyman/main`'s `project.json` and bound to no stage: it depends on the network and the date, so it is never cached and never part of `verify`. Run it by hand.

**Add when:** Never: only `@leyman/main` has it.

---

### `tofu-fmt`

Formats OpenTofu configuration with `tofu fmt` (`scripts/nx/tofu-fmt.sh`). Like `gofmt`, writes changes, except in CI where it fails showing the diff.

**Add when:** OpenTofu projects (`*.tf` files, e.g. `infra/nx-cache/tofu`).

---

### `tofu-validate`

Runs `tofu init -backend=false -lockfile=readonly` then `tofu validate` (`scripts/nx/tofu-validate.sh`): the configuration is valid, with the providers in the committed lock file. Needs no credentials or state, so it runs on pull requests. `plan` and `apply` are never targets: they need credentials, and are run by hand (see `infra/nx-cache/README.md`). Runs in `check:lint`.

**Add when:** OpenTofu projects, with `tofu-fmt`.

---

### `check-version`

Fails if `tools/local-ingress`'s image or compose file changed without a `VERSION` bump (`tools/local-ingress/check-version`), since `ensure` only replaces a running ingress with a newer version. Defined in that project's `project.json`, not in `targetDefaults`. Runs in `check:lint`.

**Add when:** Never: only `tools/local-ingress` has it.

---

### `check-go-release`

Fails unless a released Go module's `VERSION` is `X.Y.Z` and heads its `CHANGELOG.md`, fits its module path's major version, and every workspace module it requires (through a local `replace`) is released and required at its `VERSION` (`leyman/main/scripts/check-go-release.mjs`). Runs in `check:lint`.

**Add when:** a Go module is released, with its `VERSION` and `CHANGELOG.md` (see the [versioning skill](../versioning/SKILL.md#go-modules)).

---

### `go-lint`

Runs `golangci-lint run ./...` with the workspace's `.golangci.yml`, where every linter is on (`go vet` is one of them). Runs in `check:lint`, like `eslint`. Inferred by gonx (see [Go projects](#go-projects)).

**Add when:** Never: inferred for every Go project.

---

### `rust-clippy`

Runs Clippy with warnings as errors, natively and, for a crate that compiles to it, for WASM. Runs in `check:lint`, like `eslint`. Inferred (see [Rust projects](#rust-projects)).

**Add when:** Never: inferred for every Rust project.

---

### `barrelify`

Rewrites `index.ts` files that contain an `// AUTO-BARREL` marker with correct re-export statements.

**Add when:** The package has any `index.ts` files marked with `// AUTO-BARREL`. A package `barrelify` depends on can't have this target, as that would be a cycle: it keeps the marker and writes the file by hand, and `e2e/published-entrypoints` fails if the file is out of date.

---

### `populate-docs`

Only in `@leyman/docs`: runs [`docs/scripts/populate-docs.mjs`](../../../docs/scripts/populate-docs.mjs), which writes the generated docs pages (each demo's page, each `why.md`) and the tables in `AGENTS.md`, the READMEs and the skills (see the [docs-site skill](../docs-site/SKILL.md)). In CI it only checks. It runs in `prepare:generate`, before `vitepress-build` reads the pages, so a new demo's page is written before the site builds. Uncached: it reads every project's README and `package.json`.

---

### `schema-snapshot`

Keeps `schema.sql` of what the package's Postgres migrations build, with [`pg-dolly-schema`](../../../apps/pg-dolly-schema/): migrates an empty database on the `postgres` sidecar (Dagger's service in CI), dumps its schema, and writes `schema.sql`. In CI it only checks, failing if the committed file is stale. Tests build their databases from it with [`pg-dolly`](../../../tools/pg-dolly/) (see the [testing skill](../testing/SKILL.md#postgres-tests)).

The package devDepends on `pg-dolly-schema` and sets its own migrate command, in `env` (never as an option: Nx passes options in double quotes, where the shell would expand `$DATABASE_URL` too early):

```json
"schema-snapshot": { "options": { "env": { "PG_DOLLY_SCHEMA_MIGRATE": "drizzle-kit migrate" } } }
```

Hashes `src/`, `migrations/`, `schema.sql`, dependencies' builds, `postgres` (`pg_dump --version` and the server's version, `psql "$DATABASE_URL" -XtAc 'SHOW server_version'`) and `CI`. Migrations elsewhere, or a migrate tool's config file outside `src/` (e.g. `drizzle.config.js`), go in the project's own `inputs` (this repo's Drizzle packages add `drizzle.config.js`). The command runs before the package is built, so a TypeScript migrate script runs with Node's type stripping (`node migrate.ts`), not from `dist/`.

**Add when:** The package has Postgres migrations.

---

### `genever-go`

Writes Go types from a JSON Schema file or OpenAPI document with [genever-go](../../../apps/genever/go/), by running the project's `//go:generate go tool genever ...` directives (`go generate -run '^//go:generate go tool genever ' ./...`, so other directives don't run). The directive names the input, the package and `--signed`, and the module requires genever-go as a `tool`, with `replace` directives to the workspace copies of it and its dependencies. In CI genever-go only checks (its `--ci` is on when `CI` is set), failing if the committed file is stale; an edited signed file fails everywhere.

Hashes the project's `goSource` (which includes the generated file), `^goSource`, `^dependency-files` (an input such as a spec project's `out/openapi.json`), the Go version and `CI`. It declares no outputs: the generated file is committed and hashed, so a cache hit means it is already up to date. List `@leyman/genever-go` under `implicitDependencies`, since gonx infers dependencies from imports, not `tool` directives. The generated file says `Code generated ... DO NOT EDIT.`, which golangci-lint's `generated: lax` leaves out of lint and formatting. See `demos/openapi/go`.

**Add when:** A Go project generates types with genever-go.

---

### `update-ts-references`

Keep `tsconfig.json` `references` in sync with the package's inter-package dependencies.

**Add when:** The package has a `tsconfig.json`.

---

### `tsc`

Clears `./dist` ([`clean-dist.sh`](../../../leyman/nx-plugin/scripts/clean-dist.sh)), then compiles TypeScript using SWC (fast transpilation) and `tsc` (declaration file generation + type checking). SWC runs through [`swc-compile.sh`](../../../leyman/nx-plugin/scripts/swc-compile.sh), which only adds its `.mts` and `.cts` passes for a package that has those files. Clearing `dist` inside the target means it only happens on a cache miss.

The clear keeps `tsconfig.tsbuildinfo` and the declarations while the declarations match the current sources, so `tsc` only redoes what changed. Never delete a declaration and keep the build info: `tsc` trusts the build info, doesn't write the file again, and still passes.

Output goes to `./dist`.

A package using content mappers runs [`trusted-tsc`](../../../apps/trusted-tsc/) by setting `"options": { "env": { "TSC": "trusted-tsc" } }` on both this and `tsc-test`.

**Add when:** Add to all TypeScript packages (has `tsconfig.json`).

---

### `vitepress-build`

Builds a [VitePress](https://vitepress.dev/) site from `src/` into `./dist`, clearing it first.

Dependencies' builds are inputs, since the docs site type-checks its examples against them (see [`docs/README.md`](../../../docs/README.md)).

**Add when:** The project is a VitePress site. Only `docs/` today.

---

### `tsc-test`

Deletes `./dist-test`, compiles `test/` into it with SWC, then type-checks the tests with `tsc -p ./test` (no emit; `test/tsconfig.json` extends the shared [`@leyman/configs/tsconfig.test.json`](../../../leyman/configs/tsconfig.test.json)). Runs in `test:compile`, after the package's own build, so tests are type-checked against its published `.d.ts` exactly as a consumer would see them.

**Add when:** The package has tests. Add whenever `mocha-unit-test`, `mocha-integration-test`, or `vitest-unit-test` is present.

---

### `populate-files`

Generates static output files by running `load-populate-files` against `./dist/file-content.js`. Expects the package to export a default array of `PopulateFileParams` from `src/file-content.ts`. Output goes to `./out`. The files are recorded in `./out/.generated.json` (a populate-files manifest), so a hand edit to them fails CI, and `--clean` only removes files a previous run wrote. Commit the manifest, and exclude it from `files` in `package.json` (`"!out/.generated.json"`).

This is also the route for types generated from a schema: call `genever()` from `src/file-content.ts`, as [`demos/openapi/spec`](../../../demos/openapi/spec/src/file-content.ts) does, so the schema is an input through the package's own build.

**Add when:** The package defines a `src/file-content.ts` file.

---

### `sync-injected`

Mirrors the package's published files (`pnpm pack --dry-run`) into its injected copies in `node_modules/.pnpm` ([`sync-injected.mjs`](../../../leyman/nx-plugin/scripts/sync-injected.mjs)). Workspace dependencies are installed as copies (`injectWorkspacePackages`), made at install time, so without this dependents would keep seeing the `dist/` from the last `pnpm install`. Never cached: it must also run when `tsc` is a cache hit, since restoring `dist/` doesn't update the copies.

Also writes `.package-surface/<project>/package-surface.json` (gitignored): `package.json` without the fields listed as inert in the script. Dependents hash this rather than the file. Fields are listed as inert rather than consumed, so a new field invalidates until someone decides it can't matter.

A build outside Nx (e.g. running `tsc` directly) doesn't sync. Run the package's `build`, or `pnpm install`, which also refreshes every copy.

**Add when:** Every package with `tsc`.

---

### `playwright-install`

Downloads the Chromium, Firefox and WebKit builds for the project's Playwright version (`playwright install`), to `PLAYWRIGHT_BROWSERS_PATH`. Runs in `test:compile`, before the test suites. Never cached: the browsers live outside the workspace, and it is a quick no-op once they are downloaded. Their system libraries need root, so they come from the devcontainer image instead (see the [devcontainer skill](../devcontainer/SKILL.md)). Downloads nothing when `PW_TEST_CONNECT_WS_ENDPOINT` names a Playwright server to connect to, as in the Dagger pipeline, whose `playwright` service has every browser and its libraries.

**Add when:** The package's tests drive browsers with Playwright.

---

### `fetch-suites`

Downloads the external test suites pinned in the project's `test/suites.json` (a URL and the tarball's sha256 each) into its gitignored `.suites/`, with its `test/fetch-suites.ts` (run by Node.js directly). Runs in `test:compile`, before the test suites. Cached, with only the tarballs as outputs: a fresh checkout, or a Dagger run, restores them from the Nx cache instead of the network, and the script skips any tarball already holding the pinned hash. A download is checked against its hash before it is kept. Tests extract a tarball into a temporary directory of their own, so the suite's files never enter the workspace or a cache input.

**Add when:** The package's tests run a large third-party suite that has no npm package, e.g. `e2e/xenever-oracle` (the W3C XSD and XML suites).

---

### `mocha-unit-test`

Clears its coverage directory, then runs Mocha unit tests from `./dist-test/unit/**/*.spec.*js` under C8 coverage instrumentation.

**Add when:** The package has unit tests in `test/unit/`. Add to virtually all packages.

---

### `mocha-integration-test`

Clears its coverage directory, then runs Mocha integration tests from `./dist-test/integration/**/*.spec.*js` under C8 coverage instrumentation.

**Add when:** The package has integration tests in `test/integration/`.

---

### `vitest-unit-test`

Clears its coverage directory, then runs Vitest unit tests from `./dist-test/unit/**/*.spec.js` under C8 coverage instrumentation, using the shared [`vitest.config.js`](../../../leyman/configs/vitest.config.js), read from the package's installed `@leyman/configs`.

The shared config runs pre-compiled tests with native `import` and the `threads` pool (so C8 can collect V8 coverage), and sets `sequence.hooks: "list"` (required by `vitest-chain`).

**Add when:** The package tests with Vitest instead of Mocha (e.g. `vitest-chain`). Use instead of `mocha-unit-test`.

---

### `rust-wasm`

Builds the crate for `wasm32-unknown-unknown` into `dist/`: with its JavaScript bindings (`wasm-bindgen --target web`) when the crate depends on `wasm-bindgen`, and otherwise the bare `.wasm`, for a host that calls its exports itself, such as Go through wazero (see `demos/blake3-go`). Runs in `build:run`, like `tsc`. The build removes the toolchain's path from the output, so it gives the same bytes wherever it runs. Inferred (see [Rust projects](#rust-projects)).

**Add when:** Never: inferred for a crate that depends on `wasm-bindgen` or builds a `cdylib`.

---

### `rust-test`

Runs the crate's tests under `cargo llvm-cov`, writing a summary to `coverage/llvm-cov.json` (gitignored). Native only, so a file compiled just for WASM isn't counted: keep logic out of it. Inferred (see [Rust projects](#rust-projects)).

**Add when:** Never: inferred for a crate with a `tests/` directory.

---

### `go-test`

Runs `go test -cover ./...`, writing Go's coverage profile to `cover.out` (gitignored). Inferred by gonx (see [Go projects](#go-projects)). Hashes `^dependency-files` too, since a Go module can `//go:embed` files (like `data/`) that gonx's `goSource` input does not cover, and `^rustSource`, for a crate's `.wasm` it embeds from `dist/` (see `demos/blake3-go`).

**Add when:** Never: inferred for every Go project.

---

### `rust-coverage-report`

Fails unless `rust-test` covered 100% of functions, lines and regions (`scripts/nx/rust-coverage-report.sh`), like `coverage-report`.

**Add when:** Rust projects with tests.

---

### `go-coverage-report`

Fails unless `go-test`'s `cover.out` shows 100% coverage (`scripts/nx/go-coverage-report.sh`), as `coverage-report` does for TypeScript. Runs in `test:report`.

**Add when:** Go projects with tests.

---

### `coverage-report`

Validates 100% coverage using only the C8 data from this project's own test targets ([`coverage-report.sh`](../../../leyman/nx-plugin/scripts/coverage-report.sh)). Runs in `test:report`, after the test suites. Coverage from dependents' tests does not count.

**Add when:** The package has any test target.

---

## Go projects

The [`@naxodev/gonx`](https://gonx.naxo.dev/) plugin (in `nx.json` `plugins`) turns every `go.mod` into a project. It also infers dependencies between them from Go `import`s, following `replace` directives, the way Nx reads `package.json` dependencies. No `implicitDependencies` needed, except for a project whose files a Go project reads by path (shared test vectors): then `go-test` reruns when they change, as it hashes `^dependency-files`.

Its inferred targets are renamed with a `go-` prefix, so they don't collide with lifecycle targets like `build` and `test`. Only `go-lint` and `go-test` are bound in `lifecycle.json`, configured through name-keyed `targetDefaults` (inputs, `dependsOn`, and options such as `golangci-lint run` instead of gonx's default `go fmt`). Keep those defaults without an `executor`: a default naming a different executor than the inferred target is ignored. The others (`go-build`, `go-tidy`, `go-generate`, `go-serve`, `go-release-publish`) are unbound, and only run when called directly.

`gofmt` stays a repo target, since gonx's formatter always rewrites and can't only check in CI. It keeps its name, though `golangci-lint fmt` runs it.

## Rust projects

No maintained plugin supports this repo's Nx yet, so `leyman/main/scripts/nx-rust-plugin.mjs` (in `nx.json` `plugins`) does what gonx does for Go. It adds `rust-clippy` to every `Cargo.toml` with a `[package]`, `rust-test` when it has `tests/`, and `rust-wasm` when it depends on `wasm-bindgen` or builds a `cdylib`, and infers dependencies between crates from their `path` dependencies, through `cargo metadata --no-deps`. The rest of a target (inputs, `dependsOn`, outputs) is in name-keyed `targetDefaults`, so keep those without an `executor`. Replace the plugin with an upstream one once one supports the repo's Nx.

With no `cargo` on `PATH`, as in a devcontainer not yet rebuilt, the plugin infers no dependencies instead of failing, so every other project still works. Only Rust's own targets need them, and those can't run there anyway.

In Dagger, crates come from `cargo fetch --locked` in a layer of their own, and `CARGO_NET_OFFLINE` keeps everything after it from reaching the network.

## Typical `project.json` Templates

### Standard TypeScript package (unit tests only)

```json
{
  "$schema": "../../leyman/main/node_modules/nx/schemas/project-schema.json",
  "name": "my-package",
  "targets": {
    "biome": {},
    "eslint": {},
    "check-package": {},
    "update-ts-references": {},
    "tsc": {},
    "tsc-test": {},
    "mocha-unit-test": {},
    "coverage-report": {},
    "sync-injected": {},
    "check:_": {},
    "check:lint": {},
    // lots more of ignorable nx-lifecycle managed targets
  }
}
```

### Rust project

```json
{
  "$schema": "../../../leyman/main/node_modules/nx/schemas/project-schema.json",
  "name": "@leyman/my-crate",
  "targets": {
    "biome": {},
    "rustfmt": {},
    "rust-coverage-report": {},
    // lots more of ignorable nx-lifecycle managed targets
  }
}
```

### Go project

```json
{
  "$schema": "../../../leyman/main/node_modules/nx/schemas/project-schema.json",
  "name": "@leyman/my-go-project",
  "targets": {
    "biome": {},
    "gofmt": {},
    "go-coverage-report": {},
    // lots more of ignorable nx-lifecycle managed targets
  }
}
```

Target order in `project.json` technically does not matter, but try to put them in the order described above, as they generally reflect the order they will run.

`nx-lifecycle` will ensure all orchestration targets go at the end.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.