Skip to content

Instantly share code, notes, and snippets.

@hnordt
Last active January 14, 2026 13:33
Show Gist options
  • Select an option

  • Save hnordt/9130914dc2eae5de24ef23c1ddfd2021 to your computer and use it in GitHub Desktop.

Select an option

Save hnordt/9130914dc2eae5de24ef23c1ddfd2021 to your computer and use it in GitHub Desktop.

Cognitive Model & Design Principles

This codebase follows a rule-driven, semantic-first design model. The goal is to reduce ambiguity, minimize cognitive load, and keep the system easy to reason about as it grows.

Do not introduce new structure without a clear, deliberate reason.

When writing or changing code, follow these principles strictly.

1. Prefer Deterministic Rules Over "It Depends"

  • Always choose clear, absolute rules instead of flexible conventions.
  • Avoid patterns that require interpretation or context to understand.
  • If two options exist, pick one and make it the rule.

2. One Concept per Boundary

  • Each module, section, or namespace should represent one clear concept.
  • Do not group unrelated behavior together.
  • If something does not fit cleanly, the design is wrong.

3. Semantic Clarity Over Implementation Detail

  • Names must describe what something is, not how it works.
  • Avoid names based on temporary implementation choices.
  • Prefer stable concepts over technical mechanisms.

4. Stable Axes, Not Mixed Concerns

  • Keep different dimensions separate:
    • Domain (auth, user, billing)
    • Runtime (server, client, worker)
    • Responsibility (routing, rendering, persistence)
  • Never mix these in the same abstraction.

5. Closed Systems Over Open Flexibility

  • Prefer small, closed systems with limited states.
  • Avoid designs that allow many variations or loose combinations.
  • The structure should guide the developer to the correct choice.

6. Structure First, Abstraction Second

  • The shape of the code should make the architecture obvious.
  • Do not hide structure behind abstractions.
  • If something is hard to place, the design is wrong.

7. Single Responsibility at Unit Level

  • One unit (function, class, module) = one clear responsibility.
  • No "do everything" helpers.
  • If a unit grows, split by responsibility, not by convenience.

8. No Cleverness, No Metaprogramming

  • Avoid magic, dynamic behavior, and implicit contracts.
  • Prefer explicit code, even if it is more verbose.
  • Readability and predictability are more important than brevity.

9. Design for Long-Term Stability

  • Assume this code will be read in 10+ years.
  • Optimize for clarity, not speed of writing.

10. When in Doubt: Reduce the State Space

  • Fewer options is better than more options.
  • If something can be removed, remove it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment