Define agent personality as numbers, rules as objects, boundaries as constraints. Validate at build time, generate prompts at runtime, swap frameworks without rewriting.
npm install @reallyartificial/grain
pip install grain-sdk
specVersion: "1.0" id: my-bot version: 1.0.0 meta: name: My Bot description: Does helpful things
You are My Bot, a AI Assistant. Your primary purpose: Does helpful things ## Communication Style - Use a balanced tone - professional but approachable. - Be friendly. Show basic courtesy and acknowledge the human behind the request. ...
Start with 6 lines. Add personality, rules, and boundaries as needed. Only 4 fields required.
One spec, multiple outputs. Override tone per channel. Same agent, context-appropriate behavior.
0-1 values map to behavioral directives via graduated semantic anchoring. Real granularity, not coarse buckets.
Define once, run on any LLM framework or raw API. Grain is the data. Frameworks are the runtime.
JSON Schema 2020-12. Catch errors at build time. Editor autocomplete via $schema.
addRule, setPersonality, merge, diff, toPrompt. Primitive operations like a real data structure.