User (Discord)
│
▼
Product Manager (Main Agent)
│
├── Backend Agent
├── Frontend Agent
├── QA Agent
└── DevOps Agent
│
▼
GitHub Repo
│
┌───────┴────────┐
▼ ▼
Vercel Staging Vercel Production
│ │
Staging DB Production DB
You will maintain three environments:
| Environment | Purpose | Branch | Who Can Deploy | DB |
|---|---|---|---|---|
| Local | Development | feature/* | Backend / Frontend | Local DB |
| Staging | Testing | dev |
DevOps Agent only | Staging DB |
| Production | Live users | main |
DevOps Agent only | Production DB |
flowchart TD
A[Feature Request] --> B[PM Agent]
B --> C[Backend + Frontend]
C --> D[Pull Request to dev]
D --> E[QA Testing on Staging]
E -->|Pass| F[Merge dev → main]
F --> G[Production Deploy]
E -->|Fail| C
| Branch | Purpose | Protected? |
|---|---|---|
| main | Production | 🔒 Yes |
| dev | Staging | 🔒 Yes |
| feature/* | Feature work | No |
| hotfix/* | Urgent fix | Limited |
- ❌ No direct pushes
- ❌ No force push
- ✅ Requires PR
- ✅ Requires QA approval
- ✅ Requires CI passing
- ✅ Requires DevOps approval
- ❌ No direct push
- ✅ Requires PR
- ✅ CI must pass
- ❌ Does NOT deploy to production
| Setting | Staging | Production |
|---|---|---|
| Project | Same project | Same project |
| Branch | dev |
main |
| Auto-deploy | Enabled | Enabled |
| Environment Variables | Staging set | Production set |
| Database | Staging DB | Production DB |
| Variable | Staging | Production |
|---|---|---|
| DATABASE_URL | staging DB | prod DB |
| JWT_SECRET | staging secret | prod secret |
| API_BASE_URL | staging domain | prod domain |
| Variable | Staging | Production |
|---|---|---|
| NEXT_PUBLIC_API_URL | staging | production |
This prevents agents from breaking things.
| Platform | PM | Backend | Frontend | QA | DevOps |
|---|---|---|---|---|---|
| GitHub Read | ✅ | ✅ | ✅ | ✅ | ✅ |
| GitHub Write feature/* | ❌ | ✅ | ✅ | ❌ | ✅ |
| Merge to dev | ❌ | ❌ | ❌ | ❌ | ✅ |
| Merge to main | ❌ | ❌ | ❌ | ❌ | ✅ |
| Vercel Deploy | ❌ | ❌ | ❌ | ❌ | ✅ |
| Production DB | ❌ | ❌ | ❌ | ❌ | ❌ (read-only only) |
| Staging DB | ❌ | ✅ | ❌ | Read | ❌ |
Each agent must have isolated tokens.
VERCEL_TOKENGITHUB_ADMIN_TOKEN- Access to production environment variables
GITHUB_WRITE_TOKEN(restricted to feature branches)STAGING_DATABASE_URL- ❌ No access to production DB
GITHUB_WRITE_TOKEN- ❌ No DB access
GITHUB_READ_TOKEN- Staging URL access
- ❌ No write access anywhere
Backend + Frontend → PR → dev branch
↓
Vercel auto-deploys staging
↓
QA tests staging URL
↓
If PASS → DevOps promotes to production
DevOps must:
- Confirm QA PASS
- Confirm CI PASS
- Confirm staging URL health check
- Merge dev → main
- Monitor Vercel production build
- Validate production health endpoint
- Announce success
If production breaks:
| Scenario | Action |
|---|---|
| Minor UI bug | Rollback via Vercel previous deployment |
| API error | Revert GitHub commit |
| DB migration issue | Run rollback migration |
DevOps must:
1. Identify last stable commit
2. Re-deploy previous version
3. Announce rollback
User Request
↓
PM Breakdown
↓
Backend + Frontend
↓
PR to dev
↓
Staging Deploy
↓
QA Testing
↓
If PASS → DevOps
↓
Merge to main
↓
Production Deploy
↓
Health Check
↓
User Notification
| Depth | Agent | Can Spawn? |
|---|---|---|
| 0 | PM | Yes |
| 1 | Backend | Optional |
| 1 | Frontend | Optional |
| 1 | QA | No |
| 1 | DevOps | No |
| 2 | Test workers | Never |
Set:
{
"agents": {
"defaults": {
"subagents": {
"maxSpawnDepth": 2,
"maxChildrenPerAgent": 4,
"maxConcurrent": 6
}
}
}
}Production deploy is allowed ONLY if:
| Condition | Required |
|---|---|
| QA PASS | ✅ |
| CI PASS | ✅ |
| No open critical bugs | ✅ |
| Staging healthy | ✅ |
| Branch protection valid | ✅ |
DevOps must verify ALL before production merge.
DevOps Agent must:
-
Call GitHub API:
- Check open PRs
- Check failing checks
-
Call Vercel API:
- Confirm build status
- Confirm deployment ready
-
Call health endpoint:
/api/health
Agents may NOT:
- Modify main branch
- Access production DB
- Deploy without QA PASS
- Override environment variables
- Bypass PM task assignment
Only PM communicates final updates to user.
/frontend
/backend
/shared
/tests
/scripts
/vercel.json
- Production DB never exposed to any agent.
- DevOps has read-only DB access (if needed).
- All deployments must go through GitHub.
- No direct Vercel CLI deployments.
- No agent has full admin GitHub rights except DevOps.
- Canary deployment (Vercel preview split)
- Feature flags
- Migration review agent
- Secrets scanner
- Monitoring agent (error threshold watcher)
- Scheduled backup validation
Before Production Deploy:
- ✅ Staging tested
- ✅ Database migrations validated
- ✅ No console errors
- ✅ API latency acceptable
- ✅ Security scan passed
- ✅ Previous version available for rollback
- ✅ Version tag created