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

principle-model-the-domain

できること

このスキルは、状態を持つロジックを、ドメインに合った構造でモデル化する規則を、アシスタントに与えます。フラグやネストした条件でコードがいっぱいになっているエンジニア向けです。

使う場面

  • ✓ライフサイクルや段階を持つ、状態を扱うロジックを書いているとき。
  • ✓コードの分岐が多く、同じ形の前提がファイル間で繰り返されるとき。
  • ✓無効な状態がシステムに入り続けてしまうとき。

スキルのリンク

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-model-the-domain/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“注文の流れで、ステータスの追跡にブール値が大量に使われています。あり得ない状態が起きないように、きちんとモデル化してください。”

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

仕組み

アシスタントは本当の状態とルールを特定し、状態機械、型付きのモデル、ルックアップテーブルなど、適した構造でそれらを表します。これにより、多くの分岐が減り、無効な状態を書きにくくなります。

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

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

Model the Domain

Encode the real domain in a data structure instead of scattering it across conditionals. A structure that matches the domain makes invalid states unrepresentable and deletes branches. Choosing it at write time is cheap. Recovering it later reads as a refactor and gets deferred.

Reach for:

  • A state machine instead of scattered booleans, phases, or lifecycle checks.
  • A typed model instead of loose parameters or repeated shape assumptions.
  • A map, registry, lookup table, or discriminated union instead of branching spread across files.
  • A reducer or command/event model instead of ad hoc state mutations.
  • A module organized around one body of domain knowledge instead of a sequence such as load, validate, transform, and save. Execution order is not ownership.
  • A small module boundary that gathers repeated behavior, ownership, or invariants.
  • A queue, cache, index, graph, tree, or normalized collection where the access pattern calls for it.
  • Any other structure that fits. When none fits, work out what the code must never allow and how the data gets read, then find the structure that encodes exactly that.

Do not force an abstraction. Prefer boring code if the current shape is already clear, local, and unlikely to grow. Be skeptical of an abstraction that adds indirection without removing branches, duplicated rules, invalid states, or lifecycle risk.

The sign that you skipped this is a new feature that grows an existing if/else chain by one more branch, or a second boolean that must stay in sync with the first. Temporal decomposition is another sign. Phase-named modules repeat the same domain rules across steps.

よくある質問

すべての問題に新しい構造が必要ですか?

いいえ。現在の形が明確で、大きくなりそうにないなら、スキルは単純なコードを優先します。

典型的な例は?

散らばったブール値を、有効な遷移だけを許す状態機械に置き換えることです。

なぜ構造を早く選ぶのですか?

書く時点では安価ですが、後から正しい構造を再構築するのは先送りされがちで、費用が大きくなるからです。

詳細

作者による元の説明

Apply when writing stateful logic, or when code branches a lot or repeats a shape assumption across files.

repo: cursor/plugins

人気

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

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

0

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

コメント

  • …

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

似ているスキル