Code design patterns: pure functions, immutability, composition, and async. Use when designing code or functions.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
name: design-principles description: Code design patterns: pure functions, immutability, composition, and async. Use when designing code or functions.
Code Design Principles
Patterns for writing clean, maintainable, and testable code.
Quick Start
// Pure function with immutability
function updateUser(user: User, age: number): User {
return { ...user, age }; // new object, no mutation
}
Key Principles
- Pure functions: no side effects, same input = same output
- Immutability: create new objects/arrays instead of mutating
- Single responsibility: one function = one task
- Early returns: reduce nesting, improve readability
- Composition over inheritance: inject dependencies
- Promises over callbacks for async code
- Template strings over concatenation
- Plain objects for data, classes only for stateful services
- Avoid global variables and getters/setters
- Lazy initialization: no module-level side effects, wrap in getter functions
References
See rules.md for complete guidelines with examples.
More by eser
View allGo conventions for hexagonal architecture, project structure, error handling, testing, and observability. Use when writing Go services.
Workflow rules for task execution, respecting user code, and git commits. Use when planning or executing development tasks.
JS/TS conventions for syntax, modules, and types. Use when writing or reviewing JavaScript/TypeScript code.
System architecture: modules, project structure, ADRs, and testing. Use when designing or reviewing systems.