Skip to content

Targets and dry-run sandbox

asksh can run commands and inspect or edit files on remote hosts and containers through --target, and test local commands safely in an ephemeral sandbox before running them for real.

Execution targets

Select a target on the CLI with --target <uri>, or inspect and switch targets inside the TUI with /target [uri]:

asksh --target "ssh://troy@greendale.edu?env=prod" "check why nginx failed to reload"
asksh --target "docker://air-conditioning-annex?env=staging" "inspect /etc/app/config.toml"
asksh --target "k8s://study-group/api-pod/api?env=prod" "tail recent errors in /var/log/app.log"

Target URI syntax

Target URI format Example
Local host local or local?env=<env> local?env=prod
SSH host ssh://[user@]host[:port][?env=<env>] ssh://troy@greendale.edu:2222?env=prod
Docker container docker://<container>[?env=<env>] docker://study-room-db?env=staging
Kubernetes pod k8s://<namespace>/<pod>[/<container>][?env=<env>] k8s://greendale/worker-0/app?env=prod

Only the env query parameter is accepted. Setting ?env=<env> activates matching [targets.<env>] rules in permissions.toml. Switching targets with /target resets session-level file approvals.

Remote target prerequisites and limitations

  • Local CLIs: remote targets invoke your local ssh, docker, or kubectl binaries. SSH runs with -o BatchMode=yes, so key-based or ssh-agent authentication must already work without interactive password prompts.
  • Remote utilities: read_file and write_file on SSH, Docker, and Kubernetes targets require POSIX sh, ls, tail, head, dirname, mkdir, cat, mv, and rm inside the target.
  • Local-only tools: grep_files, glob_files, command_help, shell_history, and asksh dry-run always execute locally rather than inside the remote target.
  • File edit snapshots and line limits: remote edit_file reads up to 20,000 lines (20 pages of 1,000 lines) and rewrites via write_file. Remote edits do not use local FileReadTracker freshness checks and do not create undo or diff snapshots.
  • Output streaming: remote execute_shell_command collects stdout and stderr after the command completes rather than streaming lines mid-run.

Dry-run sandbox

Use asksh dry-run on the CLI, or press s on an empty input box in the TUI when asksh suggests a medium or high danger command, to run a command against a temporary copy of your working directory:

asksh dry-run "find . -name '*.tmp' -delete"

Pass --dir <path> to copy a different directory, or --json for machine-readable output.

How the sandbox isolates execution

  1. asksh creates a temporary directory and copies regular files from the working directory, skipping .git, .jj, node_modules, symlinks, and non-regular files.
  2. Copying stops at 500 files or 10 MiB total, adding a note if the cap was hit.
  3. On macOS, asksh executes the command inside sandbox-exec (seatbelt), denying all network* and file-write* outside the temporary directory and /dev/null. On Linux, it runs inside Bubblewrap (bwrap) with --unshare-net, read-only /usr, /bin, and /lib*, and a writable bind mount for the temporary directory.
  4. If sandbox-exec or bwrap is unavailable, or if a nested sandbox environment rejects confinement with EPERM, asksh falls back to running inside the isolated temporary directory (tempdir), marks the result as degraded, and records why in Note.
  5. Commands time out after 15 seconds, stdout and stderr are each capped at 512 KiB, and SHA-256 digests identify every created, modified, or deleted file before deleting the temporary directory.

See the dry-run reference for the exact output fields and JSON schema.