Bash
Writes, debugs, and hardens Bash shell scripts — quoting, arrays, strict mode, traps, argument parsing, and macOS/Linux portability. Use when writing or…
от clawic★ 23 звезды на GitHub
Установить Bash в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
User preferences live in ~/Clawic/data/bash/config.yaml (see Configuration); nothing else is stored on the user's machine. If you have data at an old location (~/bash/ or ~/clawic/bash/), move it to ~/Clawic/data/bash/, and say in one line that you moved it and from where.
When To Use
- Writing or reviewing any Bash beyond a one-liner: CI steps, deploy scripts, cron tasks, entrypoints, glue code
- Debugging scripts that break on spaces in filenames, fail silently, hang, or exit with the wrong code
- Hardening an existing script: strict mode, cleanup traps, argument parsing, re-runnability, portability
- Porting a script between macOS and Linux, or down to POSIX sh
- Deciding whether the task belongs in Bash at all (Core Rule 9)
- Not for POSIX-sh-only targets (dash, busybox, alpine
/bin/sh) — most patterns here are bashisms;portability.mdcovers the downgrade
Quick Reference
| Situation | Play |
|---|---|
| Breaks on spaces or hostile filenames | Quote every expansion, iterate with find -print0 + while IFS= read -r -d '' → quoting.md |
set -e missed a failure, cleanup never ran |
The five blind spots (conditions, ||/&&, $( ), ! cmd, exit in a subshell) → errors.md |
| Pipeline "fails" but each command worked | Exit code 141 = SIGPIPE from an early-exit consumer; PIPESTATUS names the segment → errors.md |
| Wrong output and you cannot see why | PS4='+ ${BASH_SOURCE##*/}:${LINENO}: ' bash -x script → debugging.md |
| Command built from variables misfires | Build it as an array (cmd=(rsync -a); cmd+=(--dry-run); "${cmd[@]}"), never as a string → quoting.md |
Comparison wrong: [ vs [[, numeric vs lexical |
10 < 9 is TRUE (lexical); numbers belong in (( )) or -lt → conditionals.md |
| Runs fine by hand, fails from cron | Cron has no login shell: minimal PATH, no profile, $HOME as cwd, % means newline → cron.md |
| Works locally, fails in the CI runner | Each step is a fresh non-interactive shell; strict mode does not carry over → ci.md |
| Script takes minutes on a large file | Count forks: one external command per line is the cost — batch into awk/sort → performance.md |
unbound variable / bad substitution / ambiguous redirect |
Symptom→cause chains → debugging.md |
| Must run on macOS stock bash or an old server | Version Floors below, then GNU-vs-BSD flags → portability.md |
Flags, --help, subcommands, usage exit codes |
getopts with a silent optstring, then shift $((OPTIND-1)) → arguments.md |
| Redirection order, heredocs, one-instance locking | Redirections apply left to right before the command runs → redirection.md |
| Paths, globs, temp files, deletes that must be safe | Resolve once with cd … && pwd -P; write temp + mv → files.md |
| Parsing CSV/JSON/logs, choosing awk vs sed vs jq | Per-line and stateless → one awk pass; never grep JSON → text-processing.md |
| Background jobs, signals, timeouts, N in parallel | pid=$! then wait "$pid"; xargs -P for fan-out → processes.md |
| String surgery: defaults, trim, replace, basename | Builtin expansions, no forks → expansion.md |
| Lists, dictionaries, sets, counters | mapfile -t to load, declare -A for maps → arrays.md |
| Splitting into functions or a sourced library | main "$@" behind a BASH_SOURCE guard; scope is dynamic → functions.md |
| Prompts, confirmations, color, progress | Gate every one of them on -t 1 → interactive.md |
| Calling an API, webhook, or health check | curl exits 0 on a 500 — capture %{http_code} and branch → http.md |
| Untrusted input, secrets, temp-file races, sudo | Keep values as data, never as syntax → security.md |
| Adding tests, stubbing commands, lint in CI | bash -n, shellcheck, then bats with PATH stubs → testing.md |
| Anything else | Core Rules below, then reproduce with bash -x on the smallest input that still fails |
Each file above is one sub-job and is self-contained: read SKILL.md by default, open exactly one guide when the situation matches.
Core Rules
- Open every script with
#!/usr/bin/env bashandset -euo pipefail, then learn the-eholes (errors.md) instead of dropping strict mode — the holes are enumerable; silent failures are not. - Quote every expansion:
"$var","$(cmd)","${arr[@]}". An unquoted expansion is a deliberate act that carries a comment saying why. Word splitting plus globbing is Bash's #1 bug class (shellcheck SC2086). - Build commands as arrays, never as strings.
opts="--exclude '*.log'"; rsync $opts src dstpasses the quotes as literal characters;opts=(--exclude '*.log'); rsync "${opts[@]}" src dstpasses--excludeand*.logas two clean arguments. Conditional flags append:$dry == 1 && opts+=(--dry-run). - Run shellcheck before shipping, blocking at
lint_gateseverity. Suppress only with the code and a reason on the same line: `# shellcheck disable=SC2086 -- flags must spli
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- _meta.json
- arguments.md
- arrays.md
- ci.md
- conditionals.md
- cron.md
- debugging.md
- errors.md
- expansion.md
- files.md
- functions.md
- http.md
- interactive.md
- performance.md
- portability.md
- processes.md
- quoting.md
- redirection.md
- security.md
- testing.md
- text-processing.md
FAQ
Что делает скилл Bash?
Writes, debugs, and hardens Bash shell scripts — quoting, arrays, strict mode, traps, argument parsing, and macOS/Linux portability. Use when writing or reviewing any script, one-liner, cron job, deploy script, container entrypoint, or CI step; when a script breaks on spaces in filenames, exits silently, ignores set -e, hangs, or returns the wrong exit code; when quoting, IFS, globs, arrays, heredocs, process substitution, trap, getopts, or mapfile misbehave; when shellcheck flags SC2086 and friends; when unbound variable, bad substitution, command not found, ambiguous redirect, or unexpected end of file show up; when a script works by hand but fails under cron, systemd, sudo, or a CI runner; or when porting between macOS bash 3.2, GNU/Linux, WSL, and POSIX sh. Not for interactive zsh or fish configuration, not for PowerShell, and not for host-level cron, systemd, or permission failures (linux).
Как установить скилл Bash?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Bash запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…