safe-agentic-workflow / rules
Cursor rule419 starsChanged 4 months agoMITView on GitHub
Testing rules for pytest, integration tests, and E2E Docker framework.
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/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/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 13-testing.mdc into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
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 54
Verify RLS context is used (no direct ORM calls)
- Distinctive: line 55
Test both success and error paths
- Distinctive: line 58
Test input validation errors (422)
- Very specific: line 65
Use docker-compose.test.yml for infrastructure
- Distinctive: line 66
Test complete user journeys
- Distinctive: line 75
Arrange-Act-Assert: Follow the AAA pattern
- Distinctive: line 77
RLS isolation: Verify user A cannot access user B's data
- Distinctive: line 88
When testing a spec, map each acceptance criterion to at least one test:
≈ “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: "Testing rules for pytest, integration tests, and E2E Docker framework."
globs: "tests/**/*.py,tests/**"
alwaysApply: false
---
# Testing Rules
These rules apply when writing or modifying tests.
## Testing Stack
- **Unit/Integration**: pytest with pytest-asyncio
- **E2E**: Docker-based framework (`docker-compose.test.yml`)
- **Coverage**: pytest-cov
## Test Organization
```
tests/
unit/ # Fast, isolated unit tests
integration/ # API and database integration tests
e2e/ # End-to-end tests (Docker required)
```
## Running Tests
```bash
# Unit tests
pytest tests/unit/
# Integration tests
pytest tests/integration/
# E2E tests
pytest tests/e2e/
# or: make test-e2e
# All tests
pytest tests/ -v
# Full CI validation
{{CI_VALIDATE_COMMAND}}
```
## Test Patterns
### API Integration Tests
See `patterns_library/testing/api-integration-test.md` for the full pattern.
Key points:
- Mock authentication for isolated testing
- Verify RLS context is used (no direct ORM calls)
- Test both success and error paths
- Test authentication failures (401)
- Test authorization failures (403)
- Test input validation errors (422)
### E2E Tests
See `patterns_library/testing/e2e-user-flow.md` for the full pattern.
Key points:
- Use `docker-compose.test.yml` for infrastructure
- Test complete user journeys
- Include login/auth setup in fixtures
- Clean up test data after each run
## Writing Good Tests
1. **Independent**: Tests must not depend on execution order
2. **Repeatable**: Same result every time, no flaky tests
3. **Clear naming**: `test_<what>_<condition>_<expected>`
4. **Arrange-Act-Assert**: Follow the AAA pattern
5. **Edge cases**: Cover boundary conditions, empty states, error paths
6. **RLS isolation**: Verify user A cannot access user B's data
## Coverage Requirements
- Business logic: Aim for high coverage
- API endpoints: All routes should have integration tests
- Security paths: Authentication and authorization MUST be tested
- Error handling: All error responses MUST be tested
## Acceptance Criteria Verification
When testing a spec, map each acceptance criterion to at least one test:
```python
# From spec: "User can create new resource"
def test_user_can_create_resource():
...
# From spec: "Validation shows errors for invalid input"
def test_create_resource_invalid_input_returns_422():
...
# From spec: "Unauthorized access returns 401"
def test_create_resource_unauthenticated_returns_401():
...
```
## Key References
- `patterns_library/testing/` -- Test patterns (copy-paste ready)
- `AGENTS.md` -- QAS role definition and validation commands
- `CONTRIBUTING.md` -- CI pipeline test stages
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.

