Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

principle-type-system-discipline

/principle-type-system-discipline

Projektuje typy tak, by nielegalnych stanów nie dało się zapisać: brandowane prymitywy, parsowanie na granicach i pełne warianty.

Repozytorium
claudefiles ↗
Licencja
MIT
Ostatnia zmiana repozytorium
14.10.2026

Ocena i bezpieczeństwo

86/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść21 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 14.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Projektuje typy tak, by nielegalnych stanów nie dało się zapisać: brandowane prymitywy, parsowanie na granicach i pełne warianty.

Oryginalny opis (EN)

Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, refuse to lie to the compiler, exhaust variants, derive from authoritative schemas.

Jak działa

SKILL.md bez nagłówków drugiego poziomu · 14 linii, 519 słów

Podgląd SKILL.md
---
name: principle-type-system-discipline
description: "Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, refuse to lie to the compiler, exhaust variants, derive from authoritative schemas."
disable-model-invocation: true
---

# Type System Discipline

Make the compiler reject impossible states, mismatched primitives, and unhandled variants. Prefer defining errors and special cases out of existence over proliferating handlers. For TypeScript syntax, see the `typescript-best-practices` skill.

- **Make illegal states unrepresentable.** Model variants as sum types (discriminated unions, enums with payloads, sealed classes), not as a bag of optional fields where contradictory combinations compile. `{ completed: boolean; completedAt?: Date }` admits `completed: true` with no date. Derive the boolean from `completedAt`, or model `{ kind: 'open' } | { kind: 'done'; at: Date }`. If you can write a comment explaining when a combination of fields is valid, split it into a sum type.
- **Types are constructions, not restrictions.** Build the type up from the values you want instead of carving them out of a looser type with checks. A non-empty list is a head plus a rest. A valid time range is a start plus a duration. Choose the shape that cannot build the illegal value and expose the interface callers need on top.
- **Brand semantic primitives.** `UserId` and `OrderId` are strings underneath but should not be interchangeable. Give each its own type, such as a branded intersection in TypeScript or a newtype elsewhere. Validate once at creation, trust the type downstream. If two arguments share a primitive type but mean different things, brand them.
- **External data is untyped until parsed.** RPC payloads, JSON, IPC messages, CLI args, config files, environment variables, database rows. Have a parse function at every boundary that turns unstructured input into the typed model. The **boundary-discipline** principle skill says where to put validation.
- **Don't lie to the type system.** Casts, unsafe coercions, and assertion functions that bypass the compiler are latent runtime crashes. If the compiler can't prove a fact, prove it (validate, narrow, refine the model) or accept that the cast is a hazard. Trace each `any`, `as`, or `assertNotNull` to the boundary and validate there.
- **Exhaustive matching is the compiler's job.** A match on a sum type must fail compilation when a new variant is added without handling, so the compiler tells the next agent where to add a case. Use your language's idiom: a `never`-typed binding in TypeScript, an unannotated `match` in Rust, `-Wincomplete-patterns` in Haskell, sealed-class match exhaustiveness in Kotlin.
- **Derive types from authoritative schemas.** When a protocol buffer, OpenAPI spec, GraphQL schema, database migration, design-token file, or another file owns a shape, derive from it instead of hand-rolling a parallel type. See the **encode-lessons-in-structure** principle skill.
- **Strengthen a type only where partiality appears.** A runtime assertion, null check, or "this should never happen" throw marks the place a type is too weak. Push that check up into the type. Then stop. The type system's job is to track the cases each use site must handle, not to describe the data as precisely as possible. Prefer total functions. `sum` of an empty list is 0, so it takes the plain list. `head` of an empty list has no answer, so it demands the non-empty one. If nothing would otherwise panic, keep the plain type.

Wersje

RepozytoriumWynikLicencja
Ta strona · koolamusic/claudefiles86MIT
requie/endostack90MIT
chmonitor/chmonitor86GPL-3.0
asarelcastellanos/claude-workbench86MIT
xinhi6716/axiom-atropos86MIT
workerstack/clients86MIT
lgarceau768/agent-principles86MIT
robansuini/pstack-codex86MIT
Sup-Film/pstack-omp-lean86MIT

Migawka bazy z 13.11.2026 · wersja paczki be17882036e6 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100parse-dont-validate
    Stosuje zasadę projektowania opartą na typach: zamienia dane niestrukturalne w typy strukturalne na granicach systemu, tak by stany niedozwolone były niereprezentowalne, przy walidacji, typach danych i obsłudze błędów.
  • 90design
    Projektuje API, schematy, typy i automaty stanów tak, by błędne użycie nie dawało się wyrazić: typy brandowane, unie dyskryminowane, typestate i parse-don't-validate.
  • 90principle-model-the-domain
    Zapisuje reguły domeny w maszynie stanów, typowym modelu lub tabeli, tak by nieprawidłowych stanów nie dało się zbudować.
  • 100modelling-types-for-nodejs
    Wyraża typy w backendzie Node.js i TypeScript tak, by kompilator wyłapywał błędy: unie, identyfikatory i walidacja granic.
  • 95rc-typescript
    Projektuje typy TypeScript tak, by nielegalne stany były niereprezentowalne, bez furtek typowania.
  • 86principle-boundary-discipline
    Skupia walidację i obsługę błędów na granicach systemu: CLI, konfiguracji, sieci i API, a logikę trzyma w czystych funkcjach.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.