本文へスキップ
Skillpedia
一般的なプログラミング15k · #10991

principle-type-system-discipline

できること

このスキルは、ミスを早期に捕まえる型を設計するための規則を、アシスタントに与えます。静的型付けの言語で作業する開発者向けです。

使う場面

  • ✓型を設計したり、関数のシグネチャをレビューしたりするとき。
  • ✓同じ型を持つ2つの値が、異なる意味を持つとき。
  • ✓プログラムの外部からデータがコードに入るとき。

スキルのリンク

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ユーザーIDと注文IDは、どちらもただの文字列で、取り違えが起き続けています。コンパイラがこれを止めるように型を厳しくしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

アシスタントは、意味を持つ各値に独自の型を与え、境界で外部データを型付きのモデルに解析し、処理されていないバリアントをビルドの失敗にし、手書きのコピーではなく、権威のあるスキーマから型を導きます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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.
よくある質問

ブランド付きの型とは何ですか?

基本的には文字列に見えるのに、他のIDと混ぜられない型のことです。そのためコンパイラがミスを捕まえます。

解析はどこで行いますか?

ネットワークのペイロード、設定ファイル、コマンドライン引数、データベースの行など、すべての境界です。

なぜスキーマから型を導くのですか?

プロトコルのファイルやマイグレーションが持つ形を手で複製すると、食い違いが生じてしまうからです。

詳細

作者による元の説明

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.

repo: cursor/plugins

人気

GitHubのスター
15k
ランキング
#10991
ライセンス
—
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル