-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
docs: improve AGENTS.md for agent/sandbox environments #21997
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
Open
mazze93
wants to merge
4
commits into
Homebrew:main
Choose a base branch
from
mazze93:stable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21
−5
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8c9ffa5
docs: add sandbox setup instructions for AGENTS.md
mazze93 cceec83
docs: improve AGENTS.md clarity and completeness
mazze93 5437298
Sorbet RBI regeneration (line 24) — ./bin/brew typecheck silently fai…
mazze93 788918d
Merge branch 'main' into stable
mazze93 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Agent Instructions for Homebrew/brew | ||
|
|
||
| Most importantly, run `./bin/brew lgtm` to verify any file edits before prompting for input to run all style checks and tests. | ||
| Most importantly, run `./bin/brew lgtm` to verify any file edits before prompting the user, to run all style checks and tests. | ||
|
|
||
| This is a Ruby based repository with Bash scripts for faster execution. | ||
| It is primarily responsible for providing the `brew` command for the Homebrew package manager. | ||
|
|
@@ -17,10 +17,21 @@ When running commands in this repository, use `./bin/brew` (not a system `brew` | |
| `./bin/brew typecheck` is fast enough to just be run globally every time. | ||
| - Run `./bin/brew style --fix --changed` to lint code formatting using RuboCop. | ||
| Individual files can be checked/fixed by passing them as arguments e.g. `./bin/brew style --fix Library/Homebrew/cmd/reinstall.rb` | ||
| - Run `./bin/brew tests --online --changed` to ensure that RSpec unit tests are passing (although some online tests may be flaky so can be ignored if they pass on a rerun). | ||
| - Run `./bin/brew tests --online --changed` to ensure that RSpec unit tests are passing (although some online tests may be flaky so can be ignored if they pass on a rerun). | ||
| Individual test files can be passed with `--only` e.g. to test `Library/Homebrew/cmd/reinstall.rb` with `Library/Homebrew/test/cmd/reinstall_spec.rb` run `./bin/brew tests --only=cmd/reinstall`. | ||
| - Shortcut: `./bin/brew lgtm --online` runs all of the required checks above in one command. | ||
| - All of the above can be run via the Homebrew MCP Server (launch with `./bin/brew mcp-server`). | ||
| - After adding or updating gems, regenerate Sorbet RBI stubs with `./bin/brew typecheck --update`. Use `--update-all` when gems are added or significantly changed; plain `--update` is sufficient for DSL-only changes. Commit the resulting changes to `Library/Homebrew/sorbet/` alongside the gem change. | ||
|
|
||
| ### Sandbox Setup | ||
|
|
||
| When working in a sandboxed environment (e.g. OpenAI Codex) where the default Homebrew cache directory is not writable: | ||
|
|
||
| 1. Copy the API cache: `cp -r "$(./bin/brew --cache)/api/" tmp/cache/api/` | ||
| 2. Export the writable path: `export HOMEBREW_CACHE="$(pwd)/tmp/cache/"` | ||
| 3. Then run `./bin/brew tests` as normal. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should already be handled by |
||
|
|
||
| This avoids permission errors when the test suite tries to write API cache entries or runtime logs. | ||
|
|
||
| ### Development Flow | ||
|
|
||
|
|
@@ -34,14 +45,18 @@ When running commands in this repository, use `./bin/brew` (not a system `brew` | |
| ## Repository Structure | ||
|
|
||
| - `bin/brew`: Homebrew's `brew` command main Bash entry point script | ||
| - `completions/`: Generated shell (`bash`/`fish`/`zsh`) completion files. Don't edit directly, regenerate with `./bin/brew generate-man-completions` | ||
| - `completions/`: Generated shell (`bash`/`fish`/`zsh`) completion files. Don't edit directly; regenerate with `./bin/brew generate-man-completions` when adding, removing, or renaming commands or their flags. | ||
| - `Library/Homebrew/`: Homebrew's core Ruby (with a little bash) logic. | ||
| - `Library/Homebrew/bundle/`: Homebrew's `brew bundle` command. | ||
| - `Library/Homebrew/cask/`: Homebrew's Cask classes and DSL. | ||
| - `Library/Homebrew/extend/os/`: Homebrew's OS-specific (i.e. macOS or Linux) class extension logic. | ||
| - `Library/Homebrew/formula.rb`: Homebrew's Formula class and DSL. | ||
| - `Library/Homebrew/cmd/`: User-facing `brew` commands (e.g. `install`, `upgrade`). | ||
| - `Library/Homebrew/dev-cmd/`: Developer/maintainer commands (e.g. `audit`, `bottle`). | ||
| - `Library/Homebrew/test/`: RSpec test files mirroring the structure of `Library/Homebrew/`. | ||
| - `Library/Homebrew/sorbet/`: Sorbet RBI type definitions and Tapioca-generated stubs. | ||
| - `docs/`: Documentation for Homebrew users, contributors and maintainers. Consult these for best practices and help. | ||
| - `manpages/`: Generated `man` documentation files. Don't edit directly, regenerate with `./bin/brew generate-man-completions` | ||
| - `manpages/`: Generated `man` documentation files. Don't edit directly; regenerate with `./bin/brew generate-man-completions` at the same time as `completions/`. | ||
| - `package/`: Files to generate the macOS `.pkg` file. | ||
|
|
||
| ## Key Guidelines | ||
|
|
@@ -53,5 +68,6 @@ When running commands in this repository, use `./bin/brew` (not a system `brew` | |
| 5. Suggest changes to the `docs/` folder when appropriate | ||
| 6. Follow software principles such as DRY and YAGNI. | ||
| 7. Keep diffs as minimal as possible. | ||
| 8. Prefer shelling out via `HOMEBREW_BREW_FILE` instead of requiring `cmd/` or `dev-cmd` when composing brew commands. | ||
| 8. When composing `brew` sub-commands from within Ruby code, shell out via `HOMEBREW_BREW_FILE` (e.g. `safe_system HOMEBREW_BREW_FILE, "install", name`) rather than requiring files from `cmd/` or `dev-cmd/` directly. Use `./bin/brew` only from the terminal or shell scripts. | ||
| 9. Inline new or existing methods as methods or local variables unless they are reused 2+ times or needed for unit tests. | ||
| 10. Use `scope: description` commit message format, matching the scope to the area changed — e.g. `livecheck:`, `sorbet:`, `tests:`, `docs:`, `style:`, `bundle:`, or a command name like `install:`. Use sentence case for the description and keep it under 72 characters. Dependency-bump commits from automated tooling use `build(deps):` or `build(deps-dev):` and do not need to follow this convention manually. | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change random words like this.