universalist
Algebra-Driven Design (ADD): model domains via minimal algebra + laws; encode in types; test laws.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Universalist
Intent
Use Algebra-Driven Design (ADD) to find the smallest algebra that fits the domain, encode it in types, and enforce laws with tests.
Core workflow (ADD)
- Frame the domain: observations, invariants, operations.
- Pick the minimal algebra; avoid overfitting.
- Define types: make illegal states unrepresentable.
- State laws: identity, associativity, distributivity, absorption, round-trip, homomorphism.
- Derive operations from the algebra (map/fold/compose) to reduce ad hoc branching.
- Refactor architecture to match algebra boundaries.
- Test the laws (property/model/metamorphic checks).
- Iterate: if laws are hard to state or test, the algebra is likely wrong.
Minimal-algebra decision guide
- Alternatives/variants → coproduct (tagged union)
- Independent fields → product (record/struct)
- Combine + identity → monoid
- Combine, no identity → semigroup
- Ordering/permissions → poset/lattice
- Add+multiply structure → semiring
- Structure-preserving map → functor
- Effectful apply → applicative
- Sequenced effects → monad
Testing expectations
- Include law/property tests for the chosen algebra.
- Prefer property-based checks when the repo already supports them.
- If not, write minimal deterministic law checks in the existing test framework.
- Don’t assume tooling exists; propose new dependencies only with user approval.
References
-
references/addd-overview.md -
references/addd-sources.md -
references/structures-and-laws.md -
references/testing-playbook.md -
references/case-studies.md -
references/examples-haskell.md -
references/examples-go.md -
references/examples-typescript.md
Scripts
-
scripts/emit_law_test_stub.shprints illustrative law-test stubs for Haskell, Go, or TypeScript.
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!