safe-agentic-workflow / rules
bybren-llc/safe-agentic-workflow/.cursor/rules/30-background-agents.mdc
Guidelines for Cursor background agents running long tasks autonomously in isolated VMs.
Cursor rule405 starsChanged 3 months ago
What's in it
- Background Agent Guidelines
- How Background Agents Work
- SAFe Gate Chain Compliance
- PR Creation from Background Agents
- Best Practices
- Limitations
- When to Use Background Agents
- Example Invocation
---
description: "Guidelines for Cursor background agents running long tasks autonomously in isolated VMs."
alwaysApply: false
---
# Background Agent Guidelines
Cursor Background Agents run long tasks autonomously in isolated Ubuntu VMs with internet access. They clone the repo from GitHub, work on a separate branch, and open PRs when complete.
## How Background Agents Work
- Each background agent runs in an isolated Ubuntu VM provisioned by Cursor
- The agent clones the repository from GitHub (it does NOT use your local checkout)
- It works on a dedicated branch and can commit, push, and open pull requests
- You are notified when the task completes or if the agent needs input
- Multiple background agents can run in parallel on different tasks
## SAFe Gate Chain Compliance
Background agents MUST follow the same SAFe workflow as interactive sessions:
1. **Stop-the-Line Gate**: Verify AC/DoD exists before starting work
2. **Pattern Discovery**: Search `patterns_library/` before implementing
3. **Commit Format**: Use SAFe format `type(scope): description [{{TICKET_PREFIX}}-XXX]`
4. **Branch Naming**: Use `{{TICKET_PREFIX}}-{number}-{description}`
5. **Exit States**: Declare the correct exit state when complete
## PR Creation from Background Agents
When a background agent opens a PR:
- Reference the Linear ticket in the PR title: `feat(scope): description [{{TICKET_PREFIX}}-XXX]`
- Follow the PR template from `CONTRIBUTING.md`
- Include a test plan in the PR body
- Tag appropriate reviewers per the 3-stage review process
- The PR still requires QAS validation and HITL merge authority
## Best Practices
- Assign one ticket per background agent for clear scope
- Provide the full spec path: `specs/{{TICKET_PREFIX}}-XXX-feature-spec.md`
- Reference the agent role: "Act as the BE Developer" or "Act as the FE Developer"
- Include validation commands the agent should run before opening the PR
- Monitor agent progress via Cursor's background agent dashboard
## Limitations
- Background agents cannot access your local filesystem or environment variables
- They start fresh from the GitHub remote each time
- They cannot interact with local Docker containers or databases
- Session state does not persist between background agent runs
- They inherit repository-level Cursor rules but not user-level settings
## When to Use Background Agents
| Scenario | Use Background Agent? |
|----------|-----------------------|
| Implementing a well-specified story with clear AC | Yes |
| Exploratory debugging or investigation | No -- use interactive |
| Multi-file refactoring with clear scope | Yes |
| Tasks requiring local environment (Docker, DB) | No -- use interactive |
| Running test suites and fixing failures | Yes |
| Architectural decisions requiring discussion | No -- use interactive |
## Example Invocation
```
Run as a background agent:
- Act as the BE Developer (see .claude/agents/be-developer.md)
- Implement {{TICKET_PREFIX}}-42 per specs/{{TICKET_PREFIX}}-42-user-api-spec.md
- Follow patterns from patterns_library/api/user-context-api.md
- Run: pytest tests/integration/ && ruff check . && mypy .
- Open a PR when all checks pass
```
More agent context in bybren-llc/safe-agentic-workflow
60 other files this repository gives its agents.
AGENTS.md
CLAUDE.md
Cursor rule
- .cursor/rules/00-core-principles.mdc
- .cursor/rules/01-git-workflow.mdc
- .cursor/rules/02-pattern-discovery.mdc
- .cursor/rules/03-safe-ai-dlc.mdc
- .cursor/rules/04-knowledge-vault.mdc
- .cursor/rules/10-backend-python.mdc
- .cursor/rules/11-frontend-react.mdc
- .cursor/rules/12-database-sql.mdc
- .cursor/rules/13-testing.mdc
- .cursor/rules/14-spec-creation.mdc
- .cursor/rules/15-deployment.mdc
- .cursor/rules/16-stripe-payments.mdc
- .cursor/rules/20-agent-architect.mdc
- .cursor/rules/21-agent-backend.mdc
- .cursor/rules/22-agent-qas.mdc
- .cursor/rules/23-agent-security.mdc
- .cursor/rules/31-mcp-integration.mdc
- .cursor/rules/README.md
Skill
- agent-coordination.agents/skills/agent-coordination/SKILL.md
- api-patterns.agents/skills/api-patterns/SKILL.md
- confluence-docs.agents/skills/confluence-docs/SKILL.md
- deployment-sop.agents/skills/deployment-sop/SKILL.md
- frontend-patterns.agents/skills/frontend-patterns/SKILL.md
- git-advanced.agents/skills/git-advanced/SKILL.md
- linear-sop.agents/skills/linear-sop/SKILL.md
- migration-patterns.agents/skills/migration-patterns/SKILL.md
- orchestration-patterns.agents/skills/orchestration-patterns/SKILL.md
- pattern-discovery.agents/skills/pattern-discovery/SKILL.md
- release-patterns.agents/skills/release-patterns/SKILL.md
- rls-patterns.agents/skills/rls-patterns/SKILL.md
- safe-ai-dlc.agents/skills/safe-ai-dlc/SKILL.md
- safe-workflow.agents/skills/safe-workflow/SKILL.md
- security-audit.agents/skills/security-audit/SKILL.md
- spec-creation.agents/skills/spec-creation/SKILL.md
- stripe-patterns.agents/skills/stripe-patterns/SKILL.md
- team-coordination.agents/skills/team-coordination/SKILL.md
- testing-patterns.agents/skills/testing-patterns/SKILL.md
- vault-sync.agents/skills/vault-sync/SKILL.md
- agent-coordination.claude/skills/agent-coordination/SKILL.md
- api-patterns.claude/skills/api-patterns/SKILL.md
- confluence-docs.claude/skills/confluence-docs/SKILL.md
- deployment-sop.claude/skills/deployment-sop/SKILL.md
- frontend-patterns.claude/skills/frontend-patterns/SKILL.md
- git-advanced.claude/skills/git-advanced/SKILL.md
- linear-sop.claude/skills/linear-sop/SKILL.md
- migration-patterns.claude/skills/migration-patterns/SKILL.md
- orchestration-patterns.claude/skills/orchestration-patterns/SKILL.md
- pattern-discovery.claude/skills/pattern-discovery/SKILL.md
- release-patterns.claude/skills/release-patterns/SKILL.md
- rls-patterns.claude/skills/rls-patterns/SKILL.md
- safe-ai-dlc.claude/skills/safe-ai-dlc/SKILL.md
- safe-workflow.claude/skills/safe-workflow/SKILL.md
- security-audit.claude/skills/security-audit/SKILL.md
- spec-creation.claude/skills/spec-creation/SKILL.md
- stripe-patterns.claude/skills/stripe-patterns/SKILL.md
- team-coordination.claude/skills/team-coordination/SKILL.md
- testing-patterns.claude/skills/testing-patterns/SKILL.md
- vault-sync.claude/skills/vault-sync/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

