-
Notifications
You must be signed in to change notification settings - Fork 11.8k
docs: add AGENTS.md guide for AI agents #34179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --- | ||
| trigger: always_on | ||
| --- | ||
|
|
||
| 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. | ||
|
|
||
| ## Environment | ||
|
|
||
| - Use `pnpm` for package management. | ||
| - Use `pnpm bazel test //target` to run tests. | ||
|
|
||
| ## Key Documentation | ||
|
|
||
| - [Developer Guide](docs/DEVELOPER.md): definitive guide for building, debugging, and running test targets. | ||
| - [Contributing Guide](CONTRIBUTING.md): general contribution workflows and guidelines. | ||
| - [Commit Guidelines](CONTRIBUTING.md#commit): format for commit messages and PR titles. | ||
|
|
||
| ## Building | ||
|
|
||
| - Make a local build of all packages: | ||
| ```shell | ||
| pnpm build --local | ||
| ``` | ||
|
|
||
| ## Testing | ||
|
|
||
| - **Temporary Directories (`TEST_TMPDIR`):** | ||
| - Tests in this repository only run in Bazel. **ALWAYS** use `process.env['TEST_TMPDIR']` and assert that it is set: | ||
| ```ts | ||
| import assert from 'node:assert'; | ||
| import { mkdtemp } from 'node:fs/promises'; | ||
| import { join } from 'node:path'; | ||
|
|
||
| describe('...', () => { | ||
| let tempRoot: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const baseTmpDir = process.env['TEST_TMPDIR']; | ||
| assert(baseTmpDir, 'TEST_TMPDIR is not set'); | ||
| tempRoot = await mkdtemp(join(baseTmpDir, 'angular-cli-test-')); | ||
| }); | ||
| }); | ||
| ``` | ||
| - **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. | ||
| - **Imports:** | ||
| - Always use the `node:` protocol for Node.js built-in imports (e.g., `node:fs`, `node:path`, `node:assert`). | ||
| - 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`). | ||
| - **Unit Tests:** | ||
| - Run all unit tests: `pnpm bazel test //packages/...` | ||
| - Run a specific test target: `pnpm bazel test //packages/angular/build:test` | ||
| - Query test targets: `pnpm bazel query "tests(//packages/...)"` | ||
| - Focus specific tests when debugging: use `fdescribe()` and `fit()`. NEVER commit focused tests to the repository. | ||
|
alan-agius4 marked this conversation as resolved.
|
||
| - **End-to-End Tests:** | ||
| - Run subset of E2E tests: `pnpm bazel test //tests:e2e_node22 --config=e2e --test_filter="<filter>"` | ||
|
|
||
| ## Pull Requests | ||
|
|
||
| - Use the `gh` CLI (GitHub CLI) for creating and managing pull requests. | ||
| - **Fixup Commits:** | ||
| - 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. | ||
| - Fixup commits are automatically squashed when merging with `pnpm ng-dev pr merge` or rebasing with `pnpm ng-dev pr rebase <pr>`. | ||
| - Use `pnpm ng-dev pr` commands: | ||
| - `pnpm ng-dev pr rebase <pr>`: Rebase a PR branch on its target branch and squash fixup commits. | ||
| - `pnpm ng-dev pr merge <pr>`: Merge an approved PR into its targeted branches. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.