| name | code-style |
| description | Opinionated language-agnostic design rules for implementation, refactoring, and code review. Use when shaping conditional control flow, finite states, invariants, error boundaries, resource lifetimes, abstractions, public APIs, validation boundaries, pagination, missing values, or the separation of sans-I/O decisions from imperative drivers. |
| license | MPL-2.0 |
| metadata | {"author":"Basti Ortiz <ortiz@bastidood.dev>","source":"https://github.com/BastiDood/skills"} |
Code Style
This skill keeps code explicit, linear, and honest about state, failure, ownership, and side effects. Its directives favor enforceable invariants, narrow boundaries, simple abstractions, and sans-I/O decision logic.
Treat each directive as a language-agnostic semantic requirement. Adapt its TypeScript example to the target language's native syntax, type system, resource-management mechanisms, and compiler checks.
References
Read as many linked references as are relevant to the current task before writing or reviewing code.
- When a condition needs mental negation to understand, express the permitted state through affirmative conditions.
- Keep the successful path readable by rejecting invalid or exceptional cases early with guard clauses.
- Make decisions visible at their point of effect; avoid implicit behavior that conceals valid values or control flow.
- Reserve conditional expressions for selecting one of two simple values, not for hidden effects.
- Make contradictory field combinations unrepresentable by enforcing invariants.
- When an internal guarantee is broken, fail impossible states instead of continuing with invented state.
- Prevent new finite-state members from silently inheriting a fallback through exhaustive decisions.
- Translate only the expected failure at its source with narrow error boundaries, preserving unrelated errors.
- Keep one-off or cosmetic indirection out of the design with simple abstractions.
- Ensure a resource never escapes uninitialized or unreleased by binding ownership to lifetime.
- When a lower layer normalizes external data, preserve caller-relevant information so continuation, retry, filtering, fallback, and other policy choices remain with the caller.
- Let consumers control continuation and stopping by exposing lazy pagination.
- Convert untrusted external payloads into trusted values at the first controlled boundary.
- Keep required absence explicit; reject fabricated defaults unless the domain defines the exact value.
- Keep consumer APIs intentional and side-effect-free with narrow public surfaces.
- Put decisions in a pure core and keep I/O in the imperative shell.