Files
freemo 98680825a7 feat(skills): add exhaustive programming patterns agent skill
Adds a comprehensive opencode skill under .opencode/skills/programming-patterns/
covering 90+ design, architectural, concurrency, and functional patterns.

- 108 files, 33,500+ lines across 13 reference categories
- Every pattern: pseudocode + tested Python + Go + JavaScript implementations
- All 239 code blocks verified passing (85 Python, 76 Go, 78 JS)
- 1,569-line SKILL.md with:
  - Master decision tree (all 14 categories with multi-pattern suggestions)
  - 34 situation-specific decision trees covering every programming scenario
    (new feature, refactoring, REST API, CLI, data pipeline, rule engine,
     external integration, performance, memory, notifications, plugins,
     caching, events, auth, reporting, vendor lock-in, domain model,
     business rules, observability, file I/O, scheduling, testability,
     third-party libs, concurrency, complex domain interactions)
  - 12 compound pattern-combination scenarios with full architecture maps
    (e-commerce checkout, REST endpoint, background jobs, real-time dashboard,
     microservice resilience, ML pipeline, text editor, legacy migration,
     multi-tenant SaaS, document approval, financial transactions, chat)
  - 'When Am I Allowed to Skip Patterns?' mandate table (answer: never)
  - Quick pattern lookup tables for all 90+ patterns
  - Complete reference index
2026-04-15 13:21:51 -04:00

1.8 KiB

Functional Patterns

Overview

Functional patterns leverage concepts from functional programming to write code that is more predictable, composable, and testable. These patterns emphasize immutability, pure functions, and declarative data transformations.

Patterns in This Category

Pattern Purpose Key Mechanism
Higher-Order Functions Pass and return functions as values map, filter, reduce
Monad Chain operations with context (errors, nulls) Maybe, Result types
Immutability Prevent state mutation after creation Frozen / read-only objects
Currying Transform multi-arg functions into chains Partial application
Memoization Cache function results by inputs Lookup table / decorator
Pattern Matching Destructure and branch on data shape match/case, type switch
Lazy Evaluation Defer computation until value is needed Generators, thunks

When to Use Functional Patterns

  • Data pipelines: Higher-Order Functions, Lazy Evaluation
  • Error handling without exceptions: Monad (Result/Maybe)
  • Concurrent / parallel code: Immutability (no shared mutable state)
  • Configuration and DSLs: Currying
  • Performance optimization: Memoization, Lazy Evaluation
  • Complex conditional logic: Pattern Matching

General Principles

  1. Prefer pure functions -- same input always produces same output, no side effects.
  2. Avoid mutation -- create new values instead of modifying existing ones.
  3. Compose small functions into larger transformations.
  4. Make illegal states unrepresentable using types (Monad pattern).
  5. Defer work until actually needed (Lazy Evaluation).