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]:
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, orkubectlbinaries. SSH runs with-o BatchMode=yes, so key-based or ssh-agent authentication must already work without interactive password prompts. - Remote utilities:
read_fileandwrite_fileon SSH, Docker, and Kubernetes targets require POSIXsh,ls,tail,head,dirname,mkdir,cat,mv, andrminside the target. - Local-only tools:
grep_files,glob_files,command_help,shell_history, andasksh dry-runalways execute locally rather than inside the remote target. - File edit snapshots and line limits: remote
edit_filereads up to 20,000 lines (20 pages of 1,000 lines) and rewrites viawrite_file. Remote edits do not use localFileReadTrackerfreshness checks and do not createundoordiffsnapshots. - Output streaming: remote
execute_shell_commandcollects 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:
Pass --dir <path> to copy a different directory, or --json for machine-readable output.
How the sandbox isolates execution¶
askshcreates a temporary directory and copies regular files from the working directory, skipping.git,.jj,node_modules, symlinks, and non-regular files.- Copying stops at 500 files or 10 MiB total, adding a note if the cap was hit.
- On macOS,
askshexecutes the command insidesandbox-exec(seatbelt), denying allnetwork*andfile-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. - If
sandbox-execorbwrapis unavailable, or if a nested sandbox environment rejects confinement withEPERM,askshfalls back to running inside the isolated temporary directory (tempdir), marks the result asdegraded, and records why inNote. - 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.