testing-patterns
bybren-llc/safe-agentic-workflow/.agents/skills/testing-patterns/SKILL.md
Testing patterns for unit, integration, and end-to-end tests. Use when writing tests, setting up test fixtures, or validating RLS enforcement. Routes to existing test conventions.
Skill405 starsChanged 3 months ago
What's in it
- Testing Patterns Skill
- Purpose
- When This Skill Applies
- Critical Rules
- FORBIDDEN
- CORRECT
- Test Commands
- Test Directory Structure
- Evidence Template
- Reference
---
name: testing-patterns
description: >
Testing patterns for unit, integration, and end-to-end tests. Use when
writing tests, setting up test fixtures, or validating RLS enforcement.
Routes to existing test conventions.
---
# Testing Patterns Skill
## Purpose
Guide consistent and effective testing. Routes to existing test patterns and provides evidence templates.
## When This Skill Applies
- Writing unit or integration tests
- Setting up test fixtures with RLS
- Running test suites
- Packaging test evidence
## Critical Rules
### FORBIDDEN
```typescript
// Direct Prisma calls bypass RLS
const user = await prisma.user.findUnique({ where: { user_id } });
// Shared test state causes flaky tests
let sharedUser: User;
beforeAll(() => { sharedUser = createUser(); });
```
### CORRECT
```typescript
// Use RLS context helpers
const user = await withSystemContext(prisma, "test", async (client) => {
return client.user.findUnique({ where: { user_id } });
});
// Isolated test state
beforeEach(() => {
const testUser = createTestUser();
});
// Unique identifiers
const userId = `user-${crypto.randomUUID()}`;
```
## Test Commands
```bash
{{TEST_UNIT_COMMAND}} # Unit tests
{{TEST_INTEGRATION_COMMAND}} # Integration tests
{{TEST_E2E_COMMAND}} # E2E tests (Playwright)
{{CI_VALIDATE_COMMAND}} # Full validation
```
## Test Directory Structure
```
__tests__/
├── unit/ # Fast, isolated tests
├── integration/ # API and database tests
├── e2e/ # End-to-end tests
└── setup.ts # Global setup
```
## Evidence Template
```markdown
**Test Execution Evidence**
**Test Suite**: [unit/integration/e2e]
**Files Changed**: [list files]
**Test Results:**
- Total Tests: [X]
- Passed: [X]
- Failed: [0]
**Commands Run:**
```bash
{{TEST_UNIT_COMMAND}} --coverage
```
```
## Reference
- **Jest Config**: `jest.config.js`
- **RLS Context**: `lib/rls-context.ts`
- **Pattern Library**: `patterns_library/testing/`
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/30-background-agents.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
- 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
Also found in one other repository
The same file, byte for byte, in the weekly crawl of public GitHub.
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.

