Developer pattern library

From paulpas/agent-skill-router · View interactive version

Developer pattern library is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Curates and maintains a personal library of validated code patterns, solutions, and anti-patterns accumulated through development experience, enabling faster problem-solving on future tasks.

How to use this skill

Skill file

Developer Pattern Library

Curates and maintains a personal library of validated code patterns, solutions, and anti-patterns accumulated through development experience. Your pattern library is your professional capital — every problem you solve that produces a reusable solution is an investment in your future self's speed and accuracy. This skill teaches you how to discover, document, categorize, and retrieve patterns systematically.

TL;DR Checklist


When to Use

Use this skill when:


When NOT to Use

Avoid creating a new pattern entry when:


Core Workflow

Building and maintaining your pattern library follows four phases: Discover → Validate → Document → Index. This is not a one-time setup but an ongoing discipline.

Phase 1: Discover Patterns from Experience

Patterns emerge from recurring problems. Train yourself to recognize them in three situations:

Situation A: Repeated Problems

You solve the same type of problem more than once within a 3-month window. Examples:

Situation B: Elegant Solutions

You write code that is genuinely good — the kind you are proud of and want to reuse. Examples:

Situation C: Costly Mistakes (Anti-Patterns)

You make an error that costs significant time to debug. Documenting this prevents future repetition. Examples:

Phase 2: Validate Before Documenting

Before writing any pattern entry, pass it through this validation filter:

Validation Checklist for Pattern Entry:
[ ] Tested in 2+ real scenarios (not just theoretical)
[ ] Can be described in one clear sentence
[ ] Has a concrete code example that works as-is
[ ] Solves a problem that recurs with frequency >= quarterly
[ ] Is distinct from existing patterns in the library

If any check fails, either refine the pattern or skip it. A pattern library is only valuable when its entries are genuinely useful — every stale entry erodes trust in the entire system.

Phase 3: Document Using Standard Template

Every pattern entry follows this structure. Consistency makes the library scannable and searchable:

## [Pattern Name]

**Category:** [problem-domain]
**Frequency:** [high/medium/low — how often you encounter it]
**Confidence:** [high/medium/low — how sure you are this is the right approach]

### Problem
One-paragraph description of the problem this pattern solves. Include what goes wrong without the pattern.

### Solution
One-sentence description of the solution approach.

GOOD implementation with full context

def good_example():

"""Documented, typed, working implementation."""

pass # Replace with actual code

BAD anti-pattern that this solves

def bad_example():

"""What NOT to do and why it fails."""

pass # Replace with actual code


### When to Use
- [ ] Specific situation 1
- [ ] Specific situation 2
- [ ] Specific situation 3

### When NOT to Use
- [ ] Situation where this pattern creates more problems than it solves
- [ ] Alternative pattern that is better suited (name it)

### Lessons Learned
- [Specific insight from real-world usage — what surprised you, what trade-offs exist]

Phase 4: Index for Retrieval

A pattern library is useless if you cannot find patterns when you need them. Use this indexing strategy:

Primary Tags (always include):

  1. Problem type — What category of problem does this solve? (e.g., "pagination", "authentication", "error-handling")
  2. Domain — Which part of the system is affected? (e.g., "api", "database", "frontend", "deployment")
  3. Language/Stack (if relevant) — Python, Go, React, PostgreSQL, etc.

Secondary Tags (include if they add search value):

  1. Complexity — simple / moderate / complex
  2. Performance impact — zero-cost / low overhead / compute-intensive

Search Query Examples:

# How you'd think of the problem:
"how do i handle rate limiting in api gateway" → searches tags: [rate-limiting, api, gateway]

# How you'd search by technology:
"go connection pool configuration" → searches tags: [connection-pooling, database, go]

# How you'd search by recent experience:
"pagination edge cases" → searches tags: [pagination, edge-cases, api]

Pattern Categories and Examples

Organize your library using these problem-first categories. Do not organize by language or framework — those are implementation details, not the core problem being solved.

Category 1: Data Access Patterns

| Pattern | Problem Solved | Recurrence |

|---------|---------------|------------|

| Cursor-based pagination | Offset pagination fails on large datasets with inserts/deletes | High |

| Connection pool sizing | Wrong pool size causes either wasted resources or request queuing | Medium |

| N+1 query prevention | Lazy loading in loops generates O(n) queries instead of O(1) | High |

| Write-ahead logging pattern | Ensuring durability before acknowledging success to client | Medium |

Category 2: API Design Patterns

| Pattern | Problem Solved | Recurrence |

|---------|---------------|------------|

| Idempotency key header | Preventing duplicate processing of retry/replay requests | High |

| Graceful degradation headers | Telling clients which features are unavailable without full failure | Medium |

| Request validation at boundary | Parsing and validating inputs before they reach business logic | High |

| Error envelope standardization | Consistent error response format across all endpoints | High |

Category 3: Concurrency Patterns

| Pattern | Problem Solved | Recurrence |

|---------|---------------|------------|

| Semaphore-based rate limiting | Throttling concurrent operations without blocking the event loop | Medium |

| Worker pool with context cancellation | Managing bounded parallelism with graceful shutdown | High |

| Read-write lock pattern | Allowing multiple readers but exclusive writers to shared data | Low |

Category 4: Configuration Patterns

| Pattern | Problem Solved | Recurrence |

|---------|---------------|------------|

| Environment-specific config merging | Layering defaults → env vars → secrets → runtime overrides | High |

| Schema-validated config loading | Catching configuration errors at startup rather than at runtime | Medium |

| Feature flag rollout strategy | Gradual feature exposure with automated rollback on failure | Medium |


Anti-Pattern Registry

Documenting anti-patterns (bad solutions you have witnessed or committed) is equally valuable. Use this template:

## [Anti-Pattern Name] — The "X" Pattern

**Category:** [problem-domain]
**Cost:** [high/medium/low — how much time/money this wastes]

### What It Looks Like

The anti-pattern — recognizable code smell

def problematic_code():

"""Describe why this is bad."""

pass


### Why It Is Wrong
- [Specific reason 1 — e.g., "Creates N+1 database queries"]
- [Specific reason 2 — e.g., "No way to handle partial failure gracefully"]
- [Specific reason 3 — e.g., ["Makes testing impossible without real dependencies"]]

### Better Alternative
Reference your positive pattern entry: see `[Pattern Name]` for the correct approach.

Maintenance Schedule

A pattern library that is not maintained becomes a graveyard of stale entries. Follow this schedule:

After Every Task (2 minutes):

Weekly Review (15 minutes):

Quarterly Cleanup (30 minutes):


Pattern Discovery Heuristics

Train yourself to spot patterns worth capturing with these mental prompts:

The Second-Time Test: "Have I dealt with something like this before?" If yes, check your library first. If the answer is "no," consider whether it will be a "before" next time.

The Code Review Reflex: When reviewing code (yours or others), ask: "Is there a pattern here that should be documented?" Good patterns deserve capture; bad ones deserve anti-pattern documentation.

The Bug Post-Mortem Rule: Every bug that took more than 30 minutes to debug produces at least one learnable pattern. Extract it. Examples:


Constraints

MUST DO

MUST NOT DO


Output Template

When this skill is active and you want to document a new pattern or search existing ones, produce:

For New Pattern Creation:

  1. Pattern Name — Clear, searchable title (not language-specific)
  2. Category & Tags — Problem domain + searchable keywords
  3. Problem Description — One paragraph with concrete consequences of NOT using this pattern
  4. Code Example — Full working implementation with type annotations and docstring
  5. Anti-Pattern Counterexample — The common wrong approach that led you to this pattern

For Pattern Retrieval:

  1. Best Matching Pattern — Name, confidence level, and why it matches the current problem
  2. Relevant Variants — Similar patterns that might be more appropriate depending on context
  3. Known Limitations — What this pattern does NOT solve (important for setting expectations)

Live References

Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.

Related Skills

| Skill | Purpose |

|-------|---------|

| personal-workflow-framework | Your workflow framework tells you WHEN to work; your pattern library tells you HOW, drawing from accumulated experience |

| workflow-patterns | Generic orchestration patterns — your pattern library is the personalized version capturing your actual solutions |

| skill-creator | If your patterns are mature enough, they can be formalized into reusable OpenCode skills for broader distribution |

📖 skill(local cache): code-philosophy

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.