From 3159abfa5e47df4ce11162d01dcf7e281df7b257 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 7 Oct 2026 15:10:30 -0400 Subject: [PATCH 1/2] Framework: Update agents guidance around running package scripts --- AGENTS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 23e622afe20324..e8328e5e36bae1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -90,7 +90,8 @@ For full architecture details, see `docs/explanations/architecture/`. - `block-editor` is a WordPress-agnostic package. NEVER add `core-data` dependencies or direct REST API calls to it. - `@wordpress/build` (`packages/wp-build`) is a generic build tool used both in Gutenberg and by plugins targeting WordPress Core directly. Avoid Gutenberg-specific changes in it. - Pages and routes are stable by default. Mark experimental pages with `"experimental": true` in `wpPlugin.pages`; WordPress Core builds exclude those pages and routes used only by experimental pages. Do not introduce separate `stable` or `core` flags for this distinction. -- Never invoke a CLI through `npx`. When the binary is missing locally, `npx` installs whatever the public registry serves under that name: WordPress ships its own `wp-prettier` fork, and a bare `npx wp-scripts` can resolve to an unrelated third-party package rather than `@wordpress/scripts`. Use the npm scripts (`npm run format`, `npm run lint:js`, `npm run lint:css` and so on), which run the binaries from local `node_modules`. Where no script fits, use `npm exec --no -- ` (adding `--workspace ` when the workspace that declares the dependency is not the one you are in), which fails instead of downloading. A bare `npm exec` behaves exactly like `npx`, so it needs `--no` too. The exception is a doc example handing the reader a tool they have not installed, such as `npx @wordpress/create-block@latest`: it names an exact package rather than a hijackable bin name. +- Prefer the `package.json` scripts, which accept file paths, such as `npm run test:unit -- `, `npm run lint:js ` (which also checks Prettier formatting), and `npm run typecheck -- `; see the [Testing Overview](docs/contributors/code/testing-overview.md) for more test commands. If no script fits, ask before running a binary directly, since a missing script can be a gap to fix and not to work around. +- Never use `npx` or a bare `npm exec`, which download whatever the registry serves under a missing binary's name; use `npm exec --no -- `, which fails instead. Doc examples that name an exact package, such as `npx @wordpress/create-block@latest`, are fine. - PHP function and class names are renamed at build time (`gutenberg_*` prefix, `*_Gutenberg` suffix) to avoid conflicts with WordPress Core — the built names, not the source names, are what runs (and what tests must call). See `docs/contributors/code/build-system-function-prefixing.md`. - Code changes in a package that have an external impact to consumers should be accompanied by an entry in that package's `CHANGELOG.md`. Follow the formatting structure described in [Maintaining Changelogs](packages/README.md#maintaining-changelogs). - Packages with TypeScript dev files split their configs: `tsconfig.build.json` (src only, emits `build-types`) and the default `tsconfig.json` (dev project: tests and stories, `noEmit`, jest types). Packages without dev files keep a single `tsconfig.json` build project, and a few packages deviate (a dev-only project with handwritten declarations, or specialized build projects); see the TypeScript section in `packages/README.md`. Reference a split package by `..//tsconfig.build.json` and an unsplit one by `../`. `npm run build` never type checks (it emits declarations with `--noCheck`); use `npm run typecheck`, and never add jest types to a build project. From aaf03b583a31daf2ca27a91c3c43d76b8c99bd30 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 15 Oct 2026 14:22:38 -0400 Subject: [PATCH 2/2] Clarify language around npm binaries commands and exceptions --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index e8328e5e36bae1..16350c33dc5bcd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -91,7 +91,7 @@ For full architecture details, see `docs/explanations/architecture/`. - `@wordpress/build` (`packages/wp-build`) is a generic build tool used both in Gutenberg and by plugins targeting WordPress Core directly. Avoid Gutenberg-specific changes in it. - Pages and routes are stable by default. Mark experimental pages with `"experimental": true` in `wpPlugin.pages`; WordPress Core builds exclude those pages and routes used only by experimental pages. Do not introduce separate `stable` or `core` flags for this distinction. - Prefer the `package.json` scripts, which accept file paths, such as `npm run test:unit -- `, `npm run lint:js ` (which also checks Prettier formatting), and `npm run typecheck -- `; see the [Testing Overview](docs/contributors/code/testing-overview.md) for more test commands. If no script fits, ask before running a binary directly, since a missing script can be a gap to fix and not to work around. -- Never use `npx` or a bare `npm exec`, which download whatever the registry serves under a missing binary's name; use `npm exec --no -- `, which fails instead. Doc examples that name an exact package, such as `npx @wordpress/create-block@latest`, are fine. +- Run a binary from an installed npm package with `npm exec --no -- `, which fails if it is not installed locally. Since `npx` and a bare `npm exec` download whatever the npm registry serves as a package under that name, use them only with a full package name, such as `npx @wordpress/create-block@latest`. - PHP function and class names are renamed at build time (`gutenberg_*` prefix, `*_Gutenberg` suffix) to avoid conflicts with WordPress Core — the built names, not the source names, are what runs (and what tests must call). See `docs/contributors/code/build-system-function-prefixing.md`. - Code changes in a package that have an external impact to consumers should be accompanied by an entry in that package's `CHANGELOG.md`. Follow the formatting structure described in [Maintaining Changelogs](packages/README.md#maintaining-changelogs). - Packages with TypeScript dev files split their configs: `tsconfig.build.json` (src only, emits `build-types`) and the default `tsconfig.json` (dev project: tests and stories, `noEmit`, jest types). Packages without dev files keep a single `tsconfig.json` build project, and a few packages deviate (a dev-only project with handwritten declarations, or specialized build projects); see the TypeScript section in `packages/README.md`. Reference a split package by `..//tsconfig.build.json` and an unsplit one by `../`. `npm run build` never type checks (it emits declarations with `--noCheck`); use `npm run typecheck`, and never add jest types to a build project.