safe-agentic-workflow / rules
Cursor rule419 starsChanged 4 months agoMITView on GitHub
Guidelines for Cursor background agents running long tasks autonomously in isolated VMs.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/00-core-principles.mdcCursor rule
- .cursor/rules/01-git-workflow.mdcCursor rule
- .cursor/rules/02-pattern-discovery.mdcCursor rule
- .cursor/rules/03-safe-ai-dlc.mdcCursor rule
- .cursor/rules/04-knowledge-vault.mdcCursor rule
- .cursor/rules/10-backend-python.mdcCursor rule
- .cursor/rules/11-frontend-react.mdcCursor rule
- .cursor/rules/12-database-sql.mdcCursor rule
- .cursor/rules/13-testing.mdcCursor rule
- .cursor/rules/14-spec-creation.mdcCursor rule
- .cursor/rules/15-deployment.mdcCursor rule
- .cursor/rules/16-stripe-payments.mdcCursor rule
- .cursor/rules/20-agent-architect.mdcCursor rule
- .cursor/rules/21-agent-backend.mdcCursor rule
- .cursor/rules/22-agent-qas.mdcCursor rule
- .cursor/rules/23-agent-security.mdcCursor rule
- .cursor/rules/31-mcp-integration.mdcCursor rule
- .cursor/rules/README.mdCursor rule
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- frontend-patternsSkill
- git-advancedSkill
- linear-sopSkill
- migration-patternsSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- frontend-patternsSkill
- git-advancedSkill
- linear-sopSkill
- migration-patternsSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
The file
We split this 30-background-agents.mdc into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Stop-the-Line Gate: Verify AC/DoD exists before starting work
- Very specific: line 23
Pattern Discovery: Search patterns_library/ before implementing
- Very specific: line 24
Commit Format: Use SAFe format type(scope): description [{{TICKET_PREFIX}}-XXX]
- Very specific: line 25
Branch Naming: Use {{TICKET_PREFIX}}-{number}-{description}
- Distinctive: line 30
When a background agent opens a PR:
- Very specific: line 33
Follow the PR template from CONTRIBUTING.md
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
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
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

