What problem does it solve?
It reduces mental strain when reading and maintaining code by preventing overly complex logic and shallow, hard-to-follow abstractions.
Core Features & Use Cases
- Simplify decision logic: Break complex conditions into descriptive intermediate variables and improve readability with early returns instead of deeply nested branches.
- Improve structure and naming: Use self-descriptive values and avoid custom mappings that require extra memorization.
- Refactor for working-memory limits: Prefer fewer, clearer layers of responsibility and avoid unnecessary abstraction that forces readers to track too many concepts at once.
- Use Case: Refactoring a tangled feature flag condition and nested if/else blocks into a sequence of named booleans that reads linearly for reviewers.
Quick Start
Use cognitive-load to rewrite the function so the logic is flatter, conditions are expressed via meaningful intermediate variables, and any necessary comments explain the motivation rather than restating the obvious.