enforce-rules-format

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Validate that every rule in the project's instruction files has a proper enforcement classification, and fix any that are missing.
验证项目说明文件中的每一条规则都具备正确的执行分类,并修复所有缺失分类的规则。

Instructions

操作步骤

Step 1: Detect Format

步骤1:检测格式

Check which format the project uses:
v2 (spec-based): Look for
CLAUDE.md.spec.ts
or any
*.spec.ts
files. If found, this is a v2 project — rules must use
enforce()
,
check()
, or
guidance()
.
v1 (hand-written): Look for
CLAUDE.md
,
AGENTS.md
,
.cursorrules
. If found without a spec file, this is a v1 project — rules need
**Enforced by:**
or
**Guidance only**
annotations.
检查项目使用的格式:
v2(基于规范): 查找
CLAUDE.md.spec.ts
或任意
*.spec.ts
文件。如果找到,则为v2项目——规则必须使用
enforce()
check()
guidance()
v1(手写): 查找
CLAUDE.md
AGENTS.md
.cursorrules
。如果找到这些文件但没有规范文件,则为v1项目——规则需要添加
**Enforced by:**
**Guidance only**
注释。

Step 2: Validate

步骤2:验证

For v2 specs:
The TypeScript type system already prevents unannotated rules — you can't create a rule without calling
enforce()
,
check()
, or
guidance()
. So focus on:
  1. Do
    enforce()
    rules reference real linter rules? Run
    npx vigiles compile
    to check.
  2. Are there guidance rules that COULD be
    enforce()
    ? Check linter configs for matching rules.
  3. Are there
    check()
    assertions that could be delegated to a linter? Suggest
    enforce()
    instead.
bash
npx vigiles compile
npx vigiles discover
For v1 hand-written files:
Scan for
###
headings. Each must have one of:
  • **Enforced by:** \
    linter/rule-name``
  • **Guidance only** — reason
  • <!-- vigiles-disable -->
Report missing annotations with a summary table.
针对v2规范:
TypeScript类型系统已阻止未添加注释的规则——不调用
enforce()
check()
guidance()
就无法创建规则。因此重点关注:
  1. enforce()
    规则是否引用了真实的代码检查器规则?运行
    npx vigiles compile
    进行检查。
  2. 是否存在可以改为
    enforce()
    的guidance规则?检查代码检查器配置中是否有匹配的规则。
  3. 是否存在可以委托给代码检查器的
    check()
    断言?建议改用
    enforce()
bash
npx vigiles compile
npx vigiles discover
针对v1手写文件:
扫描
###
标题。每个标题必须包含以下内容之一:
  • **Enforced by:** \
    linter/rule-name``
  • **Guidance only** — reason
  • <!-- vigiles-disable -->
通过汇总表格报告缺失的注释。

Step 3: Fix Issues

步骤3:修复问题

For each issue found:
  1. Check the project's linter configuration for matching rules
  2. Suggest
    enforce("linter/rule")
    (v2) or
    **Enforced by:** \
    linter/rule`` (v1)
  3. If no linter rule exists, suggest
    guidance()
    (v2) or
    **Guidance only**
    (v1)
  4. Ask the user before making changes
针对每个发现的问题:
  1. 检查项目的代码检查器配置中是否有匹配的规则
  2. 建议使用
    enforce("linter/rule")
    (v2)或
    **Enforced by:** \
    linter/rule``(v1)
  3. 如果没有对应的代码检查器规则,建议使用
    guidance()
    (v2)或
    **Guidance only**
    (v1)
  4. 修改前请询问用户

Step 4: Suggest Migration

步骤4:建议迁移

If the project uses v1 format, suggest migrating to v2 specs for type safety:
Your rules could benefit from type-safe specs. Run the
adopt-spec
skill to convert your CLAUDE.md to a typed .spec.ts file.
如果项目使用v1格式,建议迁移到v2规范以获得类型安全:
您的规则可以从类型安全规范中受益。运行
adopt-spec
技能将您的CLAUDE.md转换为带类型的.spec.ts文件。

Step 5: Verify

步骤5:验证

Run the appropriate command:
bash
undefined
运行相应的命令:
bash
undefined

v2

v2

npx vigiles compile && npx vigiles check
npx vigiles compile && npx vigiles check

validate

验证

npx vigiles check

Report the validation result.
npx vigiles check

报告验证结果。