fabioc-aloha/alex-cognitive-architecture · Archived

terminal-command-safety

Safe terminal command patterns — backtick escaping, output capture, and hang prevention

First seen Jun 17, 2026

Installation

$ npx skills add fabioc-aloha/alex-cognitive-architecture --skill terminal-command-safety

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from fabioc-aloha/alex-cognitive-architecture · top by installs.

npx skills add fabioc-aloha/alex-cognitive-architecture

Browse all from fabioc-aloha/alex-cognitive-architecture

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

License LICENSE.md
Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,680 B
  • docs SUMMARY.md 120 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 8 installs

SKILL.md

Terminal Command Safety

Detailed patterns and examples for safe terminal command execution in AI agent contexts.

Backtick Hazard — Details

Backticks in terminal command arguments break across all shells:

  • bash/zsh: backtick = command substitution (echo "use ls here" executes ls)
  • PowerShell: backtick = escape character (echo "use n here"` inserts newline)

Ref: vscode#295620

Safe Pattern (bash)

# Write content to temp file (single-quoted delimiter prevents interpolation)
cat > /tmp/body.md << 'EOF'
## Changes
- Added `MyClass` to the module
- Updated `config.py`
EOF

# Pass file to command
gh pr create --title "My PR" --body-file /tmp/body.md
rm /tmp/body.md

Safe Pattern (PowerShell)

$body = @'
## Changes
- Added `MyClass` to the module
'@
$body | Out-File -Encoding utf8 "$env:TEMP\body.md"
gh pr create --title "My PR" --body-file "$env:TEMP\body.md"
Remove-Item "$env:TEMP\body.md"

Output Capture — Examples

Refs: vscode#308610, vscode#308048, vscode#307173

Redirect to file

npm run build 2>&1 | Out-File -Encoding utf8 "$env:TEMP\build-output.txt"
Get-Content "$env:TEMP\build-output.txt" -Tail 50

Pipe through Out-String

git log --oneline -20 | Out-String

Sentinel pattern

npm test 2>&1; echo "EXIT_CODE:$LASTEXITCODE"

Alt-buffer avoidance

  • git log not git log | less (set $env:GIT_PAGER="cat")
  • Get-Help not man
  • gh issue view --json not gh issue view (which opens a pager)

Terminal Hanging — Examples

Refs: vscode#308610, vscode#306490

Async mode selection

mode=async for: npm start, dotnet run, docker compose up, long test suites
mode=sync with timeout=30000 for: npm install, git operations, single test files

Pre-answer interactive prompts

npm install --yes
rm -rf (not rm -ri)
az login --use-device-code
git commit --no-edit (merge commits)

Network timeouts

npm install --prefer-offline --no-audit
curl --max-time 30 --connect-timeout 10 $url