· Write/debug shell commands, scripts, dotfiles, completions for zsh, bash, POSIX sh, fish. Triggers: 'shell', 'script', '.zshrc', '.bashrc', 'alias', 'completion', 'trap'. Not for CI blocks (use ci-cd).
Installation
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Reference skill for writing commands, scripts, and configuration across Unix shells. Detects
the target shell from context and routes to the appropriate reference.
Golden rule: when in doubt, double-quote. "$var" is almost always correct. Unquoted $var
causes word splitting (in sh/bash) or glob expansion.
Exit codes
Code
Meaning
0
Success
1
General error
2
Misuse of shell builtin
126
Command found but not executable
127
Command not found
128+N
Killed by signal N (e.g., 130 = Ctrl+C / SIGINT)
Common portable idioms
# Check if command existscommand -v git >/dev/null 2>&1 || { echo"git required" >&2; exit 1; }
# Default variable value
: "${VAR:=default}"# set VAR to "default" if unset or empty
name="${1:-anonymous}"# parameter default# Temporary file (portable)
tmpfile=$(mktemp) || exit 1
trap'rm -f "$tmpfile"' EXIT
# Read file line by linewhile IFS= read -r line; doprintf'%s\n'"$line"done < file.txt
# Loop over glob resultsfor f in *.txt; do
[ -e "$f" ] || continue# guard against no matches (POSIX sh)echo"$f"done
Completions Quick Reference (Zsh)
Zsh's completion system (compsys) handles subcommand routing natively. Minimal working
example for a CLI tool with subcommands:
#compdef mycli_mycli() {
local -a subcmds=(
'init:Initialize a new project''build:Build the project''deploy:Deploy to target environment'
)
_arguments -C \
'(-h --help)'{-h,--help}'[Show help]' \
'1:command:->subcmd' \
'*::arg:->args'case$statein
subcmd) _describe 'command' subcmds ;;
args)
case$words[1] in
deploy) _arguments '--env[Target environment]:env:(dev staging prod)' ;;
esac
;;
esac
}
Place in a file named _mycli on your fpath, then ensure the directory is registered:
# In .zshrc, BEFORE compinit:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
Or source inline with compdef _mycli mycli (no fpath needed). The reference files have
deeper coverage: glob-qualified completions, _files, _hosts, _values, and async
completion patterns.
Verification Checklist
Before returning any shell script, check:
Shebang matches the target shell.#!/usr/bin/env bash for bash, #!/usr/bin/env zsh for zsh, #!/bin/sh for POSIX sh. Never #!/bin/bash (not portable across distros).
set -euo pipefail present for bash and zsh scripts. For POSIX sh: set -eu (no pipefail).
Variables are quoted."$var" not $var, unless word splitting is intentional.
No shell-isms in the wrong shell. No [[ ]] in #!/bin/sh. No BASH_SOURCE in zsh. No bash arrays in POSIX sh.
Glob safety. POSIX sh: guard with [ -e "$f" ] || continue. Zsh: use (N) qualifier. Bash: shopt -s nullglob or guard.
Array indexing matches the shell. Bash: 0-indexed. Zsh: 1-indexed. POSIX sh: no arrays.
printf over echo for anything non-trivial (echo behavior varies across shells and platforms).
references/ssh-tmux-autostart.md - safe shell startup pattern for interactive SSH sessions that attach to tmux without breaking non-interactive commands
Output Contract
See references/output-contract.md for the full contract.
Skill name: COMMAND-PROMPT
Deliverable bucket:audits
Mode: conditional. When invoked to analyze, review, audit, or improve existing repo content, emit the full contract - boxed inline header, body summary inline plus per-finding detail in the deliverable file, boxed conclusion, conclusion table - and write the deliverable to docs/local/audits/command-prompt/<YYYY-MM-DD>-<slug>.md. When invoked to write a script, dotfile, or completion / answer a question / teach a concept, respond freely: deliver the artifact or explanation inline without the contract, deliverable file, or conclusion table.
Severity scale:P0 | P1 | P2 | P3 | info (see shared contract; only used in audit/review mode).
Related Skills
firewall-appliance - OPNsense/pfSense uses tcsh/csh on FreeBSD. That skill handles the BSD firewall context; this skill covers tcsh syntax in general.
ansible - Ansible shell/command modules have their own idiosyncrasies beyond raw shell scripting. Use ansible for playbook work.
ci-cd - CI shell blocks run in restricted environments (no interactive features, possibly no bash). Use ci-cd for pipeline design; use this skill for the shell syntax within them.
networking - Linux network configuration (interfaces, routes, firewalls, DNS). Use networking for service and protocol administration; use this skill for the shell scripts that wrap or automate those tasks.
debian-ubuntu - Debian/Ubuntu system administration (packages, services, cloud-init). Use debian-ubuntu for distro-level operations; use this skill for the shell scripting patterns within those tasks.
rhel-fedora - RHEL/Fedora system administration (dnf, systemd, SELinux, subscription-manager). Use rhel-fedora for distro-level operations; use this skill for the shell scripting patterns within those tasks.
Rules
Detect the shell first. Check shebang, file extension, or ask. Don't assume bash when the user might mean zsh.
Load the right reference. Don't wing zsh arrays or bash parameter expansion from memory - the subtle differences justify loading the reference every time.
Shebang is #!/usr/bin/env <shell>. Not #!/bin/bash. The env form is portable across distros. Exception: #!/bin/sh for POSIX scripts (this IS the standard form).
set -euo pipefail in every bash/zsh script. No exceptions for scripts beyond a one-liner.
User's interactive shell is zsh. When writing commands for the user to run locally, use zsh syntax. Bash for scripts and remote machines unless the script specifically needs zsh.
Don't mix shell syntaxes. A bash script uses bash idioms. A zsh script uses zsh idioms. "Works in both" compromises use neither well and confuse readers.
Quote your variables."$var" is the default. Unquoted $var is the exception that needs justification.