For the full RUNE pattern reference, see SPEC.md.
Every RUNE spec defines these fields:
| Field | Required | Purpose |
|---|---|---|
| SIGNATURE | Yes | Exact function interface in target language syntax |
| INTENT | Yes | What it does, 1-3 sentences |
| BEHAVIOR | Yes | Logic rules in WHEN/THEN format |
| TESTS | Yes | Minimum 3: happy path, boundary, error |
| CONSTRAINTS | No | Input validation rules |
| EDGE_CASES | No | Boundary conditions and expected behavior |
| DEPENDENCIES | No | External libraries |
| EXAMPLES | No | Usage examples |
| COMPLEXITY | No | Big-O time/space |
Use standalone .rune files when you want formal, parseable specs. The SIGNATURE uses the target language’s real syntax:
---
meta:
name: validate_coupon
language: python
version: 1.0
tags: [e-commerce, validation]
---
RUNE: validate_coupon
SIGNATURE: |
def validate_coupon(code: str, coupons: list[dict], current_date: str) -> tuple[bool, str]
INTENT: |
Validates a coupon code against active coupons. Checks existence,
expiration, and discount value. Case-insensitive matching.
BEHAVIOR:
- WHEN code is empty THEN return (False, "Coupon code cannot be empty")
- WHEN code not found (case-insensitive) THEN return (False, "Coupon code not found")
- WHEN coupon has expired THEN return (False, "Coupon has expired")
- OTHERWISE return (True, matching_coupon)
TESTS:
- "validate_coupon('SAVE10', [...], '2025-01-15')[0] == True"
- "validate_coupon('save10', [...], '2025-01-15')[0] == True"
- "validate_coupon('INVALID', [...], '2025-01-15')[0] == False"
- "validate_coupon('', [], '2025-01-15')[0] == False"
The pattern is the same in every language. Only the SIGNATURE syntax and naming conventions change.
Use markdown sections when embedding specs inside AGENTS.md or other docs:
### validate_coupon
**SIGNATURE:** `def validate_coupon(code: str, coupons: list[dict], current_date: str) -> tuple[bool, str]`
**INTENT:** Validates a coupon code against active coupons. Checks existence, expiration, and discount value. Case-insensitive matching.
**BEHAVIOR:**
- WHEN code is empty THEN return (False, "Coupon code cannot be empty")
- WHEN code not found (case-insensitive) THEN return (False, "Coupon code not found")
- WHEN coupon has expired THEN return (False, "Coupon has expired")
- OTHERWISE return (True, matching_coupon)
**TESTS:**
- `validate_coupon('SAVE10', [...], '2025-01-15')[0] == True`
- `validate_coupon('', [], '2025-01-15')[0] == False`
Both formats contain the same information. The AI treats them identically.
When a user describes what they need in plain language, generate a RUNE spec.
Map each business rule to a WHEN/THEN clause in BEHAVIOR
Derive CONSTRAINTS from input descriptions (“must be positive”, “between 0 and 100”)
Derive EDGE_CASES from boundaries (empty input, zero, max value, invalid types)
Write TESTS that verify each BEHAVIOR rule plus edge cases. Minimum 3, aim for 8-15.
Ask the user which format they want (YAML .rune file or Markdown section). If unclear, default to the same format used elsewhere in their project.
When asked to validate a spec, or before presenting one you generated, check:
When given a RUNE spec (in either format) to implement, generate code that follows it exactly.