domain-primitives-and-always-valid

domain-primitives-and-always-valid is a skill for Claude Code, Codex from j5ik2o/okite-ai. It costs 218 tokens per session (3,739 once invoked), scanned A, original, MIT.

A design guide for domain primitives and always-valid domain models: types that validate their values when created and remain valid afterward.

In plain words
What is it for?
Use it when designing, implementing, reviewing, or refactoring domain-specific types in Rust, TypeScript, Java, and related languages.
Why use it?
It reduces bugs caused by unrestricted strings or numbers, invalid values entering the system, and arguments of the same basic type being mixed up.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when designing, implementing, reviewing, or refactoring domain-specific types in Rust, TypeScript, Java, and related languages.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/j5ik2o/okite-ai/domain-primitives-and-always-valid
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add j5ik2o/okite-ai --skill domain-primitives-and-always-valid
Clone the repo
git clone --depth 1 https://github.com/j5ik2o/okite-ai

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for domain-primitives-and-always-valid

README.md
[![agentmods](https://agentmods.dev/badge/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid/github.svg)](https://agentmods.dev/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid)
Your own site
<a href="https://agentmods.dev/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid"><img src="https://agentmods.dev/badge/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for domain-primitives-and-always-valid

Your own site · 80×15
<a href="https://agentmods.dev/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid"><img src="https://agentmods.dev/badge/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 218 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,739 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00218 $0.03739
Opus 5 $0.00109 $0.01869
Sonnet 5 $0.00044 $0.00748
Haiku 4.5 $0.00022 $0.00374

Measured 10d ago against content hash b514a7d62d0b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

domain-primitives-and-always-valid scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/domain-primitives-and-always-valid/SKILL.md · 387 lines

How it starts

The opening of the file, as written. The whole thing — 387 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Domain Primitives & Always-Valid Domain Model

プリミティブ型を信頼せず、ドメイン固有の型で不変条件を強制する。

核心原則

Domain Primitives(Secure by Design)

プリミティブ型をそのまま使わず、ドメイン固有の最小単位の型でラップする。

特性 説明
構築時検証 無効な値でインスタンスを作成できない
不変(Immutable) 一度作成されたら変更できない
自己完結 他のエンティティへの参照を持たない
ドメイン操作の集約 その型に関連する操作をカプセル化
引数の取り違え防止 同じプリミティブ型でも異なるドメイン型として区別

Always-Valid Domain Model

ドメインモデルは常に有効な状態にあることを型システムで保証する。

オブジェクトが存在する = そのオブジェクトは有効である

プリミティブ型の危険性

プリミティブ型をそのまま使うと、本番環境で初めて発覚するバグを生む。

1. 無効な値がシステムを汚染する

// ❌ プリミティブ型:無効な値が素通りする
fn transfer(from: &str, to: &str, amount: i64) {
    // 負の金額で送金 → 受取人の残高が減り、送金者の残高が増える!
    db.execute("UPDATE accounts SET balance = balance - ? WHERE id = ?", amount, from);
    db.execute("UPDATE accounts SET balance = balance + ? WHERE id = ?", amount, to);
}

transfer("alice", "bob", -10000);  // コンパイルOK、テストも通る、本番で大損害

2. 引数の取り違えがテストをすり抜ける

// ❌ 同じ型の引数が並ぶと、取り違えてもコンパイラが検出できない
fn create_user(first_name: &str, last_name: &str, email: &str);

// 姓名を逆に渡している。単体テストでは「動く」ので見逃される
create_user("Smith", "John", "[email protected]");
// → DB: first_name="Smith", last_name="John" 😱

3. セキュリティホールを生む

// ❌ 検証なしのStringはSQLインジェクションの温床
fn find_user(email: String) -> User {
    db.query(&format!("SELECT * FROM users WHERE email = '{}'", email))
}

find_user("'; DROP TABLE users; --".to_string());  // 💀

4. 異なる単位の混同

// ❌ 両方ともf64。単位の違いをコンパイラが検出できない
fn calculate_distance(meters: f64, feet: f64) -> f64;

// 火星探査機が墜落した原因(実話:Mars Climate Orbiter, 1999年)
let result = calculate_distance(altitude_in_feet, thrust_in_meters);

なぜテストで発見できないのか

問題 テストの限界
負の金額 正常系テストでは正の値しか使わない
引数の順序 両方とも文字列なので型エラーにならない
境界値 全ての組み合わせをテストすることは不可能
単位の混同 両方とも数値なので計算は「正しく」動く

型で制約すれば、これらはすべてコンパイル時に検出できる。

アンチパターン検出

以下のパターンを見つけたらDomain Primitiveへの変換を検討:

❌ fn send_email(to: String, subject: String)  // StringはEmailではない
❌ fn create_user(age: i32)                    // i32は年齢の制約を持たない
❌ fn process_order(amount: f64, currency: String)  // 別々に渡すと不整合の可能性
❌ struct User { email: String }               // 検証なしで無効な値を保持できる
❌ if !is_valid_email(s) { return Err(...) }   // 検証後も同じString型
❌ fn schedule(room: String, start: String, end: String)  // 引数の取り違えが検出できない

Read the full file on GitHub · 387 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 387 lines · 218 tokens per session scan A b514a7d62d0b

Subscribe to this mod's changes

domain-primitives-and-always-valid is a skill published in the GitHub repository j5ik2o/okite-ai (81 stars, last pushed 4mo ago), licensed MIT. It adds 218 tokens to every session and 3,739 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.

Related

Other skills, from other repositories