> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with Pull Requests

> The principles we use to build, review and merge every change, and how to pick the right recipe for its scope.

> [!NOTE]
>
> This guide describes **how we work with pull requests at BBrands Lab**, from a one-line fix to a
> module initiative that lasts weeks. It is written for the end state of the CI optimization plan.
> Every rule that depends on a wave carries a badge that says whether it is already in force or
> when it arrives.

## Why it matters

Every push to a pull request that is ready for review kicks off around **40 jobs** in GitHub
Actions: the CI of each affected project, the AI reviews and the policy checks. The merge queue
runs the CI again on the merge result. Working with a good method does more than protect quality:
it also determines how many runner minutes we consume and how long we wait.

## Principles

> [card] One intent per PR
>
> A PR solves one thing. If the title needs an "and", it is probably two PRs.

> [card] Draft first
>
> Every PR starts as a draft. CI does not run on drafts, so iterating there costs no runner
> minutes.

> [card] One push per round
>
> Collect every fix from a review round and push them all at once.

> [card] Verify locally
>
> The git hooks run lint, types, affected tests and the initiative policy before the push. If
> something fails, it fails on your machine, which is free.

> [card] Integrate often
>
> No branch lives more than about two weeks without being merged. Large changes go behind a
> feature flag and land in phases.

> [card] Everything has an initiative
>
> Every PR declares its initiative and the `tracker.yml` tasks it advances.

## The four scope levels

Decide the level before you create the branch. Each level has its own branch recipe, reference
size and expected CI cost.

| Level | When | Branch | Reference size | PRs to develop |
| - | - | - | - | - |
| [1 · Fix](https://docs.bbrands.io/bbrands-lab/pull-requests/level-1-fix.md) | Fixing a defect | `bugfix/<scope>/<name>` (or `hotfix/<name>` from `master`) | ≤ \~200 lines, 1 project | 1 |
| [2 · Scoped development](https://docs.bbrands.io/bbrands-lab/pull-requests/level-2-development.md) | A feature that fits in one PR | `feature/<scope>/<name>` | ≤ \~800 lines, ≤ 40 files | 1 |
| [3 · Multi-PR feature](https://docs.bbrands.io/bbrands-lab/pull-requests/level-3-multi-pr.md) | A feature that needs several PRs | integration branch + sub-PRs | sub-PRs ≤ \~600 lines | 1 at the end |
| [4 · Module initiative](https://docs.bbrands.io/bbrands-lab/pull-requests/level-4-module-initiative.md) | Weeks of work, a new module, migrations | flag + phases (each phase is a Level 3) | per phase | 1 per phase |

> [!WARNING]
>
> Above **1,500 lines or 60 files** the PR must be split, or justified with the `large-change`
> label and an entry in the initiative's decision log. The other thresholds are guidance, not an
> automatic block.

## What changes with the optimization waves

The rules in this guide already apply. The waves change **how much** each step costs in CI, not the
way we work:

[In force since Wave 0](https://docs.bbrands.io/bbrands-lab/pull-requests/waves-roadmap.md)
The team rules in this guide, a right-sized runner and a budget with alerts.

[Arrives in Wave 1](https://docs.bbrands.io/bbrands-lab/pull-requests/waves-roadmap.md)
E2E tests move to the merge queue, with an option to request them on the PR, and the policy checks are grouped into fewer jobs.

[Arrives in Wave 2](https://docs.bbrands.io/bbrands-lab/pull-requests/waves-roadmap.md)
CI runs only what your change needs: small projects grouped together and related tests on the PR.

[Arrives in Wave 3](https://docs.bbrands.io/bbrands-lab/pull-requests/waves-roadmap.md)
Heavy lanes run on external or self-hosted runners and monthly usage goes back within the included minutes.

Full details in the [waves roadmap](https://docs.bbrands.io/bbrands-lab/pull-requests/waves-roadmap.md).

## How to read this section

**1. Pick the level**

Use the [decision tree](https://docs.bbrands.io/bbrands-lab/pull-requests/choose-level.md).

**2. Follow the level's recipe**

Each level page has its own end-to-end checklist.

**3. Learn the lifecycle**

[Lifecycle and checks](https://docs.bbrands.io/bbrands-lab/pull-requests/lifecycle.md),
[commits and titles](https://docs.bbrands.io/bbrands-lab/pull-requests/commits-and-titles.md) and
[review](https://docs.bbrands.io/bbrands-lab/pull-requests/review.md) apply to every level.

**4. Watch the cost**

[CI and cost per PR](https://docs.bbrands.io/bbrands-lab/pull-requests/ci-cost.md) explains what each push kicks off.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.