Skip to content

Commit 9b7a14a

Browse files
authored
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 36bdd84 commit 9b7a14a

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

‎AGENTS.md‎

Lines changed: 16 additions & 5 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,15 @@ 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 when isolating or debugging: use `--config=no-sharding` with a specific test target (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.
62+
Do not use this flag when running broad test suites (such as `//packages/...`), as executing tests without sharding takes significantly longer.
5363
- **End-to-End Tests:**
5464
- Run subset of E2E tests: `pnpm bazel test //tests:e2e_node22 --config=e2e --test_filter="<filter>"`
5565

@@ -58,7 +68,8 @@ This is the source code for the Angular CLI and related build tooling. This guid
5868
- Use the `gh` CLI (GitHub CLI) for creating and managing pull requests.
5969
- **Fixup Commits:**
6070
- 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.
61-
- Fixup commits are automatically squashed when merging with `pnpm ng-dev pr merge` or rebasing with `pnpm ng-dev pr rebase <pr>`.
71+
- 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.
72+
- Fixup commits are automatically squashed when merging with `pnpm ng-dev pr merge` or optionally when rebasing with `pnpm ng-dev pr rebase <pr>`.
6273
- Use `pnpm ng-dev pr` commands:
63-
- `pnpm ng-dev pr rebase <pr>`: Rebase a PR branch on its target branch and squash fixup commits.
74+
- `pnpm ng-dev pr rebase <pr>`: Rebase a PR branch on its target branch and optionally squash fixup commits.
6475
- `pnpm ng-dev pr merge <pr>`: Merge an approved PR into its targeted branches.

0 commit comments

Comments
 (0)