domain-invariant-check

domain-invariant-check is a skill for Claude Code from zuoyebang/aiweave. It costs 91 tokens per session (1,533 once invoked), scanned A, original, Apache-2.0.

A code-audit guide that checks whether service methods enforce the business rules and state changes documented for a domain. A domain is the part of a product concerned with one area of business behavior.

In plain words
What is it for?
Use it to review service, controller, model, or specific method changes against documented domain invariants and business rules.
Why use it?
It finds cases where a documented rule is missing from the code, bypassed, or marked as checked without actually being enforced.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Good fit Use it to review service, controller, model, or specific method changes against documented domain invariants and business rules.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zuoyebang/aiweave/domain-invariant-check
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 zuoyebang/aiweave --skill domain-invariant-check
Clone the repo
git clone --depth 1 https://github.com/zuoyebang/aiweave

Made for: Claude Code.

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-invariant-check

README.md
[![agentmods](https://agentmods.dev/badge/skills/zuoyebang/aiweave/domain-invariant-check/github.svg)](https://agentmods.dev/skills/zuoyebang/aiweave/domain-invariant-check)
Your own site
<a href="https://agentmods.dev/skills/zuoyebang/aiweave/domain-invariant-check"><img src="https://agentmods.dev/badge/skills/zuoyebang/aiweave/domain-invariant-check/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-invariant-check

Your own site · 80×15
<a href="https://agentmods.dev/skills/zuoyebang/aiweave/domain-invariant-check"><img src="https://agentmods.dev/badge/skills/zuoyebang/aiweave/domain-invariant-check.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,533 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.00091 $0.01533
Opus 5 $0.00046 $0.00766
Sonnet 5 $0.00018 $0.00307
Haiku 4.5 $0.00009 $0.00153

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

Security

Grade A, and why

domain-invariant-check 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 11d 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.

templates/skills/domain-invariant-check/SKILL.md · 118 lines

How it starts

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

审计代码 ↔ 领域不变量一致性。范围:$ARGUMENTS

公共步骤模板见 skills-spec/01_skill_authoring_guide.md §A-§E。本 Skill 不生成代码。

第 0 步:🚫 模块 + 启用状态检查

  1. BUILD_STATUS.md §0 —— 命中 🚫 模块跳过
  2. INDEX.md §0 —— 如 docs-spec/09 §7 领域不变量 未启用 → 跳过本 Skill

第 1 步:读约束源

按顺序读:

  1. docs/service/{module}_service.md §7 —— §7.1 业务规则 / §7.2 隐式约束 / §7.3 业务状态机
  2. docs/architecture/ai_dev_guide.md §8.3 —— 领域不变量约束总清单
  3. docs/BUILD_STATUS.md §11.3 —— 领域不变量启用状态(已设计 / 已启用条目数)

第 2 步:扫描代码范围

$ARGUMENTS 确定扫描范围:

  • 空:git diff main..HEAD --name-only 取新增/修改的 service / controller / models 文件
  • {module}service/{module}/**/*.go
  • {module}/{Method}:聚焦该方法实现及其测试

第 3 步:4 项审计

审计 1:[INVARIANT-CHECK: I-N] 标记 ↔ 代码实现匹配率

对每个含 [INVARIANT-CHECK: I-N] 标记的方法:
  1. 查 §7.1 业务规则表中 I-N 对应的"不变量"条目
  2. 在该方法的代码实现中搜索对应的校验语句(如 if {amount-field} < 0 / status 流转检查)
  3. 匹配 → 通过;不匹配 → 标 🔴 严重(标记与实现脱节,结构性问题)

匹配率统计:matched / total,<95% → 触发回头复审

审计 2:业务规则保护完整性

对 §7.1 中每条业务规则 I-N:
  1. 查所有引用 I-N 涉及的代码位置(§7.1 "代码位置"列)
  2. 校验这些位置的代码确实有校验该规则的逻辑
  3. 缺失 → 标 🔴 严重(漏校验是结构性缺陷)
  4. 校验逻辑被绕过(如新增 if 分支跳过校验)→ 标 🔴 严重

审计 3:隐式约束遵守情况

对 §7.2 中每条隐式约束:
  1. 查约束的应用范围(如"{核心校验接口} 不能写 MySQL")
  2. 扫描对应代码路径是否真的避开了禁止的操作
  3. 违反 → 标 🟡 待复核(隐式约束往往无显式 grep 锚,需人工判断)

审计 4:业务状态机转换合法性

对 §7.3 业务状态机:
  1. 提取所有合法转换(PENDING→ACTIVE / ACTIVE→SUSPENDED 等)
  2. 在代码中搜索状态变更语句(UPDATE ... SET status=?)
  3. 校验每次变更是否:
     - 验证了当前状态(防止非法跳转)
     - 转换路径在 §7.3 表内
  4. 违反 → 标 🔴 严重(破坏状态机是数据一致性根因)

第 4 步:输出格式

按严重程度分组:

🔴 严重 — 标记 / 业务规则 / 状态机 结构性问题
  - [I-1] {Module}.{Method}:声明保护 {核心数值字段}≥0,但代码未发现校验
  - [State-Machine] {Module}.{Method}:UPDATE {状态字段}={state-A} WHERE {状态字段}={state-Z} (非法转换)

🟡 待复核 — 隐式约束疑似违反(需人工判断)
  - [§7.2] {file}:line:{核心校验接口} 调用了 MysqlClient.Save,与"不能写 MySQL"约束疑似冲突

🟢 通过 — 全部匹配

📊 统计
  - 不变量声明 / 实现匹配率:{N}/{M} = {P}%
  - 业务规则覆盖率:{N}/{M}
  - 状态机合法转换:{N}/{M}
  - 建议人工 reviewer 复核:M 处

第 5 步:测试同步

不适用——本 Skill 不生成业务代码。

但建议:如审计发现某条不变量虽有 [INVARIANT-CHECK] 标记但缺少对应测试用例(即缺"业务错误"类用例覆盖违反场景),提示在 PR 补充测试。

Read the full file on GitHub · 118 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. 11d ago First seen · 118 lines · 0 tokens per session scan A c2ced5ad68d3

Subscribe to this mod's changes

domain-invariant-check is a skill published in the GitHub repository zuoyebang/aiweave (20 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 91 tokens to every session and 1,533 once invoked, about $0.0005 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-08-30.

Related

Other skills, from other repositories

code-reviewer

Review completed implementation batches for spec compliance and code quality. Invoke after execution batches complete, before merging, or when a review gate is reached in the workflow.

MageByte-Zero/spec-superflow · 35 tokens

antidote

Stop AI agents from patching symptoms. Use this skill when coding, reviewing, refactoring, auditing, committing fixes, or adding guards, validation, workarounds, or 20+ lines without deleting code.

Avtr99/antidote · 47 tokens

repo-consistency-sweep

Proactive defect-class detection that handles the lower-value half of code review (per Bacchelli and Bird 2013) so human reviewers stay focused on design, intent, and knowledge transfer. Catches convention drift, ordering bugs, type-safety gaps, security and multi-tenant invariants (CWE-grounded), and operability…

Mozurok/fhorja.dev · 200 tokens

pr-feedback-ingest

Turn PR feedback (Greptile, CI, bots, humans) into a structured traceable backlog aligned with TASKSTATE.md, DECISIONS.md, and IMPLEMENTATIONPLAN.md so the next execution step can be a narrow implement-approved-slice or a small planning touch without losing alignment. Corrective scope only. Use when a PR is open or…

Mozurok/fhorja.dev · 230 tokens

review-hard

Review the current task changes for real correctness, safety, and maintainability risks before slice closure or PR prep, and recommend the smallest safe next step. Surfaces meaningful issues (not cosmetic feedback); not a replacement for external review systems. Returns no-op when the review would not materially…

Mozurok/fhorja.dev · 176 tokens

verify-against-rubric-fleet

Orchestrator-workers generalization of verify-against-rubric to N=many artifacts against ONE locked rubric. Dispatches N stateless Sonnet sub-agents in parallel; each receives ONE artifact + the SAME rubric + read-only tools (no TASKSTATE, no DECISIONS, no prior history); returns structured per-criterion verdict.…

Mozurok/fhorja.dev · 187 tokens