baphuongna/pi-crew/safe-bash
Claude Code and agent skill by baphuongna/pi-crew
- community
Checking that the SKILL.md file is still in the repository.
Safe shell-command workflow. When NOT to use: subprocess orchestration (use child-pi-spawning); destructive operations without sandbox (use ownership-session-security).
Install
npx vskill@latest install baphuongna/pi-crew/safe-bashSKILL.md
safe-bash
Use this skill whenever a task may execute shell commands. This skill covers cross-platform shell safety, destructive action confirmation, and Windows-specific patterns.
Classification
Every shell command is either read-only or mutating. Always report which it is.
Read-only commands (safe)
Mutating commands (require confirmation)
Cross-Platform Considerations
Windows vs Unix paths
argv vs cmd /c
Package manager detection
Heredoc and Quoting Gotchas
Quoting variables in commands
Heredoc in scripts
Timeout and Background Execution
Timeout long-running commands
Background vs foreground
Signal Handling
SIGTERM vs SIGKILL
| Signal | Effect | Use case | |
|---|---|---|---|
| SIGTERM (15) | Graceful termination request | Normal shutdown | |
| SIGKILL (9) | Immediate forced termination | Unresponsive process | |
| SIGINT (2) | Interrupt (Ctrl+C) | User cancel |
Child process inheritance
When spawning subprocesses, child processes inherit the parent's signal handlers. Use signal: controller.signal in Node.js to give the child its own abort signal.
Sudo and Interactive Prompts
Detecting interactive prompts
Avoiding sudo prompts in scripts
Error Trapping
set -e and set -o pipefail
Capture and handle errors
ANSI Color Code Stripping
For log parsing, strip ANSI escape codes:
Or via shell:
Node.js vs Binary Detection
Destructive Action Confirmation
Never execute destructive commands without explicit confirmation:
| Command | Risk | Confirmation needed | |
|---|---|---|---|
rm -rf <path> | Permanent data loss | "Type the path to confirm" | |
git reset --hard | Undo all changes | "Confirm with: YES" | |
git clean -fd | Remove untracked files | "Confirm with: YES" | |
npm publish | Public package | "Confirm version X.Y.Z" |
Confirmation pattern:
Enforcement — Safe Bash Gate
Before executing shell commands, verify:
- [ ] Command classified as read-only or mutating (report which)
- [ ] Mutating/destructive commands have explicit confirmation before execution
- [ ] Paths use platform-safe construction (path.join, not hardcoded forward slashes)
- [ ] Timeout set for long-running commands (prevent blocking)
- [ ] Exit codes checked and errors handled appropriately
- [ ] Secrets not passed in command-line args (use environment variables)
If ANY answer is NO → Stop. Classify and protect before executing.
Anti-patterns
- `rm -rf` without path validation: Always double-check the path before rm -rf
- Blocking on subprocess: Always use async spawn with timeout
- Ignoring exit codes: Check
$?or captureexitCodefrom Node.js spawn - Leaking secrets in args: Use environment variables instead of command-line args
- Not handling Windows spaces: Test on Windows before assuming paths work
- Background process zombie: Always handle process exit or store the pid for cleanup
Source patterns
src/utils/resolve-shell.ts— cross-platform shell detectionsrc/runtime/child-pi.ts— spawn, killProcessPid, signal handlingsrc/worktree/worktree-manager.ts— git commands via execFileSyncsrc/config/defaults.ts— platform detection
Verification
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/safe-bash/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/baphuongna/pi-crew/safe-bash)