Skip to content
Pull Requests and Commits

Pull Requests and Commits

Every change to our repositories goes through a pull request (PR), including the ones written by the person who owns the repository. This page describes how we do it in safetybitsio/safetybits, the main product repository; other repositories follow the same rules unless their README says otherwise.

The flow

  1. Pick an issue from the current iteration on the Safetybits GitHub Project and move it to In Progress. See Iterations.
  2. Create a branch from main, always: never from another branch. The name is up to you; something short that describes the change is enough.
  3. Commit as you go. Commit messages inside the branch are free-form: only the PR title ends up on main.
  4. Open the PR early, as a draft if it isn’t ready. Fill in the template.
  5. CI must pass. See Testing for what it checks.
  6. Get a review. CODEOWNERS requests it automatically.
  7. Squash and merge. It’s the only merge method enabled. The branch is deleted automatically.

We practise trunk-based development: pull requests are short-lived, ideally merged within a day or two of opening. If main moves while your branch is open, update your branch from main rather than letting it drift. A branch that has lived for a week is a sign the change should have been split.

PR titles: Conventional Commits

Because we squash, the PR title becomes the commit message on main, and it’s what we read in the history and in release notes. Titles follow Conventional Commits, and a CI check (PR Title) rejects any title that doesn’t.

type(scope): summary
  • type: one of the types below. Required.
  • scope: the part of the system the change touches, in lowercase. Optional, but use it when the change is limited to one area.
  • summary: what the change does, in the imperative (“add”, “fix”, “remove”), without a trailing full stop.
TypeUse it for
featA new capability for users: a detection, a feature, a new screen
fixA bug fix
changeA change in existing behaviour that isn’t a new feature or a bug fix: replacing a rule, changing a default, switching a service
refactorRestructuring code without changing behaviour
perfA performance improvement
testAdding or fixing tests only
docsDocumentation only
choreMaintenance: dependency upgrades, housekeeping
buildThe build system or packaging (containers, OVA images)
ciCI workflows
styleFormatting only, no code change
revertReverting an earlier change

change isn’t part of the Conventional Commits standard; we added it because many of our changes replace or adjust existing behaviour, and calling them feat or fix would be misleading.

Scopes we use often: agent, sensor, rules, intel, appliance, deploy, mcp, agentic. Reuse an existing scope before inventing a new one.

Examples from our history:

feat(sensor): decode the OPC UA service type in MSG messages
fix(agent): Feed discovered devices through one long-lived pipeline
change(rules): replace the broadcast traffic rule with the ML network-discovery rule
chore: Upgrade dependencies

The PR description

The repository’s template asks for:

This PR:

- <replace with bullet>
- <replace with other bullet>

Fixes #0000
Belongs to #0000
  • Bullets: what the PR does and why, one change per bullet. Reviewers read this before the code.
  • Fixes #…: the issue this PR completes. GitHub closes it on merge.
  • Belongs to #…: the parent issue or epic it’s part of, when the PR is one step of a larger piece of work.

Delete the lines that don’t apply rather than leaving placeholders.

Keep PRs small

Small PRs get reviewed faster, break less and are easier to revert. As a guide:

  • One logical change per PR. If the description needs “and also”, consider splitting it.
  • Split large work into steps that each leave main working, linked with Belongs to #….
  • Move refactors into their own PR before the feature that needs them.
  • Generated or vendored changes (dependency upgrades, removed trees) are fine to be big, but keep them separate from hand-written code.

Reviews

As the author:

  • Review your own diff first.
  • Answer every comment, even if only to say it’s done.
  • Don’t merge with unresolved discussions.

As the reviewer:

  • Review within one working day. A waiting PR is waste.
  • Look at correctness, tests, simplicity and naming first; formatting is the linters’ job.
  • Say whether a comment is blocking or a suggestion (“nit:”).
  • Approve when it’s good enough to merge, not when it’s how you’d have written it.

Code written with AI

AI-assisted changes follow exactly the same rules, and the author must be able to explain every line in review. See AI at Safetybits. For larger changes, consider the Research, Plan, Implement workflow.

Dependency upgrades

Dependabot opens dependency upgrade PRs. They’re titled chore: Upgrade dependencies and follow the same rules: CI must pass and someone reviews them before merging.