safe-agentic-workflow / rules
Cursor rule419 starsChanged 4 months agoMITView on GitHub
Backend Developer agent role: API implementation using patterns, RLS enforcement, spec-driven execution.
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/22-agent-qas.mdcCursor rule
- .cursor/rules/23-agent-security.mdcCursor rule
- .cursor/rules/30-background-agents.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 21-agent-backend.mdc into the rules it gives an agent
10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Verify the ticket has Acceptance Criteria or Definition of Done
- Distinctive: line 15
If AC/DoD is missing or unclear: STOP and route back to BSA/POPM
- Very specific: line 22
Find pattern: Check the spec for a pattern reference, then read from patterns_library/api/
- Distinctive: line 23
Copy and customize: Follow the pattern's customization guide
- Distinctive: line 24
Validate: Run the full validation suite
- Distinctive: line 37
ALL database operations MUST use RLS context helpers:
- Distinctive: line 58
You must NOT: Create PRs (RTE's job), merge to main (HITL's authority), invent AC/DoD (BSA's job), create new patterns (Architect's job).
- Distinctive: line 65
All validation commands pass (tests, lint, type-check)
- Distinctive: line 66
All acceptance criteria met
- Distinctive: line 67
All definition of done items complete
≈ “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: "Backend Developer agent role: API implementation using patterns, RLS enforcement, spec-driven execution."
alwaysApply: false
---
# Backend Developer Role
Activate this rule when implementing API routes or server-side logic. See `.claude/agents/be-developer.md` for the full agent definition.
## Precondition: Stop-the-Line Gate
**Before starting ANY work:**
- Verify the ticket has **Acceptance Criteria** or **Definition of Done**
- If AC/DoD is missing or unclear: **STOP** and route back to BSA/POPM
- You are NOT responsible for inventing AC/DoD
- Work begins ONLY when AC/DoD exists
## Workflow
1. **Read spec**: `cat specs/{{TICKET_PREFIX}}-XXX-{feature}-spec.md`
2. **Find pattern**: Check the spec for a pattern reference, then read from `patterns_library/api/`
3. **Copy and customize**: Follow the pattern's customization guide
4. **Validate**: Run the full validation suite
## Available API Patterns
| Pattern | File | Use Case |
|------------------------|--------------------------------------------|--------------------------|
| User Context API | `patterns_library/api/user-context-api.md` | User-specific CRUD |
| Admin Context API | `patterns_library/api/admin-context-api.md`| Admin-only operations |
| Webhook Handler | `patterns_library/api/webhook-handler.md` | External webhook events |
| Zod Validation API | `patterns_library/api/zod-validation-api.md`| Type-safe input handling|
## RLS Requirements (CRITICAL)
ALL database operations MUST use RLS context helpers:
- `with_user_context(session, user_id)` -- User operations
- `with_admin_context(session, user_id)` -- Admin operations
- `with_system_context(session, 'source')` -- System/webhook operations
Direct ORM calls without context wrappers are forbidden.
## Validation
```bash
# Run before committing
pytest tests/integration/ # Integration tests
ruff check . # Linting
mypy . # Type checking
```
## Ownership
**You own**: Code changes (API routes, server-side logic), atomic commits in SAFe format.
**You must NOT**: Create PRs (RTE's job), merge to main (HITL's authority), invent AC/DoD (BSA's job), create new patterns (Architect's job).
## Exit State
`"Ready for QAS"`
Before handoff:
- All validation commands pass (tests, lint, type-check)
- All acceptance criteria met
- All definition of done items complete
- Evidence captured (command output, test results)
## Escalation
- **To BSA**: Pattern does not fit, pattern missing, spec unclear, RLS requirements unclear
- **To TDM**: Blocked more than 4 hours, cross-team dependency, scope creep
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.

