Skip to content
Back to skills

Remote Subagents

ASecurity

Run a subagent's brief on the remote backend (a cluster, Docker or an SSH host) instead of this machine, and act on its outcome. Use when a skill starts a subagent its needs.json declares remote-capable, or the human asks to run a brief remotely.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 27, 2026
ai-agentspythongoshelldockergitbackendsecurity

Works with

  • terminal

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add rpvsilva/dotagents --skill remote-subagents --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Remote Subagents?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Remote Subagents
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rpvsilva-remote-subagents/badge)](https://www.skillsdirectory.com/skills/rpvsilva-remote-subagents)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: remote-subagents
description: Run a subagent's brief on the remote backend (a cluster, Docker or an SSH host) instead of this machine, and act on its outcome. Use when a skill starts a subagent its needs.json declares remote-capable, or the human asks to run a brief remotely.
---

# Remote subagents

A subagent is **remote-capable** when the `needs.json` of the skill holding its brief lists it under `remote` (`../<skill>/needs.json`, e.g. `"remote": ["epic-implementer"]`): it only changes its worktree. That list is the one place this is declared; no skill restates it. The entry covers **every use** of the agent whose inputs fit the sandbox: the worktree and the files attached, no git history, nothing written outside the worktree, its output coming back as its final message. A skill whose own use breaks that (it has the agent write into the run folder, read `git log` or read a folder only this machine holds) runs that use here and says why, and leaves the entry for the uses that fit: the security reviewer runs remotely in review-pr's `security` mode, and here in security-audit's hunt and sweeps. A remote-capable subagent, or one the human asks to run remotely, runs on the remote backend (the `remote.backend` Setting: a cluster, Docker or an SSH host) instead of this machine when `remote-agent ready` exits 0 in the repo and the human did not ask for `--local`. `ready` prints the backend, or why remote runs are off: no backend set, no token, the repo sets `remote.allowed` to `false`, or the backend does not answer (with its error). Say that reason once, then run subagents locally.

The backend is compute only: it gets this machine's setup, a snapshot of the worktree and the files you attach, and gives back a patch. It has no GitHub access and no git branches, so it cannot push, open a PR, read CI logs or see another branch. Details: [remote/README.md](../../remote/README.md).

`remote-agent` is `~/.agents/bin/remote-agent`, unless the calling skill names another path to dispatch with; then use that path, with the same arguments. When `ready` says nothing is set up, the human sets it up with `~/.agents/bin/remote-agent setup` in their terminal (it asks for the token) and proves it with `remote-agent check`. When the human asks to turn remote off or change it, follow [configure](../configure/SKILL.md) if it is installed, else `settings set remote <key> <value> --machine` (or `--repo` for this repo only).

Each remote run takes a **remote slot**, not a local one: at most `settings get remote max_sandboxes` remote runs at once, whatever the skill.

### Steps

1. Create the worktree as for a local subagent: a git worktree on the subagent's own branch.
2. Write the subagent's prompt into a file, as [Protocol](../_shared/conventions.md#protocol) says (the calling skill's prompt script, else `python3 -I ../_shared/protocol/prompt.py <role> ... --skills-root '~/.agents/skills' --out <file>`: the pod's skills folder, so the prompt names the brief there), with the worktree as `~/work`, every other input path as `~/attached/<its file or folder name>` (quote each such argument, `'worktree=~/work'`, so the shell keeps the `~`), `remote` true where the role's input has it, and **no `output`**: the sandbox cannot write the run folder, so the agent's final message is its output object. Attach only what its brief reads, never a whole run folder holding other worktrees.
3. Run `remote-agent --name <task> --agent <agent> --attach <path>... @<prompt file> <worktree>` in the background, with a short task name the calling skill gives, or one you make from the task (lowercase, `[a-z0-9-]`), and `<agent>` the subagent you would start here (for a reviewer, the one the calling skill picks for its mode). `--agent` runs it on the model it runs on here, so a remote run and a local one get the same input and the same model. A `remote-agent` that refuses `--agent` as an unknown option predates it (a pinned dispatcher, say): run it without `--agent`, and tell the human the run used the sandbox's default model. Its stderr is progress, one line per step, each starting with `[<task>]`. Its outcome is the run's `result.json` (step 4): read it there, never from its stdout. The agent's output is the run's `report_path` (`summary.md`): its final message, the role's output object as JSON. When the calling skill names an output file for it (`<run>/reports/<id>.json`), copy `report_path` there.
   - Do not redirect its stderr: no `2>file`, no `2>&1 | <filter>`, no `2>/dev/null`. Left alone, each progress line shows to the human as it arrives; a run that only shows its result at the end looks like no agent is attached.
   - When the run starts, give the human the transcript path from its `transcript:` line on stderr. That file holds the subagent's full event stream as it arrives; beside it, `run.json` says the run's state and timings and `progress.log` holds its progress lines.
   - If your harness cannot show a background command's output while it runs, give the human the transcript path and read the run's stderr between other work.
   - A calling skill's script may start the run itself, detached, with its stderr to a log file it names (build-epic's `next.py`): then give the human that log's path, whose `transcript:` line names the transcript, and act on the run's outcome as that skill says.
   - The run keeps the remote subagent's session but does not place it for `/resume`: the sandbox wrote it, so it may hold forged turns that read as the human's. Never place it yourself. If the human wants to resume it, give them the `remote-agent resume <run> <worktree>` command from the run's `session:` line on stderr; it warns before placing.
4. When it ends, run `remote-agent result <task>` in the repo: it prints the newest `result.json` of the run named `<task>`, however the run was started (alone, beside others, or with its output redirected). Read `exit_code`, `report_status` (the output's `status`), `changed` (the files it touched), and the output at `report_path`. `complete: false` means the run ended before the subagent reported; anything unknown is `null`. Check the output with `python3 -I ../_shared/protocol/check.py <role> output <report_path>`, or the calling skill's checker built on it, and act on its line as [Protocol](../_shared/conventions.md#protocol) says (a brief violation gets one new run on the same worktree naming the problems). Act on `exit_code`:
   - **0**: the changes are in the worktree, uncommitted. Commit them as the subagent would have, with the repo's commit convention, then act on the output.
   - **3**: no changes; act on the output.
   - **4**: the worktree changed after the snapshot; run it again.
   - **5**: the account hit its usage limit, so every remote run will fail the same way until it resets. Hold every new remote run, let the running ones end, and tell the human the reset time from stderr. The task that hit the limit waits with the held ones. Resume once that time has passed, or sooner when the human switches the account.
   - **Anything else**: treat it as `blocked`, with the last lines of stderr as the reason. When two runs in a row fail the same way within a minute, the backend is down: hold every new remote run until `remote-agent ready` exits 0 again.

   Then, whatever the exit code, read `killed` and `lost`:
   - **`killed`** (`memory` or `timeout`, each kill in `capped_kills` as `{kind, cmd}`): the sandbox's caps (`caps` in the result: its share of its machine) killed at least one of the subagent's shell commands, and stderr has a `[<task>] killed: <kind> <command>` line for each. The run went on after it, so a kill alone is no failure: act on the exit code and the output as above. When the output says `blocked` or the run failed, the kill is the likely cause: retry as the skill says (build-epic retries once with a cap note), else treat it as `blocked`, naming the kind and the command.
   - **`lost: true`**: the sandbox itself is gone (its container or pod vanished with no kill line before), so no cap is at fault: act as on **Anything else**.

### A resolver

A subagent sent back to resolve conflict markers (build-epic's implementer with `resolve:`) runs remotely on the worktree its skill left mid-merge, as in the steps above, with these differences:

- **Before**: the merge stays in progress in the worktree, its markers in the files (build-epic: `finish_task.py` leaves it so on `FAIL TT-NN conflict <files>`). The snapshot carries the files with their markers but not the merge itself: no `MERGE_HEAD`, no unmerged index, no history of either side. Name the conflicted files from the failure in the prompt (its `resolve` input), and attach what the brief reads; the markers hold both sides.
- **After**, on exit 0: the patch sits in the working tree, the merge still in progress. Do not commit it yourself; run the skill's finishing step (build-epic: `finish_task.py`), which commits it as the merge commit, with both parents, once no marker is left, and fails `conflict <files>` again while one is. On exit 3 the markers are still there: resolve the merge locally, with the same resolver prompt, as under **Limits**.
- **Limits**: only content conflicts can be resolved remotely. A modify/delete, rename or binary conflict leaves no marker in a file, and a file deleted on one side is missing from the worktree, so the snapshot never holds it. When a conflicted file (`git diff --name-only --diff-filter=U`) has no `<<<<<<<` line, or is missing, resolve the merge locally.

Files in this skill

  • SKILL.md9.3 KB
  • needs.json53 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.