Playbooks are Markdown files that describe recovery procedures. They compile to the same RecoveryPlan structure used by code-based agents, with the same safety infrastructure — blast radius validation, approval gates, state preservation, and forensic recording.
A playbook is a .md file with two parts:
- YAML frontmatter — Metadata: name, version, description, triggers, requirements.
- Markdown body — Numbered H3 headings, each describing one recovery step.
Playbooks are discovered from three locations:
~/.crisismode/playbooks/(user)./playbooks/(project)$CRISISMODE_PLAYBOOK_PATHenvironment variable
The frontmatter block is delimited by --- lines at the top of the file.
| Field | Type | Description |
|---|---|---|
name |
string | Unique playbook identifier |
version |
string | Semver version |
description |
string | What this playbook recovers |
| Field | Type | Description |
|---|---|---|
agent |
string | Which agent this playbook targets |
provider |
string | Cloud provider (aws, gcp, azure) |
severity |
string | Default risk level: routine, elevated, high, critical |
triggers |
array | Alert conditions that activate this playbook |
requires |
object | Execution contexts and tools needed |
tags |
array | Searchable tags |
author |
string | Author name or email |
estimated_duration |
string | ISO 8601 duration (e.g., 30m, PT15M) |
triggers:
- alert: pg_replication_lag_seconds
condition: "> 300"
duration: 5mrequires:
contexts:
- type: database_read
target: primary
- type: database_write
target: primary
tools:
- psql
- pg_basebackupEach step is an H3 heading with a number and title, followed by properties and an optional body.
### 1. Step title here
- type: diagnosis_action
- description: What this step does
- target: primary
Optional prose description or notes.Properties use - key: value syntax. Available properties vary by step type:
| Property | Used By | Description |
|---|---|---|
type |
All | Step type (required) |
description |
All | Human-readable explanation |
target |
system_action, diagnosis_action | Target system identifier |
execution_context |
system_action, diagnosis_action | Named execution context |
risk |
system_action | Risk level: routine, elevated, high, critical |
capability |
system_action | Comma-separated registered capability ids (required by the validator) |
preserve |
system_action | Comma-separated state-capture names (required for elevated+ risk) |
precondition |
system_action | Condition that must be true before execution |
success |
system_action | Condition that must be true after execution |
channel |
human_notification | Notification channel (pagerduty, slack, default) |
message |
human_notification | Notification message text |
template |
human_notification | Named message template |
timeout |
human_approval, replanning_checkpoint | How long to wait |
escalation |
human_approval | Who to escalate to on timeout |
condition |
conditional | Boolean expression to evaluate |
on_success |
conditional | Action if condition is true |
on_failure |
conditional | Action if condition is false |
- blast_radius:
max_affected_rows: 0
max_downtime_seconds: 30
requires_maintenance_window: trueRead-only data gathering. Use for initial assessment, replication status queries, health checks. Include a code block with the diagnostic command.
Alert stakeholders. Set channel and message. No commands are executed.
Capture system state before mutations. The framework snapshots the configured targets for rollback and audit.
Execute a command that mutates system state. Must declare risk and capability; at elevated risk or higher must also declare preserve (state captured before the step runs, blocking on failure). Should have precondition, success, and blast_radius. Include a code block with the command. crisismode playbook validate runs the compiled plan through the same safety validator as code-based agents and reports exactly which rule a step violates.
Pause execution until a human approves. Set timeout and escalation. The body text is shown to the approver as context.
Allow the agent to re-evaluate and potentially revise the remaining plan. Set timeout.
Branch based on system state. Set condition, on_success, and on_failure.
Fenced code blocks with language tags specify the commands to execute:
### 4. Disconnect lagging replica
- type: system_action
- risk: elevated
```sql
SELECT pg_terminate_backend(pid)
FROM pg_stat_replication
WHERE client_addr = '{target.replica.host}';
```Supported language tags: sql, sh, bash, yaml, json. The language tag determines how the command is interpreted by the execution backend.
Use curly braces to reference diagnosis data and target configuration:
{diagnosis.lag_seconds}— Value from diagnosis findings{target.replica.host}— Target system address{target.primary.port}— Target system port
Variables are resolved at plan compilation time from the active agent context.
Validate a playbook without executing it:
crisismode playbook validate path/to/playbook.mdThis parses the frontmatter, validates required fields, parses all steps, and compiles the playbook to a RecoveryPlan. Errors are reported with the field name and reason.
For machine-readable output:
crisismode playbook validate path/to/playbook.md --jsonPreview the compiled recovery plan:
crisismode playbook dry-run path/to/playbook.mdThis shows each step with its type, risk level, and name. Use --json for the full plan as structured JSON.
See all playbooks CrisisMode can find:
crisismode playbook listAdd a ## Rollback section at the end of your playbook to describe the rollback procedure:
## Rollback
If replica resync fails:
1. Restore read traffic to remaining healthy replicas
2. Page the DBA team with the forensic record
3. Do NOT attempt a second resync without human approvalThe rollback section is captured as free-text and included in the compiled plan's rollback strategy.
---
name: "redis-memory-pressure"
version: "1.0.0"
description: "Recovery for Redis memory pressure exceeding maxmemory"
agent: redis
severity: elevated
triggers:
- alert: redis_memory_usage_ratio
condition: "> 0.9"
duration: 5m
tags:
- redis
- memory
author: "sre-team"
estimated_duration: "15m"
---
# Redis Memory Pressure Recovery
### 1. Assess memory usage
- type: diagnosis_action
- target: redis-primary
```sh
redis-cli info memory- type: human_notification
- channel: slack
- message: "Redis memory at {diagnosis.used_memory_ratio}%"
- type: checkpoint
- type: system_action
- risk: routine
- target: redis-primary
- precondition: "Redis is accepting commands"
- success: "Memory usage below 85%"
redis-cli --scan --pattern '*' | head -1000 | xargs redis-cli unlink- type: conditional
- condition: "memory_usage_ratio < 0.85"
- on_success: "Memory pressure resolved"
- on_failure: "Escalate to team for maxmemory tuning"
If eviction causes cache miss storms:
- Monitor hit rate for 5 minutes
- If hit rate drops below 80%, alert the application team
For more playbook examples, see the `playbooks/examples/` directory.