Skip to content

Creating Custom Routines

Routines are periodic maintenance tasks with a frequency. You can create custom routines alongside catalog-provided ones.

  1. Create a file in agent/Routines/ (e.g., agent/Routines/branch-cleanup.md)
  2. Add YAML frontmatter with description and frequency
  3. Run bonsai update — it detects untracked files and offers to track them
  4. Once tracked, custom routines appear in CLAUDE.md, .bonsai.yaml, and the routine dashboard

Routines need a frequency field:

---
description: Review and clean up stale feature branches
display_name: Branch Cleanup
frequency: 14 days
---
# Branch Cleanup
**Frequency:** Every 14 days
1. **List stale branches:**
- Run `git branch --merged` to find branches already merged
...
FieldRequiredNotes
descriptionYesShown in CLAUDE.md nav tables
display_nameNoHuman-readable name
frequencyYesHow often to run (e.g., 5 days, 7 days, 14 days)
  • Use kebab-case for filenames: branch-cleanup.md, not BranchCleanup.md
  • The filename (minus extension) becomes the item’s machine name
  • Use .md extension

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.

When you run bonsai update with custom routines:

  1. Detects untracked .md files in agent/Routines/
  2. Validates frontmatter — warns if frequency is missing
  3. Tracks in .bonsai.yaml and .bonsai-lock.yaml
  4. Updates the routine dashboard at agent/Core/routines.md
  5. Refreshes CLAUDE.md nav tables