🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Rule Spec

by @pallaoro

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...

Versionv1.0.7
βš™οΈ Configuration

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

Rules

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

Sources

rulespec add-source --id  --type  --description  [--format ]
rulespec remove-source 

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

rulespec add-example --input '{"key": "val"}' --output '{"key": "val"}' [--note ]
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                 # 0-based index

Rule-specific examples

rulespec add-rule-example  --input '{"amount": 100}' --output '{"approved": true}'
rulespec add-rule-example  --input /path/to/file.pdf --output '{"extracted": "data"}'
rulespec remove-rule-example   # 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                   # Custom output dir (default: skills)
    

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

    πŸ”’ Constraints

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

    Sources

    rulespec add-source --id  --type  --description  [--format ]
    rulespec remove-source 
    

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

    rulespec add-example --input '{"key": "val"}' --output '{"key": "val"}' [--note ]
    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                 # 0-based index
    

    Rule-specific examples

    rulespec add-rule-example  --input '{"amount": 100}' --output '{"approved": true}'
    rulespec add-rule-example  --input /path/to/file.pdf --output '{"extracted": "data"}'
    rulespec remove-rule-example   # 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                   # Custom output dir (default: skills)
    

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

    View on ClawHub
    TERMINAL
    clawhub install rulespec

    πŸ§ͺ Use this skill with your agent

    Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

    πŸ” Can't find the right skill?

    Search 60,000+ AI agent skills β€” free, no login needed.

    Search Skills β†’