Creating Custom Routines
Routines are periodic maintenance tasks with a frequency. You can create custom routines alongside catalog-provided ones.
How It Works
Section titled “How It Works”- Create a file in
agent/Routines/(e.g.,agent/Routines/branch-cleanup.md) - Add YAML frontmatter with
descriptionandfrequency - Run
bonsai update— it detects untracked files and offers to track them - Once tracked, custom routines appear in CLAUDE.md,
.bonsai.yaml, and the routine dashboard
Frontmatter Format
Section titled “Frontmatter Format”Routines need a frequency field:
---description: Review and clean up stale feature branchesdisplay_name: Branch Cleanupfrequency: 14 days---
# Branch Cleanup
**Frequency:** Every 14 days
1. **List stale branches:** - Run `git branch --merged` to find branches already merged ...| Field | Required | Notes |
|---|---|---|
description | Yes | Shown in CLAUDE.md nav tables |
display_name | No | Human-readable name |
frequency | Yes | How often to run (e.g., 5 days, 7 days, 14 days) |
File Naming
Section titled “File Naming”- Use kebab-case for filenames:
branch-cleanup.md, notBranchCleanup.md - The filename (minus extension) becomes the item’s machine name
- Use
.mdextension
The Routine Dashboard
Section titled “The Routine Dashboard”Custom routines are automatically added to the routine dashboard at agent/Core/routines.md. The dashboard tracks:
- When the routine last ran
- When it’s next due
- Whether it’s overdue
The routine-check sensor reads this dashboard at session start and flags overdue routines.
What bonsai update Does for Routines
Section titled “What bonsai update Does for Routines”When you run bonsai update with custom routines:
- Detects untracked
.mdfiles inagent/Routines/ - Validates frontmatter — warns if
frequencyis missing - Tracks in
.bonsai.yamland.bonsai-lock.yaml - Updates the routine dashboard at
agent/Core/routines.md - Refreshes CLAUDE.md nav tables