A Hundred Agent Sessions on One Box

Tips for Running Coding Agents Remotely · Michael Rishi Forrester

The whole setup

The whole setup

Tip 1

Hooks, tests and rules before scale

workflow/llm-coding-workflow/claude-config/settings.json

        "matcher": "Bash",
[...]
            "command": "$HOME/.claude/hooks/check-commit-message.sh"
[...]
    "Stop": [
[...]
            "command": "$HOME/.claude/hooks/auto-test-on-stop.sh"
Play the recording

Tip 2

The repo tree is the session list

The repo tree is the session list

Tip 2

Attach helpers generated from the repo tree

workflow/llm-coding-workflow/wsl2-specific/sync-alpha-sessions.sh

    # Alias format: group-reponame (e.g., kk-ginseng, mrf-ptos)
    alias_name="${norm_group}-${norm_leaf}"

    # Session name matches alias name for simplicity
    session_name="${alias_name}"
[...]
    ALIASES+=("alias ${alias_name}='ncs ${session_name} ${repo_path}'")

workflow/llm-coding-workflow/generated/right/alpha-sessions

alias workflow-llm-coding-workflow='ncs workflow-llm-coding-workflow /home/michael/repos/workflow/llm-coding-workflow'

workflow/llm-coding-workflow/wsl2-dotfiles/crontab

*/30 * * * * /home/michael/scripts/sync-alpha-sessions.sh [...]
Play the recording

Tip 3

tmux settings that follow whichever screen you're on

workflow/llm-coding-workflow/alpha-specific/tmux.conf

set -g window-size latest
set -g aggressive-resize on
[...]
set-hook -g client-attached "resize-window -A"
[...]
set-hook -g client-resized "resize-window -A"
Play the recording

Tip 4

A reconnect loop that beats autossh

A reconnect loop that beats autossh

Tip 4

Branch on the exit code

workflow/llm-coding-workflow/wsl2-specific/sync-alpha-sessions.sh

    while true; do
        ssh "${ssh_opts[@]}" -t alpha "[...]tmux new-session -A -D -s ${session} -c \"${repo_path}\""
        local rc=$?
        case $rc in
[...]
            0)
                echo
                echo "[ncs] detached cleanly. Press Enter to re-attach, Ctrl-C to exit."
                read -r
                ;;
[...]
            255)
[...]
                    echo "[ncs] connection lost (network/ssh). Reconnecting in 5s... (Ctrl-C to abort)"
                    sleep 5

workflow/llm-coding-workflow/wsl2-dotfiles/ssh-config

Host alpha
[...]
  ServerAliveInterval 30
  ServerAliveCountMax 3

Tip 4

One-command workspace restore

workflow/llm-coding-workflow/wsl2-specific/generate-terminal-profiles.sh

    cmd="wsl.exe -d ${WSL_DISTRO} -- bash -ic 'ncs ${session_name} ${repo_path}'"

workflow/llm-coding-workflow/wsl2-specific/generate-launcher.sh

        echo "# --- ${display_name} (${#sessions[@]} tabs) ---"

        # Build the argument list: first session is new-tab, rest are ; new-tab
        echo -n 'Start-Process wt.exe -ArgumentList @('

workflow/llm-coding-workflow/wsl2-specific/bashrc-alpha-helpers.sh

restore() {
    local ps1="${WIN_SCRIPTS}/restore-workflow.ps1"
[...]
    powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\\${WIN_USER}\\Scripts\\restore-workflow.ps1" -Force
}
Play the recording

Tip 5

Cron-driven orchestration that keeps working while you're on a plane

workflow/llm-coding-workflow/alpha-dotfiles/crontab

# Daily durable snapshot of ~/.claude/projects (Anthropic prunes it)
30 4 * * * /home/michael/scripts/claude-session-snapshot.sh [...]
[...]
# Stop agent sessions idle >4d. Runs after the 4:30 snapshot so transcripts are archived first.
0 5 * * * [...] ${R1}/scripts/reap-idle-sessions.sh --apply [...]
[...]
# workflow-knowledge: monthly workflow refresh (workflow-knowledge#3, llm-coding-workflow#218).
# claude -p with a $25 cap and 60 min timeout; commits to staging, exits 1 without committing on any failure.
0 6 1 * * [...] uv run wk refresh [...]

workflow/llm-coding-workflow/alpha-dotfiles/scripts/claude-session-snapshot.sh

# Accumulate. NO --delete: the whole point is to KEEP histories that Anthropic prunes
# out of ~/.claude. Files that disappear upstream stay preserved here.
rsync -a "$SRC" "$LIVE/" 2>>"$LOG"
Play the recording

Five tips, one box

Michael Rishi Forrester · michaelrishiforrester.com

QR code for https://github.com/peopleforrester/remote-agent-fleet-config