agentleFS
chenyinrusichenyinrusi/dsh-engineering-skills/skills/shell-safety/SKILL.md

shell-safety

Skill1 starsChanged 3 months agoMITView on GitHub

Prevent interactive CLI commands from freezing agent sessions. Hard ban on interactive commands (more/less/pause/choice/start /WAIT) with non-interactive equivalents, a mandatory timeout rule, and a pre-flight checklist. Use when running shell commands, diagnosing hangs, or choosing safe CLI alternatives. 防止交互式命令冻结 agent 会话,提供安全替代。

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every shell call MUST include a timeout.

    line 80
  2. Distinctive:

    Never omit the timeout. The default is "wait forever" — exactly what you're preventing.

    line 89

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shell-Safety

Overview

Prevent interactive CLI commands from freezing agent sessions. When running inside a headless shell-execution tool (the subprocess has no interactive terminal / TTY), commands that wait for keyboard input (more, less, pause, choice, start /WAIT) will block forever, freezing the calling agent until the process is killed externally.

This skill enforces a hard ban on interactive commands and provides non-interactive equivalents for every common use case.

Ban List (NEVER use these)

Command / PatternWhy banned
morePaginates, waits for keypress
more.comSame as more (explicit extension)
lessPaginates, waits for keypress
pause"Press any key to continue..."
choiceInteractive menu prompt
start /WAIT appWaits for GUI window to close
cmd ... | morePipe into pager = indefinite block
* | more +NSkip-N pager variant, same effect

Any command that requires human interaction is forbidden in a headless agent shell. Assume the shell has no keyboard or display.

Safe Replacements

Counting matches / lines

:: Banned
findstr /i "pattern" file | more +0 | find /c "pattern"

:: Correct (native find /c)
findstr /i "pattern" file | find /c /v ""
# Single line counting
(Select-String -Path file -Pattern 'pattern').Count

Viewing output (non-interactive full dump)

:: Banned
type file | more
more file

:: Correct
type file

Pause / confirmation — NEVER use in scripts run by agents

:: Banned
pause

:: Correct: just skip it. The agent doesn't need human confirmation mid-script.
rem (remove the pause entirely)

Waiting for external processes

:: Banned
start /WAIT notepad.exe

:: Correct: timeout-controlled wait for known processes
timeout /T 10 /NOBREAK
tasklist | findstr processname

Timeout Rule (MANDATORY)

Every shell call MUST include a timeout. This is the hard kill switch:

run_shell(command="...", timeout_ms=60000)   # 60s max
  • Short lookups (findstr on small files): timeout_ms=15000
  • Medium scans (grep on <100 files): timeout_ms=30000
  • Long commands (builds, tests): timeout_ms=300000 (5 min)
  • Never omit the timeout. The default is "wait forever" — exactly what you're preventing.

Pre-Flight Checklist (before every shell call)

  1. No more, less, pause, choice, start /WAIT anywhere in the command string or pipeline
  2. No more.com explicit extension (PATH shims can't intercept it)
  3. A timeout is set and reasonable for the expected runtime
  4. If counting/filtering: use find /c /v "" or PowerShell Select-String + .Count instead of piping through pagers
  5. If viewing output: type (Windows) or cat (cross-platform) — NEVER pipe to a pager

Why This Exists

A real incident: an agent session froze for 12+ minutes because the model generated:

findstr /i "/api/health" logs\endpoint_hits.jsonl | more +0 | find /c "/api/health"

more +0 waited for keyboard input that would never arrive. The pipe chain blocked, the model waited on its shell tool, and the session appeared dead — the only recovery was externally killing the findstr and more.com processes.

This skill plus a companion PATH-level shim (which replaces more/less/pause with non-interactive equivalents) form a two-layer defense against this class of bug.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.