← 返回
未分类 中文

Rule Spec

Define, manage, and compile business rules as structured YAML data into LLM-ready prompts and agent-loadable SKILL.md files. Use when the user wants to creat...
定义、管理并将业务规则编译为结构化的 YAML 数据,生成可供 LLM 使用的提示词和可被代理加载的 SKILL.md 文件。适用于用户想要创建...
pallaoro pallaoro 来源
未分类 clawhub v1.0.7 1 版本 100000 Key: 无需
★ 0
Stars
📥 368
下载
💾 0
安装
1
版本
#latest

概述

rulespec

Manage business rules for AI agents without breaking what already works.

Adding a rule to a system prompt shouldn't risk invalidating the ones that are already there. Inline prompt editing doesn't scale — and other solutions aren't built for business rules.

rulespec treats each rule as an independent, validated unit. Add, edit, or remove one rule via CLI — the rest stay untouched. The output is a structured SKILL.md that any AI agent can load.

IMPORTANT: Always use the rulespec CLI to modify rules, sources, and examples. Never edit emitted SKILL.md files directly — they are generated and will be overwritten. For complex structures (source schemas, nested example data), you may edit rulespec.yaml directly, but always run rulespec validate afterward.

All commands use npx rulespec — no global install needed. npx downloads and runs it automatically.

CLI commands

Setup

rulespec init --domain "invoice processing"   # Create rulespec.yaml with domain
rulespec set-domain "customer support"         # Change the domain

Rules

rulespec add --id <id> --rule <text> --context <text> --intent <enforce|inform|suggest>
rulespec edit <id> --rule <new text>           # Update rule text
rulespec edit <id> --intent enforce            # Change intent level
rulespec edit <id> --context "new context"     # Change when rule applies
rulespec remove <id>                           # Remove a rule
rulespec list                                  # List all rules

Sources

rulespec add-source --id <id> --type <document|api|database|message|structured> --description <text> [--format <fmt>]
rulespec remove-source <id>

Global examples (end-to-end input/output pairs)

rulespec add-example --input '{"key": "val"}' --output '{"key": "val"}' [--note <text>]
rulespec add-example --input /path/to/input.json --output /path/to/output.json --note "From files"
rulespec add-example --input /path/to/invoice.pdf --output '{"action": "approve"}' --note "PDF input"
rulespec remove-example <index>                # 0-based index

Rule-specific examples

rulespec add-rule-example <rule-id> --input '{"amount": 100}' --output '{"approved": true}'
rulespec add-rule-example <rule-id> --input /path/to/file.pdf --output '{"extracted": "data"}'
rulespec remove-rule-example <rule-id> <index> # 0-based index

Input/output resolution

Both --input and --output accept three formats:

  • Inline JSON: '{"key": "val"}' — parsed directly
  • JSON file path: /path/to/data.json — file is read and parsed
  • Any other file path: /path/to/doc.pdf — stored as { file: "/path/to/doc.pdf" }

Find & replace

rulespec replace --old "30 days" --new "60 days"   # Validates + recompiles automatically

Build & emit

rulespec compile [id]                          # Preview compiled prompts
rulespec validate                              # Check file against schema
rulespec emit                                  # Generate skills/{domain}/SKILL.md
rulespec emit --include-examples true          # Include examples in output
rulespec emit --outdir <path>                  # Custom output dir (default: skills)

All commands accept --file to specify a different file (default: rulespec.yaml).

File format

schema: rulespec/v1
domain: "your domain here"

sources:                              # optional — what data the rules operate on
  - id: source-name
    type: document | api | database | message | structured
    format: pdf | json | csv          # optional
    description: "What this source is"
    schema:                           # optional — shape of the data
      field: type

rules:
  - id: rule-id                       # kebab-case, unique
    rule: "The business rule in plain language"
    context: "When this rule applies"
    intent: enforce | inform | suggest

examples:                             # optional — end-to-end golden standards
  - note: "What this example tests"
    input: { ... }
    output: { ... }

Intent levels

  • enforce — mandatory. Agent must follow this rule. Compiles to directive language.
  • inform — guidance. Agent should be aware. Compiles to neutral language.
  • suggest — recommendation. Agent may consider. Compiles to soft language.

Workflow

  1. rulespec init --domain "my domain" to create the file
  2. Add sources with rulespec add-source
  3. Add rules with rulespec add
  4. Add examples with rulespec add-example
  5. rulespec validate to check for errors
  6. rulespec compile to preview compiled prompts
  7. rulespec emit to generate skills/{domain}/SKILL.md

Programmatic usage

To inject rules into LLM prompts at runtime:

import { loadRules } from "rulespec";
const rules = await loadRules("rulespec.yaml");
// rules is a compiled markdown string — inject into any system prompt or API call

Key principles

  • Use the CLI for rules, sources, and examples — never edit emitted SKILL.md files
  • For complex source schemas or nested example data, edit rulespec.yaml directly + run rulespec validate
  • rulespec replace is a safe find-and-replace: validates and recompiles after every change
  • One rule, one change — editing a rule only affects that rule's compiled output
  • Examples are excluded from emitted SKILL.md by default (they may contain sensitive data)

Built by the team behind Clawnify.

版本历史

共 1 个版本

  • v1.0.7 当前
    2026-05-07 07:14 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,417 📥 325,748
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,244 📥 271,693
ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,129 📥 881,908