Skip to content

Advanced repository setup

Use this guide to add caller workflows by hand or run Code Hawk with your own GitHub App. For a new hosted installation, follow the three-step guide.

Installing the App or adding repositories queues a Set up Code Hawk pull request on branch codehawk/setup. It adds .github/workflows/codehawk.yml with scan, review, reply, settings command and fix request jobs pinned to the highest configured release, plus .github/codehawk.json with starter provider, model and spend caps. Existing settings, open setup pull requests and setup branches with commits of their own are left alone. A setup branch left behind by a merged pull request is replaced. The fix request job stays off until the repository sets the CODEHAWK_TEST_IMAGE Actions variable to an image pinned by @sha256: and adds fix_issues.test_commands, see fix requests. Large installs take about an hour per 60 repositories, plus discovery time, retries and work for other installations. The hourly sweep recovers repositories missed by webhooks.

The App commits on top of whatever the open codehawk/setup branch already holds. Since the App opens the pull request, the person who requested the change can approve it. Repositories that need a second reviewer should use CODEOWNERS or branch protection.

Follow the installation guide to choose a model, merge the pull request and add the key. The generated workflow forwards the standard provider secrets.

The starter caps are 1 USD per review and 0.10 USD per reply. Set a cap to null to remove it. While the first settings file is pending, its PR review passes with a notice and makes no model call. If GitHub refuses a workflow write, the pull request adds only settings and includes the complete workflow to copy to .github/workflows/codehawk.yml yourself.

To request a fresh setup pull request, close the old one, delete codehawk/setup, and remove and re-add the repository after the 24 hour cooldown. Remove the existing settings file too if you intend to start over. The hourly sweep does not repeat repositories with recorded outcomes. Archived, disabled, forked, empty or inaccessible repositories are skipped. Setup waits while the Worker is paused or has no configured release. See troubleshooting.

Copy the desired YAML into .github/workflows/. Called workflows do not read the caller's variables by themselves. Pass inputs explicitly and forward only the named secrets the job needs, never all caller secrets.

Replace <sha> in each uses: line with the full commit of your chosen Code Hawk release, and use the same commit in every caller. Use a commit that is available in the GitHub source repository.

With your own App, add app_id and forward CODEHAWK_PRIVATE_KEY for each job that mints a token. With the hosted App, install CodeHawk App on the caller repository and grant the calling job id-token: write. Model jobs also need settings and a matching key.

CODEHAWK_INFERENCE is deprecated for one release and overrides the settings file's model routes while set. Existing CODEHAWK_CREDENTIAL_1 through _8 secrets still work. To migrate, move the provider and model into the default-branch file, forward the standard provider secret, then remove the old input and unused credential slots. See the advanced inference reference.

with:
inference: ${{ vars.CODEHAWK_INFERENCE }}
secrets:
CODEHAWK_CREDENTIAL_1: ${{ secrets.CODEHAWK_CREDENTIAL_1 }}

Save as .github/workflows/pr-scan.yml. Set branches to your target branch if it is not main. The scan takes no inference document or credential slots.

name: PR scan
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions: {}
jobs:
scan:
if: ${{ !github.event.pull_request.draft }}
permissions:
contents: read
id-token: write
uses: bts-io/codehawk/.github/workflows/pr-scan.yml@<sha> # codehawk <version>

Save as .github/workflows/pr-review.yml and set the PR_REVIEW_ENABLED repository variable to true. Add the reply caller separately if you need it.

name: PR review
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
concurrency:
group: pr-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
if: >-
vars.PR_REVIEW_ENABLED == 'true' && !github.event.pull_request.draft &&
github.event.pull_request.user.type != 'Bot' &&
!endsWith(github.event.pull_request.user.login, '[bot]')
permissions:
contents: read
pull-requests: read
id-token: write
uses: bts-io/codehawk/.github/workflows/pr-review.yml@<sha> # codehawk <version>
secrets:
CODEHAWK_OPENAI_API_KEY: ${{ secrets.CODEHAWK_OPENAI_API_KEY }}

The calling job grants contents: read, pull-requests: read and id-token: write because a called workflow can only lower its caller permissions. Forward each provider secret your primary and fallback routes use. The legacy inference input and eight explicit slots remain optional for one release.

Save JSON at .github/codehawk.json on the default branch. Provider, model and caps are read only from that branch, even when reviewing another branch. A PR editing the file receives a note that new settings apply after merge. Branch writers can still change caller inputs and pins on pull_request events. Protect workflow files with CODEOWNERS and rulesets. See the trust model. Other sections keep their existing source. Empty caller overrides preserve the file settings. No cap applies unless you set one.

{
"provider": "openai",
"model": "your-model-id",
"caps": { "pr_review": 1 },
"pr_review": { "base_branches": ["main"], "skip_paths": ["src/generated/**"] }
}

See the complete configuration reference, workflow inputs, and the separate callers for weekly review, issue fixes, and browser flows.

For this compatibility release, reusable workflows accept optional CODE_REVIEW_HAWK_* secrets as fallbacks when the corresponding CODEHAWK_* secret is empty. Rename those caller secrets to CODEHAWK_*. The old settings and flows filenames and the codereview-hawk-fix label still work for this release and emit a deprecation warning when used. Rename them to .github/codehawk.json, .github/codehawk-flows.json and codehawk-fix. Existing open and closed findings with the codereview-hawk label remain part of weekly review deduplication.

For your own App, add app_id under with and forward CODEHAWK_PRIVATE_KEY under secrets. See the self-hosted App lines. The hosted App needs neither. The new standard provider secrets have no CODE_REVIEW_HAWK_* aliases. The existing aliases described above apply only to older App and credential-slot names.

See Change settings from the setup page.

Settings commands let repository writers open a settings pull request from a comment. The caller grants only id-token: write.

name: Code Hawk settings
on:
issue_comment: # zizmor: ignore[dangerous-triggers] comment jobs check write access and never check out pull request code
types: [created]
permissions: {}
jobs:
settings:
permissions:
id-token: write
uses: bts-io/codehawk/.github/workflows/settings-command.yml@<sha> # codehawk <version>