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
- Pick an issue from the current iteration on the Safetybits GitHub Project and move it to In Progress. See Iterations.
- Create a branch from
main, always: never from another branch. The name is up to you; something short that describes the change is enough. - Commit as you go. Commit messages inside the branch are free-form: only the PR title ends up
on
main. - Open the PR early, as a draft if it isn’t ready. Fill in the template.
- CI must pass. See Testing for what it checks.
- Get a review. CODEOWNERS requests it automatically.
- 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.
| Type | Use it for |
|---|---|
feat | A new capability for users: a detection, a feature, a new screen |
fix | A bug fix |
change | A change in existing behaviour that isn’t a new feature or a bug fix: replacing a rule, changing a default, switching a service |
refactor | Restructuring code without changing behaviour |
perf | A performance improvement |
test | Adding or fixing tests only |
docs | Documentation only |
chore | Maintenance: dependency upgrades, housekeeping |
build | The build system or packaging (containers, OVA images) |
ci | CI workflows |
style | Formatting only, no code change |
revert | Reverting 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 dependenciesThe 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
mainworking, linked withBelongs 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.