Skip to main content
skill CX Codex

principle-type-system-discipline — Claude Code skill

Enforces strict type system rules: brand semantic primitives, parse external data at boundaries, and derive types directly from schemas.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add backnotprop/pstack --skill principle-type-system-discipline -a claude-code
Open on GitHub

What principle-type-system-discipline does

The skill instructs coding agents to reject invalid program states at compile time rather than adding ad-hoc defensive checks across the codebase. It requires distinct semantic primitives to use separate types, such as TypeScript branded intersections or newtypes. A UserId and an OrderId cannot be passed interchangeably even if both are strings.

External inputs like JSON payloads or database rows are treated as untyped until validated. You parse at the boundary into a validated model instead of casting. Parallel type declarations are eliminated: shapes must derive from source schemas like OpenAPI or GraphQL.

Because the skill sets disable-model-invocation: true, the model will not invoke it autonomously; you trigger it when designing types or reviewing code. For TypeScript-specific syntax, it points to the companion typescript-best-practices skill.

What it helps with

  • prevent passing interchangeable primitive IDs such as user and order strings
  • parse raw inputs from JSON or environment variables at system boundaries
  • generate types from OpenAPI or GraphQL schemas instead of writing them manually
  • eliminate invalid states at compile time without scattering ad-hoc checks

Example prompts for the agent

  • Review function signatures in the checkout module using principle-type-system-discipline
  • Design branded types for customer IDs and account IDs
  • Create a boundary parser for incoming webhook JSON payloads

How to install principle-type-system-discipline

1Skills CLI (Vercel)

npx skills add backnotprop/pstack --skill principle-type-system-discipline -a claude-code

2Manually: put the files in place

~/.claude/skills/principle-type-system-discipline/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/principle-type-system-discipline/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about principle-type-system-discipline

How do I install principle-type-system-discipline in Claude Code?

Run the command npx skills add backnotprop/pstack --skill principle-type-system-discipline -a claude-code.

What does branding primitives accomplish?

It prevents arguments sharing the same underlying type, such as strings, from being passed in the wrong place. Validation happens once during creation, letting the compiler verify safety downstream.

Where should data types originate under this skill?

Types must derive directly from authoritative sources such as OpenAPI specs, protocol buffers, GraphQL schemas, or database migrations, avoiding hand-written parallel shapes.

Source text

SKILL.md · MIT
---
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, 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.

- **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.
- **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.

© backnotprop · MIT · backnotprop/pstack

Similar skills

Everything for Code review and refactoring →

From the same set44

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor