agentleFS
bybren-llcbybren-llc/safe-agentic-workflow/.claude/skills/pattern-discovery/SKILL.md

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

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
  1. Very specific:

    Search patterns_library/ for existing patterns:

    line 32
  2. Very specific:

    Check patterns_library/README.md for the complete pattern index:

    line 44
  3. Distinctive:

    Read the pattern file

    line 60
  4. Distinctive:

    Follow the customization guide

    line 62
  5. Distinctive:

    Search codebase for similar implementations

    line 67
  6. Distinctive:

    If found, consider extracting as new pattern (BSA/ARCHitect only)

    line 68
  7. Distinctive:

    If not found, implement from scratch following existing conventions

    line 69
  8. Distinctive:

    Input Validation: - All inputs validated with Zod schemas

    line 138
  9. Distinctive:

    After applying a pattern, run:

    line 143

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 patterns

Step 2: Review Pattern Index

Check patterns_library/README.md for the complete pattern index:

CategoryPatterns Available
APIUser Context, Admin Context, Webhook Handler, Zod Validation, Bonus Content
UIAuthenticated Page, Form with Validation, Data Table, Marketing Page
DatabaseRLS Migration, Prisma Transaction, Server Component Access
TestingAPI Integration Test, E2E User Flow
SecurityInput Sanitization, Rate Limiting, Secrets Management
CIGitHub Actions Workflow, Deployment Pipeline
ConfigEnvironment Config, Structured Logging

Step 3: Apply or Escalate

If pattern exists:

  1. Read the pattern file
  2. Copy the code pattern
  3. Follow the customization guide
  4. Run validation commands

If pattern is missing:

  1. Search codebase for similar implementations
  2. If found, consider extracting as new pattern (BSA/ARCHitect only)
  3. If not found, implement from scratch following existing conventions
  4. 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.md

Pattern Matching Guide

If you need to...Use this pattern
Create authenticated API endpointapi/user-context-api.md
Create admin-only API endpointapi/admin-context-api.md
Handle external webhooksapi/webhook-handler.md
Validate API input with Zodapi/zod-validation-api.md
Serve private downloadable contentapi/bonus-content-delivery.md
Create protected pageui/authenticated-page.md
Build form with validationui/form-with-validation.md
Display paginated dataui/data-table.md
Create marketing/landing pageui/marketing-page.md
Add new table with RLSdatabase/rls-migration.md
Run multi-step DB operationsdatabase/prisma-transaction.md
Test API endpointstesting/api-integration-test.md
Write E2E user flow teststesting/e2e-user-flow.md
Sanitize user inputsecurity/input-sanitization.md
Add API rate limitingsecurity/rate-limiting.md
Manage secrets/env varssecurity/secrets-management.md
Set up CI/CD pipelineci/github-actions-workflow.md
Configure deployment stagesci/deployment-pipeline.md
Load environment configurationconfig/environment-config.md
Add structured loggingconfig/structured-logging.md

Security Requirements

All patterns enforce:

  • RLS Context - Database operations use withUserContext, withAdminContext, or withSystemContext
  • 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 patterns

Authoritative Reference

  • Pattern Index: patterns_library/README.md
  • RLS Patterns: See rls-patterns skill for database security
  • Frontend Patterns: See frontend-patterns skill for UI conventions

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.