Metadata-Version: 2.5
Name: rc-shepherd
Version: 0.6.1
Summary: Keep Claude Code Remote Control servers running for your projects (unofficial), so you can pick them up from the Claude app at any time.
Project-URL: Homepage, https://github.com/herbalizer404/rc-shepherd
Project-URL: Changelog, https://github.com/herbalizer404/rc-shepherd/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/herbalizer404/rc-shepherd/issues
Project-URL: Security, https://github.com/herbalizer404/rc-shepherd/security/policy
License-Expression: MIT
License-File: LICENSE
Keywords: claude,claude-code,remote-control,self-hosted,supervisor,systemd
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: coverage>=7.5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# rc-shepherd

**Keep your Claude Code projects one tap away on your phone.** rc-shepherd keeps a [Remote Control](https://code.claude.com/docs/en/remote-control) server running for every project you work on, so you can start or resume sessions from the Claude mobile app, Claude desktop or claude.ai/code at any time, without SSH-ing into the machine to type `claude rc` in tmux.

[![CI](https://github.com/herbalizer404/rc-shepherd/actions/workflows/ci.yml/badge.svg)](https://github.com/herbalizer404/rc-shepherd/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/herbalizer404/rc-shepherd)](https://github.com/herbalizer404/rc-shepherd/releases)
![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)
![Coverage 100%](https://img.shields.io/badge/coverage-100%25-brightgreen)
![No dependencies](https://img.shields.io/badge/dependencies-none-brightgreen)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/herbalizer404/rc-shepherd/blob/main/LICENSE)

> **Unofficial.** rc-shepherd is an independent community project. It is not affiliated with, endorsed by or supported by Anthropic. It runs the official, unmodified Claude Code CLI; "Claude" and "Claude Code" are trademarks of Anthropic.

It is meant for people who work on their own headless Linux machines (a home server, a VPS, a workstation you reach over SSH). One small supervisor, a single systemd user service with no dependencies, follows Claude Code itself: every project you trusted and used with `claude` gets its own `claude remote-control` server, kept alive across crashes, reboots, logouts and Claude Code updates.

- **Zero setup per project**: open a folder with `claude` once, and it shows up in the app within a minute.
- **Self-healing**: crashed servers restart with backoff; an expired login is reported instead of retried every few seconds.
- **Update-aware**: after a Claude Code update, each server moves to the new version once its sessions are idle.
- **Stays out of your way**: servers you start by hand are left alone, and option changes never interrupt a session unless you ask for it.
- **Tunable**: permission mode, spawn mode (`same-dir` or one git worktree per session), capacity and filters, globally or per project.

```
$ rc-shepherd status
supervisor pid 272732 · config ~/.config/rc-shepherd/config.toml
api                      · running · pid 275126 · up 3h 12m · 0 restart(s)
web                      · running · pid 272734 · up 3h 12m · 1 restart(s)

$ rc-shepherd list
skip   /home/me  (home folder: Claude Code never saves its trust, so Remote Control cannot run there)
serve  /home/me/code/api  (has Claude sessions)
serve  /home/me/code/web  (has Claude sessions)
skip   /home/me/code/demo  (untrusted: run `claude` there once)
```

## Requirements

- Linux with systemd (user services), Python 3.11+
- [Claude Code](https://code.claude.com) logged in with a Claude subscription that includes Remote Control
- Lingering enabled so the service survives logouts: `sudo loginctl enable-linger "$USER"`

## Install

```bash
curl -fsSL https://raw.githubusercontent.com/herbalizer404/rc-shepherd/main/install.sh | sh
```

The script installs rc-shepherd into its own virtual environment (`~/.local/share/rc-shepherd/venv`), links `rc-shepherd` into `~/.local/bin`, installs bash completion, asks before installing the user service, then runs `rc-shepherd doctor`. [Read it](https://github.com/herbalizer404/rc-shepherd/blob/main/install.sh) first if you prefer, or run it from a checkout:

```bash
git clone https://github.com/herbalizer404/rc-shepherd && sh rc-shepherd/install.sh
```

- Run it again to upgrade. It asks before restarting the service (that interrupts work in progress in its sessions); without a terminal it leaves the service running.
- Options: `--yes` (no questions), `--no-service`, `--ref TAG` (e.g. `--ref v0.4.1`, see [releases](https://github.com/herbalizer404/rc-shepherd/releases)), `--source SPEC` (any pip requirement: a checkout, a wheel, `git+ssh://git@github.com/herbalizer404/rc-shepherd.git` for a private copy).
- Uninstall: `sh install.sh --uninstall`, or `--uninstall --purge` to also remove the configuration and state.
- Without the script, from [PyPI](https://pypi.org/project/rc-shepherd/): `pipx install rc-shepherd` (or `uv tool install rc-shepherd`), then `rc-shepherd service install`.

## Quick start

```bash
rc-shepherd config init          # optional: writes a commented config file
rc-shepherd doctor               # checks claude, login, lingering, projects
rc-shepherd service install      # writes, enables and starts the user service (the installer offers it)
```

By default rc-shepherd follows Claude Code itself: every project anywhere in your home folder that Claude Code lists as **trusted** (`~/.claude.json`) and that already has **Claude sessions** is served, at any depth. Nothing else is: a folder you never opened with `claude` is ignored, and so are projects outside your home folder and folders inside hidden ones (such as the worktrees Claude Code keeps in `.claude/worktrees`). To add a project, open it once:

```bash
cd ~/code/my-app && claude       # accept the trust prompt, send a message, quit
rc-shepherd reload               # or wait up to a minute
rc-shepherd list                 # every candidate and why it is served or skipped
```

To serve fewer projects, narrow `roots` (e.g. `["~/projects"]`), set a `depth`, or use `allow`, `deny`, `active_within` and `max_servers`. To serve one outside your home folder, declare it: `rc-shepherd enable /srv/app`. The home folder itself is never served: Claude Code never saves its trust, so Remote Control refuses to run there. For sessions that are not tied to one project, open `claude` once in a folder such as `~/hub`: it is then served like any project.

Then open the Claude app: the project shows up as a Remote Control environment where you can start new sessions.

## Commands

| Command | Description |
| --- | --- |
| `status [--json]` | Servers run by the supervisor: pid, uptime, restarts, last error, pending option changes |
| `list [--json]` | Every candidate project and why it is served or skipped |
| `enable <path>` / `disable <path>` | Declare a project in the config (comments are kept, a `.bak` is written) |
| `restart <name\|path>` / `restart --all` | Restart servers, for example after updating Claude Code |
| `reload [--apply]` | Reload the config; `--apply` also restarts servers whose options changed |
| `config show\|check\|init` | Effective config as JSON, validation, example file |
| `doctor` | Checks the binary, login, lingering, service, projects, settings files and memory |
| `service install\|uninstall\|status\|logs [-f] [--all]` | Manage the systemd user service; `uninstall --purge` also removes the configuration and state |
| `completion bash\|zsh` | Print a shell completion script (the installer sets up bash) |
| `run [--dry-run]` | Run the supervisor in the foreground; `--dry-run` prints the server commands |

`--config FILE` works with every command (`service install --config FILE` bakes it into the unit).

## Configuration

`~/.config/rc-shepherd/config.toml`: every key is optional, unknown keys are rejected. See [`config.example.toml`](https://github.com/herbalizer404/rc-shepherd/blob/main/src/rc_shepherd/config.example.toml) for the full reference.

```toml
[discovery]
mode = "auto"                  # "auto" (Claude's projects below roots + [[project]]) or "list" ([[project]] only)
roots = ["~/projects", "~/work"]  # default ["~"]: the whole home folder
depth = 1                      # levels below each root (default 0 = any); also lists unknown folders
active_within = "30d"          # skip projects without a recent session (default: no limit)
allow = []                     # globs on the folder name, or the path if they contain "/"
deny = ["*-archive", "~/projects/sandbox"]
max_servers = 10               # the most recently active projects win

[defaults]
permission_mode = ""           # "" = this machine's Claude Code settings
spawn = "same-dir"             # or "worktree": one git worktree per new session
capacity = 32

[[project]]                    # served even outside roots and filters
path = "~/projects/api"
spawn = "worktree"
permission_mode = "acceptEdits"

[[project]]
path = "~/projects/legacy"
enabled = false                # declared but not served

[supervisor]
min_free_memory = "1GiB"
on_failure = "notify-send 'rc-shepherd' '{name}: {reason}'"
restart_on_update = "idle"     # or "off"
idle_after = "30m"             # how long sessions must be idle before that restart
```

Per-server options (`[defaults]`, overridable per `[[project]]`): `permission_mode`, `spawn`, `capacity`, `settings`, `chrome` (`""`, `"on"`, `"off"`), `name_template` (`{name}`, `{parent}`, `{host}`), `extra_args`, `env`, `allow_bypass`.

Option changes are applied when a server next starts, so a reload never interrupts your sessions unless you pass `--apply`.

## Permissions and security

- Leaving `permission_mode` empty keeps whatever your Claude Code settings say, exactly as if you had typed `claude rc` yourself. Approval prompts appear in the Claude app.
- `bypassPermissions` is refused unless the same table also sets `allow_bypass = true`, and `doctor` reports it.
- `settings` files are passed with `--settings`. Keep them outside the projects (sessions could edit them) and not writable by other users; `doctor` checks both.
- Sessions run on this machine with your user's rights. Anyone who can use your Claude account can use them.
- Servers run with the service's `PATH`, captured when you run `service install` (`--path` to override).
- See [SECURITY.md](https://github.com/herbalizer404/rc-shepherd/blob/main/SECURITY.md) for the security design and how to report a vulnerability.

## How it works

- Every `interval` (default 60s) and on `reload`, the projects listed in `~/.claude.json` below the roots are checked for trust there and for history in `~/.claude/projects/*/*.jsonl`. With a `depth` above 0, the folders found under the roots are listed too, so `list` can explain why they are skipped.
- Each served project gets `claude remote-control --spawn <mode> --capacity <n> --name <name> [...]` in its own process group. Output goes to the journal, once per line (the CLI redraws its screen in place).
- A server that exits is restarted after 5s, then 10s, 20s… up to 5 minutes. The delay resets after 10 minutes of healthy run. After `on_failure_after` failures in a row, `on_failure` runs once.
- A server that stops because the Claude login is missing or expired shows `login required` in `status` and `doctor`, is retried at the longest delay, and `on_failure` runs at once with `{reason}` = `login`.
- Each server remembers the Claude Code version it started with. After an update, `status` and `doctor` flag the servers still on the old one; with `restart_on_update = "idle"` (the default), each one restarts on the new version once its sessions are idle: none of them runs a command (a child process of the session) and none of their transcripts changed for `idle_after` (default 30 minutes). Idle sessions reattach on their own after the restart, so work in progress is never interrupted.
- If you run `claude rc` by hand in a served folder, the supervisor leaves it alone and takes over when it exits.
- Stopping the service stops every server (SIGTERM, then SIGKILL after `stop_timeout`). An invalid config at startup exits with code 78 and systemd does not loop.

## Limitations

- The machine must stay on: sessions run here, the apps only display them.
- Restarting a server interrupts the work in progress in its sessions. Remote Control keeps its environment, so existing sessions reattach on their own after the restart.
- An old session may refuse to reattach after a restart ("Session failed" in the logs): start a new session from the app.
- Running `service install`, `service uninstall` or `systemctl --user restart rc-shepherd` from a session served by the service ends that session too (it runs inside the unit). The CLI detects it, prints its report first and queues the restart without waiting.
- After a Claude Code update, a server whose sessions keep working keeps the old version until they pause for `idle_after`, or until you run `restart` (always with `restart_on_update = "off"`).
- Sessions run inside the service, so what their own programs log (`sudo`, `docker`…) lands in its journal too: `service logs` shows only rc-shepherd's lines, `service logs --all` everything.
- In `same-dir` mode, sessions of a project share one checkout; use `spawn = "worktree"` to isolate them.
- An idle server uses about 120-200 MB of RAM.
- If the Claude login expires, servers stay down (retried every `max` delay) until you log in again (`claude auth login`).
- Linux only for now (systemd and `/proc`). launchd support is welcome.

## Alternatives

- A few projects only: `claude rc` in tmux, or a hand-written systemd unit per project, may be enough.
- No need for your own machine, tools or network: Claude Code cloud sessions run on Anthropic's infrastructure and need no server at all.
- Claude Code may offer a native background service in the future; this tool would then become unnecessary.

## Usage and terms

You remain bound by Anthropic's terms ([Claude Code legal and compliance](https://code.claude.com/docs/en/legal-and-compliance), Consumer or Commercial Terms, Usage Policy). This tool is designed to stay within ordinary, individual use:

- It runs the official `claude` binary unmodified, signed in with **your own** account. It never reads, stores or forwards credentials or session tokens.
- It only keeps Remote Control available. It never sends prompts or drives sessions by itself: a person types every message from a Claude app.
- Do not use it to share your account, to serve other people through your subscription, or to run unattended agents on a Pro/Max plan (use an API key for automation).
- Subscription usage limits assume ordinary individual use of Claude Code.

## Development

```bash
python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/ruff check src tests
PYTHONSAFEPATH=1 .venv/bin/coverage run -m pytest && .venv/bin/coverage report   # 100% lines and branches
RC_SHEPHERD_INTEGRATION=1 .venv/bin/pytest tests/test_install_script.py           # full install.sh run (uses PyPI)
```

Tests use a fake `claude` executable and never start a real Remote Control server. See [CONTRIBUTING.md](https://github.com/herbalizer404/rc-shepherd/blob/main/CONTRIBUTING.md).

## License

[MIT](https://github.com/herbalizer404/rc-shepherd/blob/main/LICENSE)
