← Files Unix CopilotARCHIVED FILE

skills/write-shell-script/SKILL.md

1.81 KB · Nov 21, 2026 · 12:44 UTC

↓ Download file

See the change to this file →

---
name: write-shell-script
description: Author maintainable Bash, zsh or POSIX shell scripts with input checks, cleanup, safe paths and tests.
---

# Write a shell script

## Scope and execution truth
This is a skills-only assistant workflow. Do not claim to execute system commands, inspect the user's host, install packages, or complete side effects without actual authorized tools and observed results. User-pasted output is evidence, not a machine connection.

## Procedure
1. Decide shell/interpreter and portability requirement first. Use an explicit shebang and check declared dependencies.
2. Define arguments, input/output contracts, expected errors and idempotency before adding code.
3. Quote expansions; use `"$@"` or arrays where supported; protect leading-dash filenames and handle weird filenames where relevant.
4. Handle nonzero exit statuses explicitly for critical steps. `set -e` and `pipefail` are not magic guarantees; document shell-specific support.
5. Use secure temporary files, `trap` cleanup when needed, and stage → validate → publish for important outputs.
6. Add dry-run or preview mode for write operations when practical, plus simple representative tests and usage examples.

## Relevant references
- Read `../../references/shell-debugging.md` for domain-specific guidance.
- Read `../../references/shell-quoting.md` for domain-specific guidance.
- Read `../../references/automation-and-recovery.md` for domain-specific guidance.

## Completion checks
- Shell-specific features match shebang
- Failure and cleanup cases addressed
- Repeat-run behavior considered

## Deliverable
Use the minimum format that makes the answer actionable: the actual command or patch, platform assumptions, a preview before risky changes, and a reproducible validation step. Clearly label proposed actions versus observed execution.

SHA-256: 147fab5ce175cfa3f2bd6a7b8a4d6cf29372a85e9b86e1ef44ede60966ea5ad8