Rota
<h1 align="center">Rota</h1>
<p align="center">
<strong>Whose turn is it on your machine?</strong><br>
A local gatekeeper that lets coding agents and scripts share one machine
without fighting over CPU, memory and GPU, and without taking it over when you need it.
</p>
<p align="center">
<a href="https://github.com/psardana/rota/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/psardana/rota/actions/workflows/ci.yml/badge.svg"></a>
<a href="https://github.com/psardana/rota/releases/latest"><img alt="Latest release" src="https://img.shields.io/github/v/release/psardana/rota"></a>
<img alt="macOS 14+" src="https://img.shields.io/badge/macOS-14%2B-black">
<img alt="Linux" src="https://img.shields.io/badge/Linux-systemd-black">
<img alt="Go 1.27" src="https://img.shields.io/badge/Go-1.27-00ADD8">
<img alt="SQLite" src="https://img.shields.io/badge/storage-SQLite-003B57">
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-blue"></a>
<img alt="Runs locally" src="https://img.shields.io/badge/runs-100%25%20local-2ea44f">
</p>
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/images/load-dark.png">
<img alt="The Rota dashboard: a CPU forecast for the next 16 hours, with each job as a coloured band kept under the limit line" src="docs/images/load-light.png" width="860">
</picture>
</p>
<p align="center">
<a href="#see-it-in-action">Demo</a> ·
<a href="#why-rota">Why</a> ·
<a href="#how-it-works">How it works</a> ·
<a href="#install">Install</a> ·
<a href="#connect-your-agents">Connect your agents</a> ·
<a href="#quick-start">Quick start</a> ·
<a href="#instructions-for-coding-agents">Agent instructions</a> ·
<a href="#enforcer-mode-optional">Enforcer mode</a> ·
<a href="#linux">Linux</a> ·
<a href="#architecture">Architecture</a> ·
<a href="#faq">FAQ</a> ·
<a href="#contributing">Contributing</a>
</p>
## See it in action
<p align="center">
<img alt="Blocking the next two hours in the Rota dashboard: running jobs are asked to pause, waiting jobs move to after the block, and the week view shows the new plan" src="docs/images/rota-demo.gif" width="860">
</p>
| Week plan | Menu bar |
| --- | --- |
| <img alt="The Week view: every project's bookings for the next seven days, with blocked time hatched" src="docs/images/week-light.png" width="560"> | <img alt="The menu bar app: load, warnings, what runs next and a Block next hour button" src="docs/images/menubar-light.png" width="260"> |
| Jobs | My time |
| --- | --- |
| <img alt="The Jobs view: each job with its trigger, needs, priority and answer" src="docs/images/jobs-light.png" width="420"> | <img alt="The My time view: blocked time on a calendar" src="docs/images/mytime-light.png" width="420"> |
The dashboard has Light, System and Dark themes.
## Why Rota
You run Claude Code in one repo, Codex in another, a nightly test suite and a
video render. Each one assumes it has the whole machine. They start at the same
time, the fans spin up, everything slows down, and the end-to-end tests time out
in the middle of your video call.
Rota gives the machine a schedule:
- **Agents ask before they start.** Rota answers *go* or *wait until 10:10*.
- **Your time wins.** Block an hour and running jobs are asked to wrap up first.
- **Higher priority goes first**, and lower jobs slip in only where they fit.
- **Projects book known work a week ahead**, so there are fewer surprises.
- **Usage limits are tracked.** Rota warns when a job may run out of a tool's
quota. It warns only and never holds a job back.
By default Rota is a **gatekeeper, not a runner**. It never starts, pauses or
kills a process. Each agent runs its own job and checks in. That keeps Rota
small, and it works with any tool that can run a shell command.
If you want Rota to hold jobs to the plan itself, turn on the optional
[enforcer mode](#enforcer-mode-optional). Rota then runs plain commands through
pueue and can pause, resume or stop them, and hooks let live agent sessions wrap
up and resume around your time.
**Platforms:** macOS and [Linux](#linux).
## How it works
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/images/rota-agent-loop-dark.png">
<img alt="Sequence diagram: an agent announces a job, asks and is told to wait until 10:10, later gets a go, checks in every few minutes, and is told to wrap up by 14:00 when you block 14:00 to 16:00; it then reports done or paused" src="docs/images/rota-agent-loop.png" width="860">
</picture>
</p>
This is the default mode: Rota only answers, and the agent starts and stops its
own work. With the optional [enforcer mode](#enforcer-mode-optional), Rota
starts, pauses and resumes plain commands itself.
Every answer is also an exit code, so a shell script can act on it without
parsing output:
| Answer | Exit code | What the agent does |
| ------------------ | :-------: | ---------------------------------------------------- |
| `go` | `0` | Start now. |
| `wait until 10:10` | `75` | Ask again later. `rota wait` does this for you. |
| `continue` | `0` | Keep going. |
| `wrap up by 14:00` | `10` | Stop at a safe point by then, then `rota done ID --paused`. |
| `pause` | `11` | Stop at the next safe point, then `rota done ID --paused`. |
An answer takes into account:
- **Triggers.** A job can run at a time (`--at`), on a schedule
(`--cron "0 2 * * *"`), only inside a window (`--window 22:00-06:00@mon,tue`),
or only once the machine has been idle for a while (`--idle 10m`). With no trigger
it is due as soon as it is announced.
- **Priority.** `low`, `normal`, `high` or `urgent`. When a higher job has waited
too long (10 minutes by default), lower running jobs are asked to wrap up.
- **Resources.** Each job estimates its cores, memory, GPU share and run time.
Rota counts both what jobs declared and what the machine is really using, and keeps
the total under your limit (85% of the CPU and all but 4 GB of memory by
default).
- **Your blocked time.** The machine is open to jobs around the clock until you
block time. A job that would run into your time waits until after it.
## Install
**One line** (macOS 14+ on Apple silicon or Intel, or Linux with systemd):
```sh
curl -fsSL https://raw.githubusercontent.com/psardana/rota/main/install.sh | sh
```
It downloads the latest release, checks its checksum, puts `rota` in
`~/.local/bin`, starts the background service (launchd or systemd) and, on
macOS, adds the menu bar app to `~/Applications`. Read
[install.sh](install.sh) first if you like; it is short.
**Homebrew:**
```sh
brew tap psardana/rota https://github.com/psardana/rota
brew install rota
rota service install
```
**Go:** `go install github.com/psardana/rota/cmd/rota@latest`, then
`rota service install`.
**From source** (Go 1.27 or later; no C compiler needed, the SQLite driver is
pure Go; on macOS also the Xcode command line tools for the menu bar app):
```sh
git clone https://github.com/psardana/rota.git
cd rota
make install
```
`make install` builds `rota` into `~/.local/bin`, registers the daemon with
launchd so it runs in the background and starts at login, and puts the menu
bar app in `~/Applications`. On Linux it sets up a systemd user service and a
tray icon instead; see [Linux](#linux).
Then open the dashboard at http://127.0.0.1:7420:
```sh
rota open
```
To remove everything, run `rota service uninstall` and delete `rota` (or
`make uninstall` from a source checkout). Your data stays in
`~/Library/Application Support/Rota`.
## Connect your agents
Rota speaks [MCP](https://modelcontextprotocol.io), so agents can announce,
ask, check in and book work as tool calls (`rota_announce`, `rota_ask`,
`rota_checkin`, `rota_done`, `rota_book`, `rota_week`, `rota_status`,
`rota_cancel`) instead of shell commands.
**Claude Code:** install the plugin. It adds the MCP tools, a skill that tells
the agent when to use them, and the [hooks](#enforcer-mode-optional) that
route heavy commands and wrap sessions up before your blocked time.
```text
/plugin marketplace add psardana/rota
/plugin install rota@rota
```
Or add only the MCP server: `claude mcp add rota -- rota mcp`.
**Codex:** `codex mcp add rota -- rota mcp`
**Gemini CLI:** `gemini mcp add rota rota mcp`
**OpenCode:** add this to `opencode.json`:
```json
{ "mcp": { "rota": { "type": "local", "command": ["rota", "mcp"], "enabled": true } } }
```
Any other MCP client: run `rota mcp` as a stdio server. Tools that can't
use MCP use the CLI below, and every agent follows Rota best with the
[instructions for coding agents](#instructions-for-coding-agents).
## Quick start
### For agents and scripts
Wrap any heavy job in four steps.
1. **Announce the job.** Rota prints the job's id.
```sh
id=$(rota add --name "refactor checkout flow" --est 90m --cpu 3 --ram 6)
```
2. **Wait for a go.** This returns when it is the job's turn.
```sh
rota wait "$id"
```
3. **Check in every few minutes while it runs.** Exit code `0` means keep going.
`10` (wrap up) or `11` (pause) means stop at a safe point and run
`rota done "$id" --paused`.
```sh
rota checkin "$id"
```
4. **Say when it is done.** Add `--failed` if it failed.
```sh
rota done "$id"
```
Priority, the tool's name, usage-limit estimates and JSON output are all options
on `rota add`. See the [CLI reference](docs/cli.md). To have coding agents do this
on their own, give them the [instructions for coding agents](#instructions-for-coding-agents).
### Booking the week ahead
1. **Book a one-off job** at a set time.
```sh
rota book --project web-app --name "e2e suite" --at "wed 23:00" --est 1h
```
2. **Book repeating work** with a cron schedule.
```sh
rota book --project api-server --name "nightly e2e" --cron "0 2 * * *" --est 40m
```
3. **See every project's next 7 days.**
```sh
rota week
```
If a slot is taken, Rota books the nearest free one and says so. Booked work goes
before ad-hoc work of the same priority.
### For you
| Command | What it does |
| ------------------------ | --------------------------------------------- |
| `rota open` | Opens the dashboard. |
| `rota status` | Shows the load now and what runs next. |
| `rota block add --for 2h`| Keeps the machine to yourself for two hours. |
| `rota feed` | Shows what Rota decided, and why. |
Every command and option is in the [CLI reference](docs/cli.md), or run `rota help`.
## Instructions for coding agents
Agents follow Rota best when every project tells them to. Paste this into your
agent's global instructions file, and change the defaults to suit you:
````markdown
## Heavy work goes through Rota
This machine is shared by several agents and by me. Rota (`rota help`) decides
whose turn it is. Anything heavy, such as browser or UI tests, renders, video
or audio work, model runs, benchmarks, large migrations or long agent runs,
must go through Rota. Ordinary builds and unit test suites are not heavy and
run as they are.
- **Book known work a week ahead.** Recurring or planned jobs for this project
go in with `rota book --project <project> --name "<what>" --at "<time>"` or
`--cron "<schedule>"`, with `--est`, `--cpu` and `--ram` estimates. Check the
plan with `rota week --project <project>`.
- **Announce ad-hoc jobs and wait for a go.** Run
`id=$(rota add --name "<project>: <what>" --est <time> --cpu <cores> --ram <GB>)`,
then `rota wait "$id"`. Never start heavy work before Rota says go.
- **Check in while running.** Run `rota checkin "$id"` every few minutes. Exit
code 0 means continue. 10 means wrap up by the time given, and 11 means pause.
- **Stop cleanly when told.** On wrap up or pause, reach a safe point, save
your state, run `rota done "$id" --paused` and tell me where you stopped.
Otherwise, finish with `rota done "$id"`, or `--failed --note "<why>"`.
- **My blocked time always wins.** Never work around a wait, a wrap up or a
pause, and never change my blocks or priorities yourself.
- **Prefer enforcement for plain commands.** Run heavy commands with
`rota run --enforce --name "<project>: <what>" --est <time> -- <command>`, so
Rota can pause and resume them. If this tool has Rota hooks installed, let the
hooks route heavy commands and follow what they say.
- **Ask when unsure.** If you can't tell whether something is heavy, or Rota's
answer seems wrong, ask me instead of guessing.
````
Where each tool reads global instructions:
| Tool | File |
| ----------- | -------------------------------------------------------------------------------------- |
| Claude Code | `~/.claude/CLAUDE.md` for every project, or `CLAUDE.md` in a repo |
| Codex | `~/.codex/AGENTS.md` for every project, or `AGENTS.md` in a repo |
| OpenCode | `~/.config/opencode/AGENTS.md` for every project, or `AGENTS.md` in a repo |
| Gemini CLI | `~/.gemini/GEMINI.md` for every project, or `GEMINI.md` in a repo |
Instructions are a request, not a guarantee. For Claude Code, the
[hooks](#enforcer-mode-optional) route heavy commands through Rota even when
the agent forgets.
## Enforcer mode (optional)
Rota is a gatekeeper by default: it answers, and jobs run themselves. Enforcer
mode is for when you want Rota to really hold the reins. It is built on
[pueue](https://github.com/Nukesor/pueue), which you install yourself (Rota
never installs it):
```sh
brew install pueue
brew services start pueue
```
Then check that Rota can reach it:
```sh
rota enforce
```
**Plain commands** opt in one at a time:
```sh
rota run --enforce --name "api-server: full test suite" --est 40m --cpu 6 --ram 8 -- make test-all
```
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/images/rota-enforcer-dark.png">
<img alt="Sequence diagram of enforcer mode: rota run --enforce hands the command to Rota, which holds it in pueue, starts it when the plan says go, pauses it at 14:00 when you block 14:00 to 16:00, resumes it at 16:00, and rota run exits with the command's own status" src="docs/images/rota-enforcer.png" width="860">
</picture>
</p>
Rota holds the command in pueue's `heavy` group (with a parallel limit, set
under Settings) and starts it when the plan says go. When your blocked time
or a higher-priority job needs the machine, Rota pauses it there and then, and
resumes it later. A paused command keeps its memory, so Rota keeps counting it
as taken. `rota run` shows the output and exits with the command's own status.
`--detach` returns at once, and `rota logs ID [--follow]` shows the output,
which Rota keeps after the run ends. Cancelling an enforced job stops it.
Commands that send work outside their process group (`nohup`, `setsid`,
`docker run`, a trailing `&`) are flagged as not fully enforceable, because
pausing or stopping them would miss those processes.
**Live agent sessions are never frozen.** Instead, hooks let them work with
Rota. Claude Code is the first tool supported. The
[Claude Code plugin](#connect-your-agents) brings the hooks with it. Without the
plugin, this adds them to `~/.claude/settings.json` and keeps a `.bak` copy. Use
`rota hooks print claude-code` to see them first.
```sh
rota hooks install claude-code
```
With the hooks in place, each session shows up as a job. Heavy commands it
runs (browser and UI tests, renders and other media or model work; see the
built-in list in `internal/enforce/classify.go`, or set your own patterns) go
through `rota run --enforce`. Builds and unit tests run as they are. A heavy
command that would run into your blocked time is turned away with the reason,
so the agent can do something else. Before your
time starts, the session is told to reach a safe stopping point and end its
turn. Afterwards, Rota resumes it with the tool's resume command
(`claude --resume <session> -p …`) through pueue. The hooks keep Claude Code's
normal permission checks. Set `ROTA_HOOK_DECISION=ask` to have every rerouted
command shown to you first.
**Backstop:** if a session is still working a few minutes after its wrap-up
time (5 by default), Rota stops the session's heavy child processes (busy
CPU or large memory), never the agent itself, and tells you which ones.
## Linux
Rota runs on Linux with systemd (Ubuntu, Debian, Fedora, Arch and most others).
The [one-line install](#install) works there too. From a source checkout:
```sh
make install
```
Either way, `rota` goes into `~/.local/bin`, with a systemd user service
(`~/.config/systemd/user/rota.service`) that starts at login, adds a "Rota"
launcher that opens the dashboard, and starts the tray icon now and at login.
To keep Rota running from boot on a machine nobody logs in to, run
`loginctl enable-linger` once.
What Rota reads on Linux:
| | Source |
|---|---|
| CPU | `/proc/stat` |
| Memory | `/proc/meminfo` (total minus available) |
| GPU | `nvidia-smi` on NVIDIA, `gpu_busy_percent` on AMD; other GPUs are not measured |
| Idle time | GNOME's idle monitor, the freedesktop ScreenSaver service (KDE and others), or `xprintidle`. A machine with no desktop session counts as idle. If the desktop reports none of these, jobs that wait for idle time keep waiting and say why. |
| Notifications | the desktop's notification service over D-Bus (`gdbus`, or `notify-send`) |
The tray icon (`rota tray`) needs a panel that shows StatusNotifierItem icons:
KDE, Ubuntu, XFCE and Cinnamon do out of the box; stock GNOME needs the
AppIndicator extension. `rota tray --panel light` draws dark bars for a light panel.
Files live in `~/.local/share/rota` (database) and `~/.local/state/rota` (log).
GPU readings have been tested against sample output only. If you run Rota on
an NVIDIA or AMD machine, please report what `rota status` shows.
## Architecture
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/images/rota-architecture-dark.png">
<img alt="Architecture diagram: agents and scripts reach the Rota daemon on 127.0.0.1:7420 through the rota CLI, rota mcp or Claude Code hooks; the daemon keeps jobs, blocks and activity in SQLite, reads the machine's CPU, RAM and GPU, serves the dashboard and menu bar, and can drive pueue in optional enforcer mode" src="docs/images/rota-architecture.png" width="860">
</picture>
</p>
| Path | What lives there |
| ------------------- | --------------------------------------------------------------------- |
| `cmd/rota` | The `rota` command, the launchd and systemd service setup, and the Linux tray. |
| `internal/gate` | The decision engine. It plans the coming hours and answers each job. Pure Go, no I/O. |
| `internal/server` | The daemon: HTTP API, background loop and booking logic. |
| `internal/store` | SQLite storage for jobs, blocked time, readings and the feed. |
| `internal/sysinfo` | CPU, memory, GPU and idle readings, for macOS and Linux. |
| `internal/enforce` | Optional enforcer mode: the pueue backend and agent session hooks. |
| `internal/platform` | Where Rota keeps its files on each operating system. |
| `internal/cronexpr` | A small cron expression parser. |
| `internal/notify` | Desktop notifications on macOS and Linux. |
| `web/` | The dashboard: plain HTML, CSS and JavaScript, built into the binary. |
| `macos/` | The SwiftUI menu bar app. |
| `linux/` | Desktop launcher files for Linux. |
### Built on
- Go's standard library for the daemon, the API and the command line.
- [SQLite](https://sqlite.org) through the pure-Go driver
[`modernc.org/sqlite`](https://pkg.go.dev/modernc.org/sqlite), so no C compiler is needed.
- launchd on macOS and a systemd user service on Linux to keep the daemon running.
- The system's own tools for readings: `sysctl`, `ps`, `vm_stat` and `ioreg` on
macOS, `/proc` on Linux.
- SwiftUI for the macOS menu bar app and [`fyne.io/systray`](https://github.com/fyne-io/systray)
for the Linux tray.
- [pueue](https://github.com/Nukesor/pueue), only if you opt in to enforcer mode.
### Security
Rota listens only on `127.0.0.1`, answers only requests addressed to this machine,
and refuses changes that come from other web pages. Nothing leaves your machine.
To report a vulnerability, see [SECURITY.md](SECURITY.md).
## FAQ
**Why not `nice`, cgroups or systemd slices?** Those share the CPU among
processes that are already running. Rota decides whether a job should start at
all, and when it should stop, based on memory, the GPU, your blocked time and
priorities. Memory is the main reason: two jobs that each need 10 GB on a 16 GB
machine don't just get slower under `nice`, they swap or get killed. You can
still run a job Rota let through under `nice`.
**Why not just a job queue like pueue?** A queue runs commands for you. An
agent session isn't one command: it runs many and has to stop at a sensible
point, which the agent knows better than a scheduler. So by default Rota only
answers. For plain commands, [enforcer mode](#enforcer-mode-optional) does use
pueue underneath.
**What stops an agent from ignoring Rota?** In the default mode, nothing: it's a
request, like the [instructions](#instructions-for-coding-agents) you give it.
For Claude Code, the hooks send heavy commands through Rota even when the agent
forgets, turn away a heavy command that would run into your blocked time, and,
a few minutes past a wrap-up time, stop the session's heavy child processes
(never the agent itself).
**Does it work with my tool?** Anything that speaks MCP can use `rota mcp`, and
anything that can run a shell command can use the CLI and its exit codes.
**Windows?** Not yet. macOS 14+ and Linux with systemd.
## Roadmap
- **A dedicated job machine.** Run Rota on an always-on Mac mini that does the
heavy work while your laptop stays free.
- **More agent hooks** beyond Claude Code, for tools that offer them.
- **GPU readings confirmed on real NVIDIA and AMD machines**, and **Windows** support.
Ideas and opinions are welcome in [issues](../../issues).
## Contributing
Contributions are welcome, from a typo fix to a new platform. Start with
[CONTRIBUTING.md](CONTRIBUTING.md), and look at
[good first issues](docs/good-first-issues.md) if you want somewhere easy to
begin. Please follow the [code of conduct](CODE_OF_CONDUCT.md).
## License
Rota is released under the [MIT License](LICENSE).
TDQS
Scored across 8 tools
Most tools map to distinct lifecycle stages (announce → ask → checkin → done, plus book/cancel). The only real overlap is rota_announce vs rota_ask (both return GO/WAIT) and rota_status vs rota_week (both report load/bookings), but the descriptions clarify that announce registers a new job while ask re-queries an already-announced one, and that status is 'now' versus week being 7 days out.
All eight tools share a predictable rota_<suffix> snake_case pattern with single-word suffixes. Minor deviation: suffixes mix verbs (ask, announce, book, cancel, done, checkin) with nouns (status, week), though the noun forms consistently denote read-only queries.
Eight tools is well within the sweet spot and each maps to a necessary step in the announce-run-finish scheduling workflow. Nothing appears redundant or padded.
The job lifecycle is fully covered: announce, re-ask, periodic checkin, completion reporting, booking, cancellation, and two views of load/plan. Minor gaps: no way to inspect or amend an existing booking (must cancel and rebook) and no per-job detail/history lookup, but agents can work around these.