-
Notifications
You must be signed in to change notification settings - Fork 660
docs: add AGENTS.md with guidance for AI coding agents #3480
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
+101
−0
Merged
Changes from 1 commit
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,97 @@ | ||
| # Agent Instructions | ||
|
|
||
| Guidance for AI coding agents (GitHub Copilot, Claude, Cursor, etc.) working in | ||
|
cijothomas marked this conversation as resolved.
Outdated
|
||
| this repository. Human contributors should follow [CONTRIBUTING.md](CONTRIBUTING.md); | ||
| this file captures the conventions an automated agent must respect to keep CI | ||
| green and reviews short. | ||
|
|
||
| ## Repository Layout | ||
|
|
||
| This is a Cargo workspace. Each top-level `opentelemetry-*` directory is a | ||
| separately published crate. `opentelemetry-prometheus` is intentionally | ||
| **outside** the workspace and must be linted/tested via its own manifest. | ||
| See [docs/design/architecture.md](docs/design/architecture.md) for the | ||
| API/SDK split and crate responsibilities. | ||
|
|
||
| ## Required Pre-Push Checks | ||
|
|
||
| Always run these before pushing. They're cheap and catch the lint failures CI | ||
| will otherwise flag. | ||
|
|
||
| ```sh | ||
| # 1. Format every file in the workspace (always). | ||
| cargo fmt --all | ||
|
|
||
| # 2. Clippy on the crates you actually touched, with -Dwarnings. | ||
| # Replace <crate> with the directory name (e.g. opentelemetry-sdk). | ||
| cargo clippy -p <crate> --all-targets --all-features -- -Dwarnings | ||
|
|
||
| # 3. Tests for the crates you touched. | ||
| cargo test -p <crate> --all-features --lib | ||
| ``` | ||
|
|
||
| For changes inside `opentelemetry-prometheus` (non-workspace), run from that | ||
| directory: | ||
|
|
||
| ```sh | ||
| (cd opentelemetry-prometheus && cargo clippy --all-targets --all-features -- -Dwarnings) | ||
| (cd opentelemetry-prometheus && cargo test --all-features --lib) | ||
| ``` | ||
|
|
||
| ### When to Run the Full Precommit | ||
|
|
||
| The full [scripts/precommit.sh](scripts/precommit.sh) runs `cargo update`, | ||
| workspace-wide clippy, the full `cargo hack --each-feature` matrix, and the | ||
| entire test suite. It takes a long time. Reserve it for: | ||
|
|
||
| - Changes touching multiple crates or shared types (e.g. anything in | ||
| `opentelemetry/src/`). | ||
| - Public API changes, trait signature changes, or feature-flag changes. | ||
| - Dependency bumps in `Cargo.toml`. | ||
| - Changes to build scripts, proto definitions, or codegen. | ||
| - Anything you suspect could regress feature-gated builds. | ||
|
|
||
| For small, single-crate changes (a bug fix, a doc tweak, a benchmark, a test), | ||
| the targeted commands above are sufficient — CI will catch anything missed. | ||
|
|
||
| ## Formatting and Lint Rules | ||
|
|
||
| - `rustfmt` is enforced (`cargo fmt --all -- --check` runs in CI). Always | ||
| format before committing; do not hand-format. | ||
| - Clippy runs with `-Dwarnings` everywhere. A new warning fails CI. | ||
| - Do not introduce `#[allow(...)]` to silence clippy without a comment | ||
| explaining why. | ||
|
|
||
| ## Commit and PR Conventions | ||
|
|
||
| - PR titles follow [Conventional Commits](https://www.conventionalcommits.org/) | ||
| (e.g. `fix(sdk): ...`, `feat(otlp): ...`, `docs: ...`). The | ||
| `validate-pr-title` check enforces this. | ||
| - Keep PRs focused and under ~500 lines where practical (see | ||
| [CONTRIBUTING.md](CONTRIBUTING.md#pull-request-size-and-scope)). | ||
| - Refactors must be in their own PR with no behavior changes. | ||
| - Update the relevant crate's `CHANGELOG.md` under the `## vNext` / | ||
| `## Unreleased` section for any user-visible change. | ||
| - Do not commit generated files, editor settings, or unrelated whitespace | ||
| changes. | ||
|
|
||
| ## Things Not to Do | ||
|
|
||
| - Do not push directly to `open-telemetry/opentelemetry-rust`. Push to a | ||
| fork and open a PR. | ||
| - Do not bypass git hooks or CI checks (`--no-verify`, `[skip ci]`, etc.). | ||
| - Do not hand-edit `Cargo.lock`; let `cargo` manage it. | ||
| - Do not add new public API without updating the corresponding | ||
| `allowed-external-types.toml` if one exists for that crate. | ||
| - Do not create a markdown file to "document the changes you made" unless | ||
| the user asked for it. | ||
|
|
||
| ## Useful References | ||
|
cijothomas marked this conversation as resolved.
|
||
|
|
||
| - [CONTRIBUTING.md](CONTRIBUTING.md) — full contributor guide | ||
| - [docs/design/architecture.md](docs/design/architecture.md) — workspace and | ||
| crate layout | ||
| - [docs/adr/](docs/adr/) — past design decisions | ||
| - [scripts/precommit.sh](scripts/precommit.sh) — full local CI mirror | ||
| - [scripts/lint.sh](scripts/lint.sh) — exact clippy invocations CI runs | ||
| - [scripts/test.sh](scripts/test.sh) — exact test invocations CI runs | ||
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.