# Principle type system discipline

> Principle type system discipline is an open-source agent skill for developer tools. Guides agents to encode invariants in types so invalid states fail at compile time. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-type-system-discipline
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-type-system-discipline
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill steers an agent toward type-level design when it writes or reviews code in statically typed languages. It covers modeling domain states so impossible combinations cannot be expressed, giving distinct types to values that share a primitive representation, parsing untrusted input once at the edge of a system, handling every variant of a union, and generating types from an existing schema rather than duplicating them by hand.

The guidance is short and principle-based. It is meant to shape design decisions during type design, function signature review, and general coding in typed languages, rather than to run checks or tools. The skill includes no scripts; it points to a separate typescript-best-practices skill for TypeScript-specific syntax.

It works as ordinary instructions loaded by the agent and expects no particular tools. Its examples and principles are language-neutral, though the closing reference is TypeScript-oriented, so it suits projects using TypeScript or similar typed languages.

## When your agent uses it

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

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-type-system-discipline)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-type-system-discipline)

## Features

- **Impossible states excluded:** Shows how to shape types so invalid combinations of data cannot be written at all.
- **Branded semantic primitives:** Gives arguments with the same underlying type separate types so they cannot be mixed up.
- **Boundary parsing:** Routes JSON, RPC payloads, config, environment variables and database rows through a parser that returns a typed model.
- **Exhaustive variant handling:** Makes sure every case of a union or variant is handled so unhandled cases are caught by the compiler.
- **Schema-derived types:** Derives types from the authoritative schema file instead of maintaining a parallel hand-written copy.

## Good for

- Review a function signature for ambiguous primitive parameters
- Redesign a type so invalid state combinations are no longer possible
- Add validation for API payloads or config at the input boundary
- Refactor a switch over a union so every variant is covered
- Replace a hand-written type with one generated from an existing schema

## Install

### Claude Code

This skill ships in the `pstack` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-type-system-discipline`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-type-system-discipline &&
cp -R "$tmp/plugins/pstack/skills/principle-type-system-discipline" ~/.claude/skills/principle-type-system-discipline &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-type-system-discipline` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-type-system-discipline` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-type-system-discipline &&
cp -R "$tmp/plugins/pstack/skills/principle-type-system-discipline" ~/.agents/skills/principle-type-system-discipline &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-type-system-discipline` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-type-system-discipline` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-type-system-discipline &&
cp -R "$tmp/plugins/pstack/skills/principle-type-system-discipline" ~/.cursor/skills/principle-type-system-discipline &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-type-system-discipline` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-type-system-discipline
```

Or copy the folder to `~/.gemini/skills/principle-type-system-discipline` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-type-system-discipline`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-type-system-discipline &&
cp -R "$tmp/plugins/pstack/skills/principle-type-system-discipline" ~/.copilot/skills/principle-type-system-discipline &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-type-system-discipline` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-type-system-discipline` into your agent's skills folder as `principle-type-system-discipline`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle type system discipline apply?

It applies when designing types, reviewing a function signature, or writing code in any statically typed language.

### Does Principle type system discipline run any scripts or tools?

No. The skill includes no scripts and does not set allowed tools; it provides guidance the agent follows while working.

### Does Principle type system discipline cover TypeScript specifically?

It refers TypeScript syntax questions to a separate typescript-best-practices skill rather than covering them itself.

### How do I install Principle type system discipline in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-type-system-discipline to use it in all your projects, or to .claude/skills/principle-type-system-discipline in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle type system discipline run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Principle type system discipline?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Principle type system discipline?

The closest alternatives to Principle type system discipline are TypeScript best practices, Principle model the domain, Principle boundary discipline, Domain modeling and Principle foundational thinking.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [TypeScript best practices](https://ai-powered.com/skills/typescript-best-practices): TypeScript best practices is an open-source agent skill for developer tools.
- [Principle model the domain](https://ai-powered.com/skills/principle-model-the-domain): Principle model the domain is an open-source agent skill for developer tools.
- [Principle boundary discipline](https://ai-powered.com/skills/principle-boundary-discipline): Principle boundary discipline is an open-source agent skill for developer tools.
- [Domain modeling](https://ai-powered.com/skills/domain-modeling-xd4o): Domain modeling is an open-source agent skill for developer tools.
- [Principle foundational thinking](https://ai-powered.com/skills/principle-foundational-thinking): Principle foundational thinking is an open-source agent skill for developer tools.
- [Principle test behavior not implementation](https://ai-powered.com/skills/principle-test-behavior-not-implementation): Principle test behavior not implementation is an open-source agent skill for developer tools.
- [Readable code](https://ai-powered.com/skills/readable-code): Readable code is an open-source agent skill for developer tools.
- [Poka yoke](https://ai-powered.com/skills/poka-yoke): Poka yoke is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-type-system-discipline
