Overview
Rules are modular system prompts that modify AI behavior during sessions. They allow you to dynamically adjust tone, content restrictions, narrative style, and other behavioral aspects without editing world or character files.Why Use Rules?
Rules provide flexibility:- Modular: Apply different rulesets to the same character/world combination
- Reusable: Use the same rules across multiple sessions
- Dynamic: Activate or deactivate rules mid-session
- Layered: Stack multiple rules for combined effects
Rules are injected into the system prompt at runtime. They modify AI behavior without altering the underlying world lore or character persona.
Rule File Structure
Rules are defined as YAML files in theassets/rules/ directory.
Required Fields
Unique identifier for the rule. Used in commands to activate/deactivate.
Display name shown in the TUI rules selector.
The instruction text that modifies AI behavior. This is injected into the system prompt.
Basic Example
Fromassets_example/rules/gritty.yaml:
Advanced Examples
Tone Modifiers
horror.yaml
Content Restrictions
family_friendly.yaml
Narrative Style
noir_style.yaml
Mechanical Rules
combat_detailed.yaml
Content Expansion
nsfw.yaml
Rule Loading Process
Rules are loaded from YAML files at startup:Activating Rules
Add a Rule
engine/commands.py:76-89:
Clear All Rules
Quick NSFW Toggle
nsfw rule on/off (if the rule file exists).
Rules are saved to
persist.json and persist across engine restarts.Stacking Multiple Rules
You can activate multiple rules simultaneously:noir: Sets narrative stylecombat_detailed: Defines how combat is handledgritty: Adds consequence and tone
Rule Categories
Organize rules by purpose:Tone Rules
Modify emotional atmosphere:horror.yaml: Dread and tensionlighthearted.yaml: Fun and comedicepic.yaml: Grand and heroicmelancholic.yaml: Sad and reflective
Content Rules
Control what appears:family_friendly.yaml: Age-appropriate contentnsfw.yaml: Adult contentlow_violence.yaml: Minimal combathigh_violence.yaml: Graphic action
Style Rules
Define narrative approach:noir.yaml: Hardboiled detective stylepoetic.yaml: Lyrical descriptionsterse.yaml: Minimal, clipped sentencesverbose.yaml: Rich, detailed prose
Mechanical Rules
Specify how systems work:combat_detailed.yaml: Blow-by-blow combatdialogue_focused.yaml: Emphasize conversationinvestigation.yaml: Clue-based mysteriessandbox.yaml: Player-driven exploration
Best Practices
Keep rules focused
Keep rules focused
Each rule should do one thing well. Don’t create mega-rules that try to control everything.
Use clear, directive language
Use clear, directive language
Write rule prompts as instructions, not descriptions. “Emphasize X” is better than “X is important.”
Provide examples
Provide examples
Show the AI what you mean with concrete examples in the rule prompt.
Test rule combinations
Test rule combinations
Before using rules in important sessions, test how they interact with your characters and worlds.
Version your rules
Version your rules
If you update a rule significantly, consider creating a new version (e.g.,
combat_v2.yaml).Rule Template
template.yaml
Runtime Rule Management
View Active Rules
The TUI displays active rules in the state panel. Programmatically:Persisted State
Active rules are saved topersist.json:
System Prompt Injection
Rules are injected into the system prompt before each LLM call:- Base engine instructions
- Character persona
- World system prompt
- Active rules (in activation order)
Creating Rule Collections
Create themed rule sets for different play styles:Investigation Pack
Combat Pack
Social Pack
Troubleshooting
Rule not found
If/rules add fails:
- Verify the rule file exists in
assets/rules/ - Check that the ID matches the filename (without
.yaml) - Ensure the YAML is valid and has an
idfield - Restart the engine to reload rule assets
Rule not affecting behavior
- Check that the rule prompt is clear and directive
- Verify the rule is in the active rules list
- Test with a stronger model (some models ignore weak instructions)
- Ensure other rules aren’t contradicting it
- Review the system prompt to see if rule injection is working
Rules conflicting
- Clear all rules and add them one at a time to identify conflicts
- Reorder rule activation (later rules override earlier ones)
- Rewrite conflicting rules to be more compatible
- Use fewer, more focused rules instead of many broad ones
Command Reference
| Command | Description |
|---|---|
/rules add <rule_id> | Activate a rule |
/rules clear | Deactivate all rules |
/nsfw | Toggle NSFW mode (if rule exists) |
Next Steps
Creating Worlds
Design worlds that work with your rules
Creating Characters
Create characters that respond to rules