Skip to content

Commit 6a0c0a3

Browse files
committed
docs: add AGENTS.md guide for AI agents
Adds AGENTS.md to provide instructions and standard practices for AI agents working in this repository, including testing and environment constraints. (cherry picked from commit e023a8e)
1 parent aa3f204 commit 6a0c0a3

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
This is the source code for the Angular CLI and related build tooling. This guide outlines standard practices for AI agents working in this repository.
6+
7+
## Environment
8+
9+
- Use `pnpm` for package management.
10+
- Use `pnpm bazel test //target` to run tests.
11+
12+
## Key Documentation
13+
14+
- [Developer Guide](docs/DEVELOPER.md): definitive guide for building, debugging, and running test targets.
15+
- [Contributing Guide](CONTRIBUTING.md): general contribution workflows and guidelines.
16+
- [Commit Guidelines](CONTRIBUTING.md#commit): format for commit messages and PR titles.
17+
18+
## Building
19+
20+
- Make a local build of all packages:
21+
```shell
22+
pnpm build --local
23+
```
24+
25+
## Testing
26+
27+
- **Temporary Directories (`TEST_TMPDIR`):**
28+
- Tests in this repository only run in Bazel. **ALWAYS** use `process.env['TEST_TMPDIR']` and assert that it is set:
29+
```ts
30+
import assert from 'node:assert';
31+
import { mkdtemp } from 'node:fs/promises';
32+
import { join } from 'node:path';
33+
34+
describe('...', () => {
35+
let tempRoot: string;
36+
37+
beforeAll(async () => {
38+
const baseTmpDir = process.env['TEST_TMPDIR'];
39+
assert(baseTmpDir, 'TEST_TMPDIR is not set');
40+
tempRoot = await mkdtemp(join(baseTmpDir, 'angular-cli-test-'));
41+
});
42+
});
43+
```
44+
- **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`).
48+
- **Unit Tests:**
49+
- Run all unit tests: `pnpm bazel test //packages/...`
50+
- Run a specific test target: `pnpm bazel test //packages/angular/build:test`
51+
- Query test targets: `pnpm bazel query "tests(//packages/...)"`
52+
- Focus specific tests when debugging: use `fdescribe()` and `fit()`. NEVER commit focused tests to the repository.
53+
- **End-to-End Tests:**
54+
- Run subset of E2E tests: `pnpm bazel test //tests:e2e_node22 --config=e2e --test_filter="<filter>"`
55+
56+
## Pull Requests
57+
58+
- Use the `gh` CLI (GitHub CLI) for creating and managing pull requests.
59+
- **Fixup Commits:**
60+
- 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>`.
62+
- 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.
64+
- `pnpm ng-dev pr merge <pr>`: Merge an approved PR into its targeted branches.

0 commit comments

Comments
 (0)