{"data":{"slug":"discovered-6ec69bc6d214d048bd767c9d13ca3c4fe5c37b6989225d99","title":"Shell Safety","summary":"Prevent interactive CLI commands from freezing agent sessions by enforcing a hard ban on interactive commands and providing non-interactive equivalents, along with a mandatory timeout rule and a pre-flight checklist. Use when running shell commands, diagnosing hangs, or choosing safe CLI alternatives.","url":"https:\/\/skillshunter.net\/skills\/discovered-6ec69bc6d214d048bd767c9d13ca3c4fe5c37b6989225d99","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-6ec69bc6d214d048bd767c9d13ca3c4fe5c37b6989225d99","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-6ec69bc6d214d048bd767c9d13ca3c4fe5c37b6989225d99.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-6ec69bc6d214d048bd767c9d13ca3c4fe5c37b6989225d99\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Every shell call must include a timeout, and the default is 'wait forever' \u2014 exactly what you're preventing. Ensure no `more`, `less`, `pause`, `choice`, or `start \/WAIT` commands are used in scripts run by agents.","instructions":"---\nname: shell-safety\ndescription: '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. \u9632\u6b62\u4ea4\u4e92\u5f0f\u547d\u4ee4\u51bb\u7ed3 agent \u4f1a\u8bdd\uff0c\u63d0\u4f9b\u5b89\u5168\u66ff\u4ee3\u3002'\nkeywords: [shell, safety, command, sandbox, \u5b89\u5168, \u547d\u4ee4]\n---\n# Shell-Safety\n\n## Overview\n\nPrevent 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.\n\nThis skill enforces a hard ban on interactive commands and provides non-interactive equivalents for every common use case.\n\n## Ban List (NEVER use these)\n\n| Command \/ Pattern    | Why banned                          |\n|----------------------|-------------------------------------|\n| `more`               | Paginates, waits for keypress       |\n| `more.com`           | Same as `more` (explicit extension) |\n| `less`               | Paginates, waits for keypress       |\n| `pause`              | \"Press any key to continue...\"      |\n| `choice`             | Interactive menu prompt             |\n| `start \/WAIT app`    | Waits for GUI window to close       |\n| `cmd ... \\| more`    | Pipe into pager = indefinite block  |\n| `* \\| more +N`       | Skip-N pager variant, same effect   |\n\n**Any command that requires human interaction is forbidden in a headless agent shell.** Assume the shell has no keyboard or display.\n\n## Safe Replacements\n\n### Counting matches \/ lines\n\n```cmd\n:: Banned\nfindstr \/i \"pattern\" file | more +0 | find \/c \"pattern\"\n\n:: Correct (native find \/c)\nfindstr \/i \"pattern\" file | find \/c \/v \"\"\n```\n\n```powershell\n# Single line counting\n(Select-String -Path file -Pattern 'pattern').Count\n```\n\n### Viewing output (non-interactive full dump)\n\n```cmd\n:: Banned\ntype file | more\nmore file\n\n:: Correct\ntype file\n```\n\n### Pause \/ confirmation \u2014 NEVER use in scripts run by agents\n\n```cmd\n:: Banned\npause\n\n:: Correct: just skip it. The agent doesn't need human confirmation mid-script.\nrem (remove the pause entirely)\n```\n\n### Waiting for external processes\n\n```cmd\n:: Banned\nstart \/WAIT notepad.exe\n\n:: Correct: timeout-controlled wait for known processes\ntimeout \/T 10 \/NOBREAK\ntasklist | findstr processname\n```\n\n## Timeout Rule (MANDATORY)\n\nEvery shell call MUST include a timeout. This is the hard kill switch:\n\n```text\nrun_shell(command=\"...\", timeout_ms=60000)   # 60s max\n```\n\n- Short lookups (findstr on small files): `timeout_ms=15000`\n- Medium scans (grep on <100 files): `timeout_ms=30000`\n- Long commands (builds, tests): `timeout_ms=300000` (5 min)\n- Never omit the timeout. The default is \"wait forever\" \u2014 exactly what you're preventing.\n\n## Pre-Flight Checklist (before every shell call)\n\n1. [ ] No `more`, `less`, `pause`, `choice`, `start \/WAIT` anywhere in the command string or pipeline\n2. [ ] No `more.com` explicit extension (PATH shims can't intercept it)\n3. [ ] A timeout is set and reasonable for the expected runtime\n4. [ ] If counting\/filtering: use `find \/c \/v \"\"` or PowerShell `Select-String` + `.Count` instead of piping through pagers\n5. [ ] If viewing output: `type` (Windows) or `cat` (cross-platform) \u2014 NEVER pipe to a pager\n\n## Why This Exists\n\nA real incident: an agent session froze for 12+ minutes because the model generated:\n\n```cmd\nfindstr \/i \"\/api\/health\" logs\\endpoint_hits.jsonl | more +0 | find \/c \"\/api\/health\"\n```\n\n`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 \u2014 the only recovery was externally killing the `findstr` and `more.com` processes.\n\nThis 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.\n","use_cases":["Running shell commands in headless agent environments","Diagnosing and resolving session freezes caused by interactive CLI commands","Choosing safe CLI alternatives for non-interactive execution"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/chenyinrusi\/dsh-engineering-skills\/blob\/86d622bfbebb228269ad2b906c44069fd492397f\/skills\/shell-safety\/SKILL.md","source_commit":"86d622bfbebb228269ad2b906c44069fd492397f","license":null,"version":null,"listing_approved_at":"2026-11-28","created_at":"2026-11-28T07:59:23.000000Z","updated_at":"2026-11-28T18:37:41.000000Z","seo_title":"Shell Safety - Prevent Interactive CLI Commands from Freezing Agent","seo_description":"Ensure safe shell execution by banning interactive CLI commands and enforcing timeouts. Prevent agent session freezes with non-interactive alternatives and a pre-flight","seo_keywords":["shell","safety","command","sandbox","\u5b89\u5168","\u547d\u4ee4"]}}