Protected Main Branch
Protected main branch mode changes how the agent delivers code. Instead of merging directly, it creates pull requests.
Enabling
Go to Project → Settings → General and toggle Protected main branch on.
Requirements:
- GitHub integration must be connected and installed
- The project must be linked to a GitHub repository
How it changes the workflow
| Unprotected (default) | Protected | |
|---|---|---|
| Agent completes work | Ticket → In Review | Auto-creates PR on GitHub |
| Approving | Merges to default branch + pushes | Happens on GitHub (merge PR) |
| PR merged on GitHub | N/A | Webhook → Ticket → Done |
| PR closed on GitHub | N/A | Webhook → Ticket → Cancelled |
| CI failure | N/A | Agent auto-fixes (up to 3 retries) |
| PR review | N/A | Agent responds to changes_requested |
| PR comment | N/A | Agent responds to non-command comments |
The full lifecycle
- Create a ticket and start the agent
- Agent works, commits, and pushes to a feature branch
- Agent creates a PR from the feature branch to the default branch
- CI runs on the PR. If it fails, the agent auto-fixes (up to 3 times)
- Reviewers review the PR. If changes are requested, the agent addresses them
- Someone merges the PR on GitHub
- Codality receives the merge webhook, marks the ticket done, cleans up the worktree
Action bar changes
With protected main enabled, the ticket detail action bar shows:
- View PR — Opens the PR on GitHub (when a PR exists)
The Approve button is removed because approval happens on GitHub.
Review page redirect
When you click the review/diff link for a ticket with protected main enabled and an existing PR, Codality redirects you to the PR on GitHub rather than showing a local diff view.
Rebase on push
When someone pushes to the default branch (e.g., another PR is merged):
- Codality receives the push webhook
- The local repository syncs with the remote
- All open worktrees are rebased onto the updated default branch
This keeps all in-progress tickets up to date with main.
Note: If a rebase creates conflicts, the agent handles them on its next run. The worktree remains in the conflicted state until the agent resolves it.