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.
npx skills add j5ik2o/okite-ai --skill domain-primitives-and-always-validgit clone --depth 1 https://github.com/j5ik2o/okite-aiWrote 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.
[](https://agentmods.dev/skills/j5ik2o/okite-ai/domain-primitives-and-always-valid)<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.
<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>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.
| Model | Per session | Once 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 |
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.
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) // 引数の取り違えが検出できない
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.
- 10d ago First seen · 387 lines · 218 tokens per session scan A b514a7d62d0b
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.
Other skills, from other repositories
architecture-audit
Systematic architecture audit and refactoring methodology for Rust + TypeScript codebases. Use when performing refactoring, cleanup, unification, code review, dead code removal, module reorganization, or tech debt elimination. Ensures no naming confusion, semantic overloading, hidden defaults, duplicate logic, or…
no-bare-casts
Writing as in TypeScript or TSX production code, modifying a file that contains a bare as cast, silencing a type error with a cast, encountering as unknown as, or reviewing a cast site.
ax-rust-llm
Use when writing Rust code with axllm for using the generated Ax package, factory functions, package docs, examples, and API reference.
ax-rust-signature
Use when writing Rust code with axllm for string signatures, field descriptors, JSON schema output, validation, and typed tool argument shapes.
dd-code-generation
Use pup CLI for immediate Datadog operations or generate code for integration into applications.
splitting-oversized-modules
Split an oversized Python module (a thousand-plus-line logic.py, models.py, api.py, or its test file) into a package of one module per concern, mechanically and provably without changing behavior. Use on a request to split / break up / decompose a god module or move functions out of one, once a human has agreed to…