# Git and Pull Requests
<!--
ref: @any-corp/engineering/git-and-pr
type: protocol
tags: [engineering, git, github, pr, branching, commits]
triggers: [need to create a pull request, branch management issues, commit message format errors, merge conflicts]
trigger_prompt: When a developer is preparing to submit code changes and needs guidance on branch naming, commit messages, or pull request requirements.
version: 2
updated_at: 2026-10-24T21:05:18.275Z
-->
How code moves from your laptop to main to production.
## Branch model — trunk-based
We use **trunk-based development**. `main` is always deployable.
- Cut a branch from `main`.
- Open a PR within 24 hours of cutting (even if it's a draft).
- Merge to `main` within 5 working days (target: 2).
- Long-lived branches are a smell. If a feature can't merge in a week, gate it behind a feature flag and ship the partial work.
## Branch naming
```
{name}/{short-description}
{name}/issue-{number}-{short-description}
```
Examples:
- `alex/add-pricing-page`
- `kim/issue-1234-fix-billing-overflow`
Don't put dates, ticket prefixes from another tracker, or "wip" in the name.
## Commit messages
```
<type>(<scope>): <one-line summary, imperative mood>
<optional body, wrapped at 72 chars>
<optional footer: refs / co-authors>
```
**Types** (the only ones we use):
- `feat` — new functionality
- `fix` — bug fix
- `refactor` — code change that doesn't add/remove behavior
- `perf` — performance change
- `test` — adding or fixing tests
- `docs` — docs only
- `chore` — tooling, deps, infra config
- `build` — build system
Examples:
```
feat(billing): add proration on plan changes
Customers downgrading mid-cycle now see a credit rather than a charge.
Backfill job in next PR.
Refs: #1234
```
```
fix(auth): handle expired session cookie on /login
We were 500-ing instead of redirecting. Cause was a missing null check
in the session middleware.
Refs: #1289
```
The first line is the commit's tweet. Make it count.
## Pull request — required components
### Title
Same shape as a commit message. The PR title becomes the merge commit if you squash-merge.
### Description
Required sections:
```markdown
## What
One-line summary; what changes for the user.
## Why
Why this change. Link the issue, RFD, or DR.
## How
What approach you took, especially anything non-obvious.
## Test plan
What you tested. Commands, screenshots, or recorded clips.
## Risks
What could break. What you've mitigated. What needs monitoring.
```
A description with all five sections answered honestly is **non-negotiable** for any non-trivial PR. The reviewer should know what they're looking at without reading the diff.
### Size
PRs target **< 400 lines changed**. Hard ceiling: **< 800 lines changed**, and only with a stacking explanation in the description.
If your PR is bigger than that, **stack it**: split into a series of smaller PRs that build on each other. Reviewer can land each independently.
### Required CI checks
Configured at the repo level. PR can't merge until:
- Tests pass.
- Linter passes.
- Type check passes.
- Coverage doesn't drop > 1%.
- No new high-severity dependency findings.
### Required reviewer
- Default: **1 reviewer**, anyone in the team's CODEOWNERS.
- Cross-team change (touches code another team owns): **+1 reviewer from that team**.
- Migrations, security-sensitive changes, or production runbooks: **+1 senior engineer**.
## Reviewing a PR — see `@any-corp/engineering/code-review`.
## Merging
We **squash-merge** by default. Branch history is preserved on the branch but doesn't pollute `main`.
- Author merges their own PR after approval (no "approve and merge for me" except for emergencies).
- Merge commit message: PR title + the description's "What" line.
- Delete the branch on merge.
## Releasing
- `main` deploys automatically to **staging** on every commit.
- Promotion to **production** is gated by `@any-corp/engineering/deploy-runbook`.
- Reverts are cherry-picks, not rewrites.
## Merge conflicts
- Resolve **on your branch**, not on `main`.
- Rebase against `main` to fix; don't merge `main` into your branch (creates messy history).
- If a conflict is non-trivial, sync with the other author before resolving.
## What we don't do
- We don't force-push to shared branches. `main` is sacred. Personal feature branches you can rebase as you like.
- We don't merge with a failing CI check unless the failure is unrelated AND there's a written reason in the PR.
- We don't merge a PR over 800 lines without stacking it first.
- We don't commit generated files to source control unless we have a clear reason. Build artifacts are in `.gitignore`.
- We don't squash-merge a series of commits when the individual commits tell a useful story (rare; ask).
---
*Related: `@protocol/git-pipeline-and-timestamp-traps` · `@any-corp/engineering/code-review` · `@knowledge/frameworks/the-interpretability-tax` · `@knowledge/frameworks/constraints-in-code-not-in-prompt` · `@content/youtube/aie/2026-07-11-stop-ai-agent-hallucinations-5-techniques-production-pattern`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*