Repository setup for agents
Repository setup for agents
Section titled “Repository setup for agents”Use this guide when you need to configure a repository for Shipper without running
shipper setup.
Task 1: Configure dependency bootstrap
Section titled “Task 1: Configure dependency bootstrap”Inspect the full repository layout and configure the dependency bootstrap Shipper should run in new worktrees.
-
Build a bootstrap inventory.
Read
.shipper/settings.json, then inspect root and nested manifests/lockfiles such aspackage.json,package-lock.json,pnpm-lock.yaml,yarn.lock,bun.lockb,Cargo.toml,Cargo.lock,go.mod,go.work,go.sum,pyproject.toml,requirements.txt,Pipfile.lock, andpoetry.lock. Also inspect workspace declarations such as npm workspaces,pnpm-workspace.yaml, Yarn workspaces, Cargo workspaces, Go workspaces/modules, Python project files,.github/workflows/, package scripts, repo setup scripts, build scripts, and existing hooks. Produce a concrete list of package/project areas required by known build, type-check, and test commands before choosing commands. -
Choose the bootstrap using only existing Shipper configuration.
Use
installCommandfor the primary/root install when a single command covers the relevant areas. Generate an executable.shipper/hooks/worktree-setupfor additional idempotent package or project steps when a single root install is not enough. Do not add a new bootstrap settings schema.Single root workspace install:
{"installCommand": "npm install"}Multi-package bootstrap:
{"installCommand": "npm install"}#!/usr/bin/env bashset -euo pipefail(cd packages/mobile && npm install)(cd tools/codegen && npm install && npm run build)Save the script as
.shipper/hooks/worktree-setupand run:Terminal window chmod +x .shipper/hooks/worktree-setupHook-only bootstrap is also valid:
{"installCommand": ""}Deliberate no-bootstrap is recorded the same way after confirming with the user that the repository genuinely needs no install step:
{"installCommand": ""} -
Handle native-build and special prerequisites conservatively.
Look for Node native packages, Electron rebuild/package steps, Cargo build scripts, Python extension builds, Go CGO signals, and explicit workflow prerequisite commands. Configure only repository/package-level install, rebuild, or build commands that Shipper can safely run. Do not add
apt,brew, Xcode Command Line Tools, SDK, compiler, or system-library provisioning toinstallCommandor.shipper/hooks/worktree-setup; list those prerequisites for the user to install manually. -
Verify the configured bootstrap through Shipper’s runtime primitive.
Create a temporary cold verification checkout from the repository source under
.shipper/tmp/bootstrap-verify-<unique-suffix>. This path is gitignored and absent from a clean worktree; create it only as a disposable verification checkout. Prefergit worktree add --detach <tmp> HEADso the checkout includes the repository manifests, lockfiles, and source. Ifgit worktreeis unavailable, copy the tracked working tree instead. Overlay the just-written.shipper/settings.jsonto<tmp>/.shipper/settings.json. If you generated.shipper/hooks/worktree-setup, copy it to<tmp>/.shipper/hooks/worktree-setupand keep it executable. Then run:Terminal window shipper bootstrap --cwd <tmp>After bootstrap succeeds, run the single type-check/build follow-up from inside
<tmp>. Remove the temporary checkout/worktree when verification finishes. -
Run exactly one lightweight follow-up verification when possible.
After bootstrap succeeds, run exactly one known type-check command when available; otherwise run exactly one known build command. Do not run tests, lint, format, or aggregate commands that include tests. If no type-check/build command can be justified from CI or package scripts, state explicitly that bootstrap verification could not be performed.
-
Report what was configured and why.
Include the package/project areas covered by
installCommand, the areas covered by.shipper/hooks/worktree-setup, any manual system prerequisites, theshipper bootstrap --cwdresult, and the single type-check/build result or the reason that verification could not run.
Task 2: Generate or update the agent configuration file
Section titled “Task 2: Generate or update the agent configuration file”Create or update the repository’s agent configuration file so coding agents know which verification commands to run.
-
Select the target file.
Use
CLAUDE.mdfor Claude Code. UseAGENTS.mdfor Codex, Copilot, or OpenCode. -
Discover CI commands from
.github/workflows/.Treat workflow files as the source of truth. Read every workflow that exists and extract the exact lint, format-check, type-check, build, and test commands CI runs. Do not hardcode generic commands.
-
Update an existing file in place.
If the target file exists, preserve its content. Add a
Commandssection if it does not have one. If it already has a commands section, verify it matches CI and update only the commands that need to change. -
Create a missing file only with facts you can support.
If the target file does not exist, create it with a brief project description inferred from the repository and a
Commandssection only when CI commands exist. -
Skip commands when no CI configuration exists.
If
.github/workflows/is missing or has no CI commands, omit theCommandssection in a new file. Leave an existing commands section unchanged. -
Keep the file synchronized with any workflow you create later.
If Task 3 writes
.github/workflows/pr-checks.yml, immediately revisit this configuration file and make itsCommandssection match the selected checks.
Task 3: Scaffold PR-check workflow if missing
Section titled “Task 3: Scaffold PR-check workflow if missing”Determine whether the repository already has PR-triggered GitHub Actions coverage. Create a workflow only when coverage is missing.
-
Inspect
.github/workflows/*.ymland.github/workflows/*.yaml.Treat a workflow as sufficient when its top-level
on:block includespull_request, a bare-listpull_requestentry, orpull_request_target. Use tolerant string or line-based inspection. Do not add a YAML parser dependency. -
Skip scaffolding when PR coverage exists.
If any workflow already covers pull requests, skip the workflow scaffold and continue to Task 4.
-
Infer verification commands when PR coverage is missing.
Reuse the repository signals from Tasks 1 and 2. The workflow install step must use the same configured
installCommand.- For Node projects, infer scripts named
lint,format:checkorformat-check,typecheckortype-check,test, andbuild. - For Cargo projects, infer
cargo fmt --check,cargo clippy,cargo test, andcargo build. - For Go projects, infer
go vet,go test ./..., andgo build ./.... - For Python projects, infer commands from detected tools such as
ruff,mypy, andpytest.
Offer only commands you can justify from detected scripts, lockfiles, or tooling.
- For Node projects, infer scripts named
-
Continue without writing a workflow when no commands can be inferred.
Explain that Shipper recommends lint, format-check, type-check, test, and build scripts plus a PR-checks workflow and branch protections because coding agents need deterministic green/red signals and Shipper’s review and merge gates rely on them. Then continue to Task 4.
-
Present inferred commands and require confirmation before writing.
Describe the planned workflow in natural language only. Do not preview file contents. Explain that
.github/workflows/pr-checks.ymlwill run onpull_requestagainst the default branch, using one human-readableubuntu-latestjob per selected command. -
Resolve the default branch.
Terminal window gh api repos/{owner}/{repo} --jq .default_branch -
Check for an existing target file before writing.
If
.github/workflows/pr-checks.ymlalready exists, do not overwrite it. Explain why and skip the write. -
Write
.github/workflows/pr-checks.ymlonly after explicit confirmation.Use
on: pull_request: branches: [<default branch>]. Create one job per selected command. Each job should useactions/checkout@v4, the matching ecosystem setup action, the configuredinstallCommand, and then the single verification command. Keep the workflow simple: no matrix, no file-content preview, and no caching beyond what the setup action provides by default. -
Sync the agent configuration file.
After writing the workflow, update
CLAUDE.mdorAGENTS.mdso itsCommandssection matches the selected checks.
See Reference > CLI for command details.
Task 4: Configure branch protections
Section titled “Task 4: Configure branch protections”Always ask whether to configure branch protections after Task 3 resolves, regardless of whether scaffolding succeeded, was skipped, was declined, or had no inferred commands.
-
If the user declines, continue without configuring protections.
-
If the user approves, create a repository ruleset.
Use
gh api repos/{owner}/{repo}/rulesets -X POST. Target~DEFAULT_BRANCHand include anamefield such asShipper PR Checks. -
Add required status checks only when selected check names exist.
If selected check names exist, include a
required_status_checksrule with those names. If no selected check names exist because scaffolding was declined or no commands could be inferred, explain that Shipper cannot configure a “require PR checks to pass” ruleset yet and do not send an emptyrequired_status_checksrule. -
Use a workflow-file rule only with the correct rule type.
If Task 3 created
.github/workflows/pr-checks.ymland you add a workflow-file rule, use theworkflowsrule type, notrequired_workflows. Resolve the repository ID first:Terminal window gh api repos/{owner}/{repo} --jq .idInclude both
repository_idandpath: ".github/workflows/pr-checks.yml"in the workflow entry. -
Do not use classic branch protection APIs.
-
Handle permissions failures without failing setup.
If
gh apireturns403, report that the user lacks permission to administer branch protections and continue setup.