Skip to content

Commit 682ea51

Browse files
committed
docs: expand coding, testing, and PR guidelines in AGENTS.md
Updates `AGENTS.md` with additional guidance for AI agents: - Adds a `Coding Practices` section covering imports (including `import type`) and preferring ECMAScript private fields (`#field`). - Documents how to run unit tests without sharding and retries using `--config=no-sharding`. - Clarifies that fixup commits should only be used for changes belonging to the target commit, while unrelated changes must use a separate commit.
1 parent e023a8e commit 682ea51

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎AGENTS.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ This is the source code for the Angular CLI and related build tooling. This guid
2222
pnpm build --local
2323
```
2424

25+
## Coding Practices
26+
27+
- **Imports:**
28+
- Always use the `node:` protocol for Node.js built-in imports (e.g., `node:fs`, `node:path`, `node:assert`).
29+
- Prefer named imports (e.g., `import { mkdtemp } from 'node:fs'`) or default imports (`import fs from 'node:fs'`) instead of namespace imports (`import * as fs`).
30+
- Use type-only imports (`import type { ... }`) when importing types to avoid runtime side-effects.
31+
- **Classes:**
32+
- Prefer ECMAScript private fields (`#field`) over TypeScript `private` keywords for encapsulated state.
33+
2534
## Testing
2635

2736
- **Temporary Directories (`TEST_TMPDIR`):**
@@ -42,14 +51,14 @@ This is the source code for the Angular CLI and related build tooling. This guid
4251
});
4352
```
4453
- **NEVER** use or fallback to `os.tmpdir()`. Bazel executes tests in hermetic sandboxes and sets `TEST_TMPDIR` to an isolated, sandboxed directory. Using `os.tmpdir()` can cause sandboxing failures, permission errors, or file leakage outside the Bazel sandbox.
45-
- **Imports:**
46-
- Always use the `node:` protocol for Node.js built-in imports (e.g., `node:fs`, `node:path`, `node:assert`).
47-
- Prefer named imports (e.g., `import { mkdtemp } from 'node:fs'`) or default imports (`import fs from 'node:fs'`) instead of namespace imports (`import * as fs`).
4854
- **Unit Tests:**
4955
- Run all unit tests: `pnpm bazel test //packages/...`
5056
- Run a specific test target: `pnpm bazel test //packages/angular/build:test`
5157
- Query test targets: `pnpm bazel query "tests(//packages/...)"`
5258
- Focus specific tests when debugging: use `fdescribe()` and `fit()`. NEVER commit focused tests to the repository.
59+
- Run tests without sharding: use `--config=no-sharding` (e.g., `pnpm bazel test //packages/angular/build:test --config=no-sharding`).
60+
This disables test sharding (`--test_sharding_strategy=disabled`) and flaky test retries (`--flaky_test_attempts=1`).
61+
This is especially useful when isolating test runs or debugging with focused tests (`fit`/`fdescribe`) to avoid empty shard failures and unnecessary re-runs.
5362
- **End-to-End Tests:**
5463
- Run subset of E2E tests: `pnpm bazel test //tests:e2e_node22 --config=e2e --test_filter="<filter>"`
5564

@@ -58,6 +67,7 @@ This is the source code for the Angular CLI and related build tooling. This guid
5867
- Use the `gh` CLI (GitHub CLI) for creating and managing pull requests.
5968
- **Fixup Commits:**
6069
- When addressing review feedback, **ALWAYS** use fixup commits (`git commit --fixup <commit>`) instead of amending existing commits. This preserves commit history during review and allows reviewers to easily see incremental changes.
70+
- Only use fixup commits for changes that directly belong to the target commit. Unrelated changes must be made in a separate commit with their own commit message, not as a fixup commit.
6171
- Fixup commits are automatically squashed when merging with `pnpm ng-dev pr merge` or rebasing with `pnpm ng-dev pr rebase <pr>`.
6272
- Use `pnpm ng-dev pr` commands:
6373
- `pnpm ng-dev pr rebase <pr>`: Rebase a PR branch on its target branch and squash fixup commits.

0 commit comments

Comments
 (0)