Shepherd - Autonomous Pipeline Monitor
Tends long-running pipelines (snakemake, nextflow) using a sense-think-act loop. Detects errors, recalls fixes from memory, restarts automatically, checkpoints progress.
Quick Commands
/shepherd <command> [--interval=60] [--max-restarts=3] # Start monitoring
/shepherd status # Check shepherd status
/shepherd stop # Stop monitoring
Configuration
| Flag | Default | Description |
|------|---------|-------------|
| --interval | 60 | Seconds between sense cycles |
| --max-restarts | 3 | Max automatic restarts before escalating |
| --notify | true | Send notifications on events |
| --auto-fix | true | Attempt automatic fixes from memory |
| --session | auto | Target session: "auto", "current", or session name |
| --isolate | auto | Session isolation: "auto", "yes", "no" |
--isolate=auto picks isolation by job type (SLURM/remote-SSH/multiple parallel
pipelines get an isolated session; quick local or interactive jobs don't). Read
reference/configuration.md before implementing this decision — it has the full
condition table and the shouldIsolate logic.
Core Workflow
- Initialize — load the
zellij_mcp/chittatools viaToolSearch, check for an existinglong_taskto resume, decide session isolation, create the monitoring pane, and launch the pipeline. - Sense — tail the pane, check for idle/stall, search for error patterns.
- Think — match sensed output against known habits and pattern libraries; decide to apply a habit, restart, fix from memory, checkpoint, or escalate.
- Act — execute the decision: restart the command, apply a fix, log an event, notify, or mark the task complete/paused.
- Main loop — repeat sense/think/act on
--interval, with a pre-flighthealth_checkand session-liveness check each cycle, until done or paused.
Read reference/initialize-and-loop.md before implementing any of the steps
above — it has the full pseudocode, including every mcp__zellij_mcp__* and
mcp__chitta__* call.
Read reference/patterns-and-tools.md for known snakemake/nextflow error
signatures, the expected status-line output format, and the full MCP tool list.
Read reference/resume-protocol.md when resuming a shepherd task after a
disconnect or session restart.
Anti-Patterns
- Never poll faster than 30 seconds (wastes resources)
- Never restart without checkpointing first
- Never exceed max_restarts without escalating
- Never ignore repeated errors (they compound)
- Never fix without logging (lose learnings)
Dashboard
/shepherd dashboard opens an interactive control center across all active
shepherd tasks — view task details or pane output, restart/stop/escalate a
pipeline, or view learned habits. Read reference/dashboard.md for the full
implementation before building or running it.