pattern-discovery
Skill419 starsChanged 4 months agoMITView on GitHub
Pattern library discovery for pattern-first development. Use BEFORE implementing any new feature, creating components, writing API routes, or adding database operations. Ensures existing patterns are checked first before writing new code.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- adyba/pi-safe-workflowedited, first seen Jul 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- adyba/pi-safe-workflow★ 067% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
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/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
- 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 skill into the rules it gives an agent
9 rules. About 0 are common, 7 are distinctive, and 2 are 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.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Search patterns_library/ for existing patterns:
- Very specific: line 44
Check patterns_library/README.md for the complete pattern index:
- Distinctive: line 60
Read the pattern file
- Distinctive: line 62
Follow the customization guide
- Distinctive: line 67
Search codebase for similar implementations
- Distinctive: line 68
If found, consider extracting as new pattern (BSA/ARCHitect only)
- Distinctive: line 69
If not found, implement from scratch following existing conventions
- Distinctive: line 138
Input Validation: - All inputs validated with Zod schemas
- Distinctive: line 143
After applying a pattern, run:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
Pattern Discovery Skill
Purpose
Enforce pattern-first development by checking the Pattern library before implementing new functionality. This reduces code duplication, ensures consistency, and leverages battle-tested solutions.
When to Use
Invoke this skill when:
- About to create a new API route
- About to create a new UI component
- About to add database operations
- About to write integration tests
- User asks "how do I implement..." or "how should I build..."
- Starting work on any feature implementation
Pattern Discovery Protocol
ALWAYS follow this sequence before writing new code:
Step 1: Check Pattern Library
Search patterns_library/ for existing patterns:
# Find patterns by category
ls patterns_library/api/ # API route patterns
ls patterns_library/ui/ # UI component patterns
ls patterns_library/database/ # Database operation patterns
ls patterns_library/testing/ # Testing patternsStep 2: Review Pattern Index
Check patterns_library/README.md for the complete pattern index:
| Category | Patterns Available |
| API | User Context, Admin Context, Webhook Handler, Zod Validation, Bonus Content |
| UI | Authenticated Page, Form with Validation, Data Table, Marketing Page |
| Database | RLS Migration, Prisma Transaction, Server Component Access |
| Testing | API Integration Test, E2E User Flow |
| Security | Input Sanitization, Rate Limiting, Secrets Management |
| CI | GitHub Actions Workflow, Deployment Pipeline |
| Config | Environment Config, Structured Logging |
Step 3: Apply or Escalate
If pattern exists:
- Read the pattern file
- Copy the code pattern
- Follow the customization guide
- Run validation commands
If pattern is missing:
- Search codebase for similar implementations
- If found, consider extracting as new pattern (BSA/ARCHitect only)
- If not found, implement from scratch following existing conventions
- Report pattern gap to BSA for future extraction
Pattern Library Structure
patterns_library/
├── README.md # Pattern index and usage guide
├── api/
│ ├── user-context-api.md
│ ├── admin-context-api.md
│ ├── webhook-handler.md
│ ├── zod-validation-api.md
│ └── bonus-content-delivery.md
├── ui/
│ ├── authenticated-page.md
│ ├── form-with-validation.md
│ ├── data-table.md
│ └── marketing-page.md
├── database/
│ ├── rls-migration.md
│ ├── prisma-transaction.md
│ └── server-component-direct-access.md
├── testing/
│ ├── api-integration-test.md
│ └── e2e-user-flow.md
├── security/
│ ├── input-sanitization.md
│ ├── rate-limiting.md
│ └── secrets-management.md
├── ci/
│ ├── github-actions-workflow.md
│ └── deployment-pipeline.md
└── config/
├── environment-config.md
└── structured-logging.mdPattern Matching Guide
| If you need to... | Use this pattern |
| Create authenticated API endpoint | api/user-context-api.md |
| Create admin-only API endpoint | api/admin-context-api.md |
| Handle external webhooks | api/webhook-handler.md |
| Validate API input with Zod | api/zod-validation-api.md |
| Serve private downloadable content | api/bonus-content-delivery.md |
| Create protected page | ui/authenticated-page.md |
| Build form with validation | ui/form-with-validation.md |
| Display paginated data | ui/data-table.md |
| Create marketing/landing page | ui/marketing-page.md |
| Add new table with RLS | database/rls-migration.md |
| Run multi-step DB operations | database/prisma-transaction.md |
| Test API endpoints | testing/api-integration-test.md |
| Write E2E user flow tests | testing/e2e-user-flow.md |
| Sanitize user input | security/input-sanitization.md |
| Add API rate limiting | security/rate-limiting.md |
| Manage secrets/env vars | security/secrets-management.md |
| Set up CI/CD pipeline | ci/github-actions-workflow.md |
| Configure deployment stages | ci/deployment-pipeline.md |
| Load environment configuration | config/environment-config.md |
| Add structured logging | config/structured-logging.md |
Security Requirements
All patterns enforce:
- RLS Context - Database operations use
withUserContext,withAdminContext, orwithSystemContext - Authentication - Protected routes verify auth before processing
- Input Validation - All inputs validated with Zod schemas
- Error Handling - Comprehensive error handling with proper status codes
Validation Commands
After applying a pattern, run:
yarn lint && yarn type-check # All patterns
yarn test:integration # API patterns
yarn test:e2e # UI patternsAuthoritative Reference
- Pattern Index:
patterns_library/README.md - RLS Patterns: See
rls-patternsskill for database security - Frontend Patterns: See
frontend-patternsskill for UI conventions
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.

