/selamy-skills:safe-remote-shell-commandsfrom selamy-skills
Use when commands cross shell boundaries through SSH, nested shells, tmux, heredocs, substitutions, variables, or quoted data. Prevent expansion by the wrong interpreter, simplify transport, and verify resulting state.
Ships in selamy-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Remote commands often traverse several interpreters: the local shell, SSH, the remote login shell, an optional nested shell, and perhaps tmux. Quoting that is correct for one boundary can be consumed by an earlier one.
Before running anything, name every interpreter in order. For example:
local shell -> ssh argument -> remote shell -> bash -lc -> tmux process
For every $name, ${name}, $(command), backtick, glob, backslash, and quote,
decide which interpreter must see it. If that is difficult to state precisely,
simplify the command instead of adding another escape layer.
Do not place remote command substitution inside a local double-quoted string:
# Unsafe: the local shell runs git before ssh starts.
ssh build-host "cd /srv/app && test \"$(git rev-parse HEAD)\" = abc123"
Prefer one of these patterns:
# A fixed, already-resolved value needs no substitution.
ssh build-host 'cd /srv/app && test "$(git rev-parse HEAD)" = abc123'
# Resolve remotely, return the value, and compare locally as a separate step.
remote_head=$(ssh build-host 'cd /srv/app && git rev-parse HEAD')
test "$remote_head" = "abc123"
Single quotes protect text from the local shell. They do not make arbitrary nested quoting easy. Also, SSH joins remote command arguments into one command string; do not assume local argument boundaries survive transport. When dynamic data must cross the boundary, send it to a fixed remote program over standard input or another data protocol rather than interpolating it into shell source:
expected_ref="abc123"
printf '%s\n' "$expected_ref" | ssh build-host '/srv/control/verify-ref'
Here /srv/control/verify-ref is a previously copied, reviewed script that
reads one constrained ref from standard input. The remote shell parses only the
fixed command path; the ref remains data.
Use this preference order:
sh -c or bash -lc only when login-shell behavior is required.For tmux, provide the program and arguments directly when possible:
ssh build-host tmux new-session -d -s audit -c /srv/app \
worker --mode review --input /srv/control/audit.prompt
Put long prompts, JSON, or multiline logic in a file. Copying a file and then executing or reading it is usually clearer than transporting it through nested quotes.
eval. If source must be generated dynamically, write and inspect a
script before executing it.Do setup, launch, and verification as separate calls. A shorter command makes the failure boundary visible and avoids ambiguous partial success.
ssh build-host 'test -d /srv/app && git -C /srv/app status --short'
ssh build-host tmux new-session -d -s audit -c /srv/app worker --mode review
ssh build-host 'tmux has-session -t audit && pgrep -af "worker --mode review"'
After any quoting or transport failure, assume some earlier operations may have succeeded. Inspect the exact remote directory, process, session, branch, or artifact before retrying. Do not infer remote state from a local exit message.
Stop and restructure the operation when:
$();What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selamy-labs/agent-skills --plugin selamy-skills111 skills in this plugin
/adaptive-estimationUse when tracking a slowly-varying latent quantity from noisy measurements with quantifiable uncertainty — a drifting metric, capacity, latency trend, or confidence. Prefer a Kalman-style adaptive estimator over fixed moving averages or static thresholds./adaptive-loop-budgetingUse when an autonomous loop needs explicit limits on attempts, time, cost, tool calls, verification depth, or risk, and a clear stop, continue, yield, or escalate decision./adopt-and-deleteUse when adopting a shared module, library, chart, or service, or doing any consolidation, migration, or refactor that supersedes existing code. The change that adds the replacement must REMOVE what it replaced, in the same atomic change.Other plugins' skills for the same job