Repository navigation
Description
Description
Add a just recipe (e.g. just devc-remote <ssh-host>) that orchestrates starting a devcontainer on a remote host and connecting Cursor/VS Code to it in a single command. This enables a workflow where developers can spin up their devcontainer on a powerful remote machine from their local terminal.
Problem Statement
Currently, starting a devcontainer on a remote host requires multiple manual steps:
- SSH into the remote host
- Clone/update the repository
- Check if podman/docker is available and start the container via compose
- Open Cursor with
--remote ssh-remote+host /path/to/project - Reopen in Container from within Cursor
This is tedious and error-prone. A single just command should handle the full orchestration.
Proposed Solution
A just recipe (or small shell script invoked by just) in justfile.base that:
- SSHs into the specified remote host and runs pre-flight checks (see Pre-flight Checks below)
- Clones the repo if a target path is specified (defaults to
~/), or skips if already present - Starts the devcontainer via
compose up -don the remote host, with container state detection (see below) - Opens Cursor directly into the remote devcontainer using the nested authority CLI syntax (see below)
Example usage:
just devc-remote myserver
just devc-remote user@host --path /opt/projects/myrepo
just devc-remote myserver --clone [email protected]:org/repo.gitCursor Nested Authority CLI (Key Finding)
Cursor supports opening a devcontainer on a remote SSH host in a single CLI command using nested authorities:
cursor --folder-uri "vscode-remote://dev-container+${DC_HEX}@ssh-remote+${SSH_SPEC}/${container_workspace}"Dev container spec (hex-encoded JSON):
{
"settingType": "config",
"workspacePath": "/home/user/repo",
"devcontainerPath": "/home/user/repo/.devcontainer/devcontainer.json"
}SSH spec — two variants:
- Simple (host from
~/.ssh/config):@ssh-remote+loginnode - Full (hex-encoded JSON):
@ssh-remote+${SSH_HEX}where{"hostName":"[email protected] -p 22"}
This eliminates the previously assumed two-step flow. No manual "Reopen in Container" is needed.
Pre-flight Checks
The recipe must validate the following before proceeding, with clear error messages on failure:
Local (before SSH)
| Check | Failure mode | Error message |
|---|---|---|
cursor or code CLI exists |
CLI not in PATH | "Neither cursor nor code CLI found. Install Cursor or VS Code and enable the shell command." |
| SSH host is reachable | DNS failure, network timeout, auth failure | "Cannot connect to . Check your SSH config and network." |
| SSH key/agent available | No key loaded, agent not running | "SSH authentication failed for . Ensure your SSH key is loaded (ssh-add -l)." |
Remote (over SSH)
| Check | Failure mode | Error message |
|---|---|---|
| Container runtime exists | Neither podman nor docker installed | "No container runtime found on . Install podman or docker." |
| Compose plugin available | podman compose / docker compose missing |
"Compose not available on . Install docker-compose or podman-compose." |
| Git is available | Git not installed (only if --clone used) | "Git not found on . Install git to use --clone." |
| Repo path exists or --clone provided | Path missing, no clone URL | "Repository not found at on . Use --clone to clone it." |
| Disk space sufficient | Disk full | "Low disk space on (). At least 2GB recommended." |
.devcontainer/ exists in repo |
Missing devcontainer config | "No .devcontainer/ found in . Is this a devcontainer-enabled project?" |
| Compose files are valid | YAML parse error | "Invalid compose configuration: . Check .devcontainer/docker-compose*.yaml" |
| Container image pullable | Registry auth failure, image not found | "Cannot pull devcontainer image. Check registry access on ." |
| Port conflicts | Ports already bound | "Port already in use on . Stop the conflicting service or use a different port." |
Implementation Detail: Container State Detection
Before running compose up, the recipe must detect and handle existing container state on the remote host. Docker compose scopes containers by project name (derived from directory name), so multiple repos in different directories are naturally isolated.
Detection flow
SSH into remote host
→ cd <repo_path>
→ compose ps --format json (scoped to project via -f flags)
→ Parse state of "devcontainer" service
→ running + healthy → SKIP compose up, open Cursor
→ running + unhealthy/restarting → compose restart, health poll, open Cursor
→ exited/stopped → compose up -d, health poll, open Cursor
→ not found → compose up -d, health poll, open Cursor
Container state matrix
| # | State | Cause | Action | User message |
|---|---|---|---|---|
| 1 | Running, healthy | Previous devc-remote or manual compose up |
Skip compose up | "Devcontainer already running on . Opening..." |
| 2 | Running, unhealthy/restarting | Container crashed, compose restart-looping | compose restart devcontainer, health poll |
"Devcontainer unhealthy, restarting..." |
| 3 | Exited/stopped | Manual compose stop or unrecoverable crash |
compose up -d, health poll |
"Devcontainer was stopped. Starting..." |
| 4 | Not found | First run, or compose down was used |
compose up -d, health poll |
"Starting devcontainer on ..." |
| 5 | Running, config changed | User edited compose files since last up | compose up -d (detects changes, recreates) |
"Devcontainer config changed. Recreating..." |
| 6 | Running, image updated | Image tag changed or new image pulled | compose up -d (detects image change, recreates) |
"Image updated. Recreating devcontainer..." |
Detecting config/image changes (cases 5 & 6): compose up -d inherently handles these — it compares the running state to the desired state and recreates only what changed. No custom detection needed; compose's own output indicates whether it recreated or left the service as-is.
Health poll after compose up
After any compose up -d or compose restart, poll the container state before opening Cursor:
MAX_WAIT=30
INTERVAL=5
for i in $(seq 1 $((MAX_WAIT / INTERVAL))); do
STATE=$(compose ps --format json | jq -r '.[] | select(.Service=="devcontainer") | .State')
case "$STATE" in
running) break ;;
exited|dead)
echo "[ERROR] Devcontainer failed to start. Last 20 log lines:"
compose logs --tail 20 devcontainer
exit 1
;;
esac
[ "$i" -eq $((MAX_WAIT / INTERVAL)) ] && {
echo "[ERROR] Devcontainer did not become healthy within ${MAX_WAIT}s"
compose logs --tail 20 devcontainer
exit 1
}
sleep "$INTERVAL"
doneEdge cases in state detection
| Scenario | Behavior |
|---|---|
| Container name collision (different repo, same dir name) | Compose project is scoped by the -f file paths, so this is safe. Different repos in different directories get different project names. |
| Same repo cloned twice to different paths | Each path gets its own compose project — independent containers. No collision. |
| Multiple users running devc-remote to same host+repo | Compose project is shared. Second user's compose up -d is a no-op if config hasn't changed. Both get the same container — this is fine for shared dev servers. |
--force flag (future) |
Could add --force to always compose down && compose up -d, bypassing state detection. Not in v1 scope. |
Failure Modes & Edge Cases
| Scenario | Expected behavior |
|---|---|
| SSH connection drops mid-operation | Partial state left on remote. Recipe must be idempotent — re-running detects existing state and resumes. Compose up is already idempotent. Clone skips if directory exists. |
| Container already running (various states) | See Container State Detection section above. |
| Repo exists but is on wrong branch | Don't touch the branch. Warn: "Repo exists at on branch ." |
| Container runtime is rootless podman | Must work — test both rootless and rootful. Rootless podman uses $XDG_RUNTIME_DIR/podman/podman.sock. |
| Remote host is macOS (not Linux) | podman runs in a VM on macOS — compose paths differ. Detect OS via uname and warn if unsupported. |
~/.ssh/config uses ProxyJump or bastion |
Cursor's ssh-remote authority supports full SSH config, including proxy jumps. Test with multi-hop. |
| Multiple devcontainer services in compose | Recipe assumes service name devcontainer (from template). Fail clearly if service not found in compose ps output. |
| Compose up succeeds but container exits immediately | Health poll catches this within 30s. Reports last 20 log lines for debugging. |
| User interrupts with Ctrl+C | Trap SIGINT/SIGTERM. If mid-compose-up, let compose finish (it's idempotent). If mid-clone, warn about partial clone. |
| Remote host has no internet (air-gapped) | Image must be pre-loaded. Pre-flight check for image pullability will catch this. Suggest podman load as workaround. |
| SSH agent forwarding needed for private repo clone | Recipe should forward the SSH agent (ssh -A) when --clone is used with an SSH URL. |
Implementation Detail: Script Architecture
The recipe should be a thin just wrapper calling a shell script for complex logic:
justfile.base
└── devc-remote recipe → calls assets/scripts/devc-remote.sh
devc-remote.sh structure:
├── parse_args() — host, --path, --clone, --clone-to
├── detect_editor_cli() — cursor > code, store in $EDITOR_CLI
├── check_ssh() — connectivity + auth test
├── remote_preflight() — single SSH session, runs all remote checks
│ ├── detect_runtime() — podman > docker, store in $COMPOSE_CMD
│ ├── check_git() — only if --clone
│ ├── check_repo() — exists? has .devcontainer/?
│ └── check_disk() — df, warn if < 2GB
├── remote_clone() — git clone (if --clone), with SSH agent forwarding
├── remote_compose_up() — container state detection + compose up + health poll
├── build_cursor_uri() — hex encode specs, assemble nested authority URI
└── open_editor() — $EDITOR_CLI --folder-uri "$URI"
Key design decisions:
- Single SSH session for pre-flight: Batch all remote checks into one
sshcall to avoid repeated connection overhead. - Idempotent by design: Every step checks existing state before acting. Safe to re-run.
- No dependencies on remote host beyond runtime + git: No
just,jq, or other tools assumed on remote. Use basic shell + compose JSON output. set -euo pipefail: Strict error handling throughout.
Implementation Detail: Cursor URI Construction
The hex encoding and URI assembly must be exact. Here's the construction logic:
build_cursor_uri() {
local workspace_path="$1" # e.g. /home/user/myrepo
local ssh_host="$2" # e.g. myserver or user@host
local container_workspace # e.g. /workspace/myrepo (from devcontainer.json)
# Read workspaceFolder from devcontainer.json on remote
container_workspace=$(ssh "$ssh_host" \
"grep -o '\"workspaceFolder\"[[:space:]]*:[[:space:]]*\"[^\"]*\"' \
${workspace_path}/.devcontainer/devcontainer.json" \
| sed 's/.*: *"//;s/"//')
# Build devcontainer spec
local dc_conf
dc_conf=$(printf '{"settingType":"config","workspacePath":"%s","devcontainerPath":"%s/.devcontainer/devcontainer.json"}' \
"$workspace_path" "$workspace_path")
# Hex encode
local dc_hex
dc_hex=$(printf '%s' "$dc_conf" | od -A n -t x1 | tr -d '[\n\t ]')
# Build URI — simple variant (host from SSH config)
printf 'vscode-remote://dev-container+%s@ssh-remote+%s%s' \
"$dc_hex" "$ssh_host" "$container_workspace"
}For hosts not in SSH config, the full variant adds hex-encoded SSH spec:
local ssh_conf
ssh_conf=$(printf '{"hostName":"%s"}' "$ssh_host")
local ssh_hex
ssh_hex=$(printf '%s' "$ssh_conf" | od -A n -t x1 | tr -d '[\n\t ]')
# URI becomes: dev-container+${dc_hex}@ssh-remote+${ssh_hex}/${container_workspace}Testing Strategy
Unit tests (BATS — shell script analysis)
- Script structure validation (
set -euo pipefail, error handling, signal traps) - Argument parsing (
host,--path,--clone,--clone-to) - Hex encoding correctness — given known JSON input, assert exact hex output
- URI assembly — given known specs, assert exact
--folder-urioutput - Container state matrix — each state maps to correct action
- Error message formatting for each pre-flight failure
Integration tests — local simulation (pytest, no remote host)
Reuse existing patterns from conftest.py:
| Test | Approach |
|---|---|
| URI construction end-to-end | Call build_cursor_uri() with known inputs, assert exact output matches Cursor docs examples. |
| Pre-flight check functions | Mock SSH commands via a stub script, test each check returns correct pass/fail with correct exit code. |
| Compose file resolution | Given a workspace path, verify the recipe generates correct -f flags for all three compose files. |
| Idempotency | Run the remote setup logic twice against a local container. Verify second run detects "running" state and skips compose up. |
| Error messages | Trigger each failure mode, assert user-facing message matches spec. |
| Container state detection | For each of the 6 states in the matrix, mock compose ps output and verify correct action is taken. |
| Health poll timeout | Mock a container that never becomes healthy. Verify timeout fires at 30s with log output. |
Integration tests — SSH loopback (pytest + sshd sidecar)
Spin up a sidecar container running sshd to simulate a remote host:
services:
test-remote-host:
image: linuxserver/openssh-server:latest
environment:
- PUBLIC_KEY_FILE=/config/.ssh/authorized_keys
volumes:
- ./test-keys/id_ed25519.pub:/config/.ssh/authorized_keys:ro
ports:
- "2222:2222"| Test | Approach |
|---|---|
| SSH connectivity pre-flight | Connect to sshd sidecar on port 2222. Verify check passes. |
| SSH auth failure | Connect with wrong key. Verify check fails with correct message. |
| Remote runtime detection | sshd sidecar has podman/docker installed (or mock binaries). Verify detection picks correct runtime. |
| No runtime installed | sshd sidecar with neither podman nor docker. Verify error message. |
| Clone + compose up | Clone a test repo into sidecar, run compose up, verify container starts via compose ps. |
| Container state detection (live) | Start container, verify "already running" detection. Stop container, verify "stopped" detection. |
| Full URI generation | After remote setup, verify the generated cursor --folder-uri command is syntactically valid (parse the URI, decode hex, validate JSON). |
| Idempotency (live) | Run devc-remote twice against sshd sidecar. Verify second run is a no-op for compose. |
| SSH drop simulation | Kill sshd mid-compose-up. Re-run. Verify recovery. |
| Disk space check | Fill sidecar's /tmp. Verify disk space warning triggers. |
This follows the existing devcontainer_with_sidecar fixture pattern from conftest.py.
CI considerations
- GitHub Actions runners (ubuntu-22.04) support running sshd containers as sidecars
- No multi-machine CI needed — the sshd sidecar simulates a remote host on the same runner
- Existing
test-integrationjob structure can host these tests - Session-scoped fixture for the sshd sidecar (expensive to set up, reuse across tests)
- Clean up sidecar containers after test session (existing
PYTEST_AUTO_CLEANUPpattern) - Generate ephemeral SSH keypair in CI (no secrets needed)
Manual / smoke testing
- Test with a real remote host (developer's own server) — not automatable in CI, documented in test plan
- Test with ProxyJump / bastion hosts
- Test Cursor actually opens and connects (requires human verification)
- Test with rootless podman on remote
- Test with macOS remote (expected: warn unsupported)
Alternatives Considered
- Manual SSH + compose: Current approach — works but requires many steps.
- VS Code Remote SSH + "Reopen in Container": GUI-only workflow, not scriptable.
devcontainerCLI over SSH: Requires@devcontainers/cliinstalled on the remote host (extra dependency).- Cursor tunnels (
cursor tunnel): Requires the Cursor CLI on the remote host and a different auth flow.
Additional Context
- Depends on issue [FEATURE] Expand justfile.base with devcontainer, quality, security, docs, info, and git recipes #71 (local justfile.base recipes) for the shared
up/down/compose patterns - Cursor CLI docs confirm nested
dev-container+...@ssh-remote+...authority works for single-command remote devcontainer opening - The recipe should auto-detect
cursorvscodeCLI (prefer cursor, fall back to code) - Existing test infrastructure (sidecar pattern, SSH agent forwarding, pexpect) provides a solid foundation
- No
jqorjustassumed on the remote host — only basic shell, git, and a container runtime
Impact
- Benefits developers working with remote build/dev machines (GPU servers, cloud VMs, CI runners)
- Backward compatible — new recipe, no changes to existing behavior
- Requires SSH access configured on the host (uses
~/.ssh/config)
Changelog Category
Added
Activity
gerchowl commentedon Feb 21, 2026
Design
Decisions
--clone, signal traps, etc.scripts/), synced toassets/workspace/.devcontainer/scripts/via manifestjustfile.gh,scripts/gh_issues.py)assets/workspace/.devcontainer/justfile.baseArchitecture
Key design choices:
ssh <host> bash -sbatching all checks to avoid repeated connection overhead.File Layout
scripts/devc-remote.shscripts/devc_remote_uri.pyassets/workspace/.devcontainer/justfile.basedevc-remoterecipe (thin wrapper)scripts/sync_manifest.pyassets/workspace/Sub-Issue Decomposition (v1)
Sub-issue A: Script scaffold + pre-flight checks
devc-remote.shwithparse_args(),usage(),set -euo pipefail<ssh-host>(required),--path <remote-repo-path>(optional, default~/)detect_editor_cli()(cursor > code),check_ssh()(connectivity + auth viassh -o BatchMode=yes)Sub-issue B: Container state + compose + URI construction
compose ps --format json(6-state matrix from issue spec)devc_remote_uri.py:hex_encode(),build_uri()with CLI interfaceSub-issue C: End-to-end wiring
justfile.baserecipe:devc-remote host *args--helpsuccessfully)Follow-Up Issues (post-v1)
--clone <url>flag for remote repo cloning (+ SSH agent forwarding withssh -A)trapfor SIGINT/SIGTERM)--forceflag (alwayscompose down && compose up -d)Testing Strategy (v1)
devc-remote.sh --helpexits 0gerchowl commentedon Feb 22, 2026
Implementation Plan
Issue: #70
Branch:
feature/70-remote-devc-orchestrationStructure
Two parallel sub-issues, then wiring on the parent branch:
devc-remote.shbash orchestratordevc_remote_uri.pyPython URI helperSub-issue #152 Tasks —
devc-remote.sh--path,--help, unknown flags) —tests/bats/devc-remote.bats— verify:npx bats tests/bats/devc-remote.batsparse_args()+usage()+set -euo pipefailscaffold —scripts/devc-remote.sh— verify: BATS passdetect_editor_cli()(cursor found, code found, neither) —tests/bats/devc-remote.bats— verify: BATS passdetect_editor_cli()—scripts/devc-remote.sh— verify: BATS passcheck_ssh()(success, connection fail, auth fail) —tests/bats/devc-remote.bats— verify: BATS passcheck_ssh()—scripts/devc-remote.sh— verify: BATS passremote_preflight()structured output parsing —tests/bats/devc-remote.bats— verify: BATS passremote_preflight()— single SSH heredoc returning key=value output —scripts/devc-remote.sh— verify: BATS passcompose ps) —tests/bats/devc-remote.bats— verify: BATS passremote_compose_up()— state detection + compose up + health poll —scripts/devc-remote.sh— verify: BATS passopen_editor()— calldevc_remote_uri.py, then$EDITOR_CLI --folder-uri—scripts/devc-remote.sh— verify: BATS passscripts/devc-remote.sh— verify:bash scripts/devc-remote.sh --helpexits 0Sub-issue #153 Tasks —
devc_remote_uri.pyhex_encode()— known inputs → exact hex output —tests/test_devc_remote_uri.py— verify:uv run pytest tests/test_devc_remote_uri.py -vhex_encode()—scripts/devc_remote_uri.py— verify: pytest passbuild_uri()— known inputs → exact URI —tests/test_devc_remote_uri.py— verify: pytest passbuild_uri()—scripts/devc_remote_uri.py— verify: pytest passtests/test_devc_remote_uri.py— verify: pytest pass__main__block with argparse —scripts/devc_remote_uri.py— verify: pytest passtests/test_devc_remote_uri.py— verify: pytest pass#70 Wiring Tasks (after #152 + #153 merge)
devc-remoterecipe toassets/workspace/.devcontainer/justfile.base— verify:just --listshows recipescripts/sync_manifest.py— verify:uv run python scripts/sync_manifest.py listshows entriesassets/workspace/.devcontainer/scripts/bash scripts/devc-remote.sh --helpexits 0 with usage outputfeat(scripts): devc_remote_uri.py — Cursor URI construction for remot…
fix(scripts): correct devc-remote.sh URI construction and add justfil…
refactor(scripts): use SSH-style path format for devc-remote
36 remaining items
fix(remote): add --yes to gpg dearmor to overwrite existing keyring
fix(remote): update all repos with clock-skew tolerance for Node.js deps
fix(remote): ignore apt-get update exit 100 from clock-skewed repos
feat(remote): add cl/cld aliases in container for both root and claud…
fix(remote): source OAuth token from PID 1 in claude wrapper
fix(remote): allocate PTY in claude wrapper for interactive TUI
feat(remote): sync local Claude Code config into container on deploy
feat(remote): skip Claude Code onboarding screen in container
fix(remote): add hasCompletedAuthFlow to skip login screen
feat(remote): pre-configure workspace trust and dangerous mode skip
feat(remote): add --add-dir \$PWD to claude wrapper for workspace trust
fix(remote): pre-set workspace trust in both .claude.json and project…
feat(image): bundle agent-CLI toolkit + TUI debug stack + Claude Code
c-vigo commentedon Jul 8, 2026
Closing as part of an agreed backlog cleanup (with @gerchowl). The remote-devcontainer /
devc-remote/ Tailscale initiative predates the Nix + Claude-native migration (#625) and has had no activity since Feb–Mar 2026. If remote provisioning is wanted again it will be re-planned from scratch after the devkit rename (#781). Reopen/refile if revived.