OpenCode instructions for running shell commands safely in a non-interactive environment.
OpenCode's shell is non-interactive: it has no TTY/PTY, so commands that wait for input, launch a pager, or open an editor will hang until timeout. These instructions teach an agent to use command-specific non-interactive forms, fail fast when authorization is missing, and avoid unsafe patterns that bypass security controls.
The rules are written for OpenCode and apply to any comparable headless agent host.
Add the remote instruction file to your OpenCode configuration:
{
"instructions": [
"https://raw.githubusercontent.com/JRedeker/opencode-shell-strategy/trunk/shell_strategy.md"
]
}
Restart OpenCode. The rules load automatically at the start of each session.
A local clone is optional. If you want to edit or contribute, clone the repository and point your config at the local shell_strategy.md path instead.
| Tool | Avoid | Use |
|---|---|---|
| npm init | npm init | npm init -y |
| apt install | apt-get install pkg | apt-get install -y pkg |
| pip install | pip install pkg | pip install --no-input pkg |
| git commit | git commit | git commit -m "msg" |
| git merge | git merge branch | git merge --no-edit branch |
| git pull | git pull | git pull --no-edit |
| rm | rm -i file | rm file (no -i) |
| ssh first contact | ssh host | ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 user@host |
These hang or break autonomy in a non-interactive shell:
vim, nano, vi, emacs (editors)less, more, man (pagers)git add -p, git rebase -i (interactive git modes)python, node, ipython, irb without a script or -c/-e argument (REPLs)bash -i, zsh -i (interactive shells)Do not use yes | … or heredocs to blanket-approve unknown prompts. If a command has no non-interactive flag, choose one of:
apt-get install -y pkg.sudo -n command exits immediately if a password is required.For an explicitly trusted first contact, use StrictHostKeyChecking=accept-new with a short timeout:
ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 user@host
If a host key changes, the command fails. Do not use StrictHostKeyChecking=no.
Use sudo -n to run a command only when it needs no password:
sudo -n systemctl status nginx
If the command requires a password, sudo -n fails immediately. Do not pipe passwords into sudo -S.
MIT
sudo -n so failures are visible instead of hanging, and do not pipe passwords into sudo -S.StrictHostKeyChecking=accept-new with a short timeout and BatchMode=yes instead of disabling host-key checks.test.sh verify) so the rule set can be checked without installing extra tools.7 commits
Shell
100.0%
OpenCode instructions for running shell commands safely in a non-interactive environment.
OpenCode's shell is non-interactive: it has no TTY/PTY, so commands that wait for input, launch a pager, or open an editor will hang until timeout. These instructions teach an agent to use command-specific non-interactive forms, fail fast when authorization is missing, and avoid unsafe patterns that bypass security controls.
The rules are written for OpenCode and apply to any comparable headless agent host.
Add the remote instruction file to your OpenCode configuration:
{
"instructions": [
"https://raw.githubusercontent.com/JRedeker/opencode-shell-strategy/trunk/shell_strategy.md"
]
}
Restart OpenCode. The rules load automatically at the start of each session.
A local clone is optional. If you want to edit or contribute, clone the repository and point your config at the local shell_strategy.md path instead.
| Tool | Avoid | Use |
|---|---|---|
| npm init | npm init | npm init -y |
| apt install | apt-get install pkg | apt-get install -y pkg |
| pip install | pip install pkg | pip install --no-input pkg |
| git commit | git commit | git commit -m "msg" |
| git merge | git merge branch | git merge --no-edit branch |
| git pull | git pull | git pull --no-edit |
| rm | rm -i file | rm file (no -i) |
| ssh first contact | ssh host | ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 user@host |
These hang or break autonomy in a non-interactive shell:
vim, nano, vi, emacs (editors)less, more, man (pagers)git add -p, git rebase -i (interactive git modes)python, node, ipython, irb without a script or -c/-e argument (REPLs)bash -i, zsh -i (interactive shells)Do not use yes | … or heredocs to blanket-approve unknown prompts. If a command has no non-interactive flag, choose one of:
apt-get install -y pkg.sudo -n command exits immediately if a password is required.For an explicitly trusted first contact, use StrictHostKeyChecking=accept-new with a short timeout:
ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 user@host
If a host key changes, the command fails. Do not use StrictHostKeyChecking=no.
Use sudo -n to run a command only when it needs no password:
sudo -n systemctl status nginx
If the command requires a password, sudo -n fails immediately. Do not pipe passwords into sudo -S.
MIT
sudo -n so failures are visible instead of hanging, and do not pipe passwords into sudo -S.StrictHostKeyChecking=accept-new with a short timeout and BatchMode=yes instead of disabling host-key checks.test.sh verify) so the rule set can be checked without installing extra tools.7 commits
Shell
100.0%