How do multiple developers or AI agents work on one codebase safely?
One accountable technical lead (the orchestrator) owns requirements, scope, acceptance criteria, architecture decisions, integration order and production changes. Specialists (security, database, performance, frontend/QA, SRE) can audit and build independently, but:
- One branch or worktree per task with assigned, non-overlapping file ownership
- Order of work: contracts/ADR → database migrations → API → frontend → integration tests
- One migration authority who serialises schema changes and replays them on a fresh database
- Only the integration owner merges or cherry-picks — a cherry-pick copies a commit, not its dependencies or migrations
- Protected main, CODEOWNERS, required CI, reviews, environment approvals — no silent emergency merges, no force-push to main
- Treat AI-written code as untrusted until reviewed; limit agent credentials and separate dev from production secrets
- Write a spec first: user story, scope exclusions, threats, invariants, permissions, API/DB contract, error behaviour, migration compatibility, tests and rollback plan