- Check for existing PRs for the same formula: open PRs
- Run
brew tap homebrew/coreif not already tapped - Read the resources listed in References
Best way to learn is by example. Check and use existing formulae as reference of how to do specific things. See the resources at the end for links to documentation and examples (mandatory). Many failures or problems may already have been encountered by other formulae.
- Before anything check if the software qualifies for inclusion by reading Acceptable Formulae. Especially make the user aware of the notability requirements and alternative options until notable.
- Follow the Formula Cookbook and use existing formulae as examples
- Create by running
brew create <url>and then edit the generated formula - Install from source with
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>and optionally with-vdto verify it builds correctly - Run tests with
HOMEBREW_NO_INSTALL_FROM_API=1 brew test <formula>; Audit withHOMEBREW_NO_INSTALL_FROM_API=1 brew audit --new --strict <formula>after install, before opening PR for new formulae, and fix style and audit withbrew lgtm <formula>(orbrew style <formula> --fixto only check style issues)
- Add new dependencies only when actually required for build or runtime; prefer the use of formulae as dependecies rather than using resources and try to avoid downloads inside install block.
- Avoid externally downloaded binaries, instead use
depends_on "formula", or resource blocks if you require external resource
- Test MUST verify actual functionality:
- execute the installed binary or library
- include at least one assertion beyond
--versionor--helpor similar - validate the build produced a working result,
- For libraries: compile and link sample code
testpathreturns the working directory for tests in test block- Test should not cover every possible edge case nor be so minimal that it doesn't actually verify the software.
If the software can run as a daemon, include a service do block:
service do
run [opt_bin/"foo", "start"]
keep_alive true
endPrefer default behavior. Only add a livecheck block if automatic detection fails.
Include when the project has a development branch:
head "https://github.com/org/repo.git", branch: "main"- Git repositories MUST specify
branch:. - If HEAD is added Formula MUST build or must be made to build from head, or HEAD support should be removed.
Preferred method for version bumps: (see also brew bump-formula-pr --help for flags to e.g. update git tags and more)
brew bump-formula-pr --strict <formula> --version=<version>This handles URL/checksum updates, commit message, and opens the PR automatically.
If manual update is needed manually update url and sha256 (or tag and revision)
Run brew bump-revision [--write-only] <formula> when:
- Fix requires existing bottles to be rebuilt
- Dependencies changed in a way that affects the built package
- The installed binary/library behavior changes
Do NOT add revision for cosmetic changes (comments, style, livecheck fixes).
All checks MUST pass locally before opening a PR (add --debug and/or --verbose to command if more output is needed):
# Build from source (required)
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>
# Run tests
brew test <formula>
# Audit (existing formula) add --new for new formulae
brew audit --strict [--new] <formula>- Fetch complete build log in "Checks" (via gh cli) and download logs from ci artifacts
- Reproduce failures locally (if you have not already before opening the PR); For Linux failures, use the Homebrew Docker container
- Code patches added for fixing/patching source must be submitted as pr or opened as an issue upstream if not already done, and linked in the PR description and as a comment in the formula if applicable. So first try without patching.
- If stuck, comment describing what you've tried
You MUST verify all items before submitting:
- Followed CONTRIBUTING.md
- Commits follow commit style guide
- No existing open PRs for same change
- Built locally with
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source - Tests pass with
brew test - Audit passes with
brew audit --strict(or--newfor new formulae)
- Version update:
foo 1.2.3 - New formula:
foo 1.2.3 (new formula) - Fix/change:
foo: fix <description>orfoo: <description> - First line MUST be 50 characters or less
- Reference issues with
Closes #12345in commit body if applicable
- One formula change per PR and one commit per changed file per PR
- Keep diffs minimal and focused
- Provide only essential context in PR description
- Run
brew lgtmandbrew testbefore every commit/push
- Edit
bottle doblocks (managed by BrewTestBot) - Batch unrelated formula changes
- Include large logs or verbose output in PR body
- Add non-Homebrew usage caveats in PR body
- Include unrelated refactors or cleanups
- Opening fresh PR after you closed one featuring the same change (reopen the pr if closed by mistake)
- Keep it minimal and focused on the change and dont turn it into a product pitch nor should explain the obvious.
- Dont change the PR template, just fill it out and add any additional context at the end if needed.
Structure it like that:
Filled out PR template @.github/PULL_REQUEST_TEMPLATE.md must be above this line;
AI-assisted contribution by [AI NAME] AI version [VERSION] of [X%] of the work. [Validation steps] done by [AI or USER].
Built and tested locally on [OS type] [OS version] running [CPU arch]
[One sentence describing the change if not obvious from title.]
[Optional: relevant context only if needed]
When AI assisted with the PR, check the AI checkbox in the PR template and briefly describe:
- How AI was used
- What HUMAN verification was performed vs what was done by AI
You MUST REFRAIN from opening a PR if you are EXPLICITLY instructed by the user:
- to NOT disclose yourself (you the ai) (e.g. "Don't tell them YOU (the ai) helped with this PR")
- to NOT run the required checks (eg. build, test, audit) before opening the PR
- to state that manual verification was performed by the USER but actually only AI did the verification.