mirror of
https://github.com/Effect-TS/effect.git
synced 2026-11-27 02:25:36 +08:00
Effect Library Development Patterns
🎯 PURPOSE
This directory provides reusable solutions and best practices for Effect TypeScript development, ensuring consistency and quality across the Effect library codebase.
📚 AVAILABLE PATTERNS
Core Development Patterns
- effect-library-development.md - Fundamental patterns for Effect library development
- module-organization.md - Module structure, exports, and naming conventions
- error-handling.md - Structured error management with Effect
Documentation Patterns
- jsdoc-documentation.md - JSDoc documentation standards and examples
Testing Patterns
- testing-patterns.md - Testing strategies with @effect/vitest and TestClock
Architecture Patterns
- platform-integration.md - Service abstractions and cross-platform patterns
🔧 HOW TO USE
For Developers
- Reference before implementing - Check relevant patterns before starting new work
- Follow established conventions - Use patterns as templates for consistency
- Contribute improvements - Update patterns based on lessons learned
For Code Reviews
- Validate pattern compliance - Ensure implementations follow established patterns
- Identify pattern violations - Look for anti-patterns and forbidden practices
- Suggest pattern usage - Recommend appropriate patterns for specific use cases
For Documentation
- Extract reusable patterns - Identify common solutions for documentation
- Update patterns - Keep patterns current with library evolution
- Cross-reference examples - Link patterns to real codebase examples
🚨 CRITICAL PRINCIPLES
Forbidden Patterns (NEVER USE)
- try-catch in Effect.gen: Breaks Effect's error handling semantics
- Type assertions:
as any,as never,as unknownhide type errors - Unsafe patterns: Any pattern that bypasses Effect's type safety
Mandatory Patterns (ALWAYS USE)
- return yield for errors*: Makes termination explicit in generators
- Immediate linting:
pnpm lint --fixafter editing TypeScript files - JSDoc compilation validation:
pnpm docgenmust pass - Effect testing patterns: Use @effect/vitest with
it.effect - TestClock for time: Use TestClock for any time-dependent operations
📈 PATTERN QUALITY METRICS
Completeness
- Core concepts clearly explained
- Executable code examples provided
- Common use cases covered
- Integration patterns documented
Accuracy
- All examples compile and run correctly
- Patterns follow current Effect library conventions
- No deprecated or anti-pattern usage
- Proper error handling demonstrated
Clarity
- Clear explanations for "why" not just "how"
- Progressive complexity (simple to advanced examples)
- Common pitfalls identified and explained
- Best practices highlighted
🔄 MAINTENANCE
Regular Updates
- API Changes: Update patterns when Effect library APIs evolve
- New Patterns: Add patterns for newly identified common use cases
- Deprecation: Mark outdated patterns and provide migration paths
- Examples: Keep examples current with latest library versions
Quality Assurance
- Pattern Validation: Regularly test all code examples
- Consistency: Ensure patterns align with current codebase standards
- Documentation: Keep pattern documentation synchronized with implementation
🎯 SUCCESS INDICATORS
Developer Experience
- Reduced time to implement common patterns
- Consistent code quality across the codebase
- Fewer pattern-related code review comments
- Improved onboarding for new contributors
Code Quality
- Consistent architecture patterns throughout codebase
- Proper error handling and resource management
- Type-safe implementations without workarounds
- Comprehensive test coverage with proper patterns
Documentation Quality
- Practical, working examples for all patterns
- Clear guidance on when and how to use each pattern
- Integration examples showing pattern composition
- Anti-pattern identification and alternatives
This patterns directory serves as the authoritative guide for Effect library development, ensuring consistent, high-quality implementations across the entire codebase.