Use this skill when the task matches the trigger condition described in description.
Do not use this skill when the primary task falls outside this skill's domain.
Use this skill to write and review Zsh scripts that intentionally rely on Zsh behavior while staying safe and maintainable.
Trigger And Co-activation Reference
If available, use references/trigger-matrix.md for canonical co-activation rules.
If available, resolve style-guide activation from changed files with python3 scripts/resolve_style_guides.py <changed-path>....
If available, validate trigger matrix consistency with python3 scripts/validate_trigger_matrix_sync.py.
Quality Gate Command Reference
If available, use references/quality-gate-command-matrix.md for CI check-only and local autofix mapping.
Quick Start Snippets
Script skeleton for Zsh entrypoints
#!/usr/bin/env zsh
set -euo pipefail
SCRIPT_NAME="${0:t}"
TEMP_DIR="$(mktemp -d)"
cleanup() {
rm -rf -- "${TEMP_DIR}"
}
on_error() {
local line_number="$1"
local exit_code="$2"
print -u2 -- "${SCRIPT_NAME}: failed at line ${line_number} (exit=${exit_code})"
}
trap cleanup EXIT
TRAPERR() {
on_error "$LINENO" "$?"
}
main() {
print -- "temp dir: ${TEMP_DIR}"
}
main "$@"
Required environment variable check
: "${API_TOKEN:?API_TOKEN is required}"
: "${API_BASE_URL:?API_BASE_URL is required}"
Safe external command with arrays
local -a curl_args=(
--fail
--silent
--show-error
--header "Authorization: Bearer ${API_TOKEN}"
"${url}"
)
curl "${curl_args[@]}"
Bounded retry helper
typeset -ri MAX_ATTEMPTS=5
typeset -ri RETRY_DELAY_SECONDS=2
retry_command() {
local -i attempt=1
while (( attempt <= MAX_ATTEMPTS )); do
if "$@"; then
return 0
fi
if (( attempt == MAX_ATTEMPTS )); then
print -u2 -- "command failed after ${MAX_ATTEMPTS} attempts"
return 1
fi
sleep "${RETRY_DELAY_SECONDS}"
(( attempt++ ))
done
}
Structure And Readability
Use explicit Zsh shebang for executable scripts.
Use strict mode for executable entrypoints.
Keep functions small and orchestration in main.
Use local and typed variables where it improves safety.
Keep comments short and focused on intent.
Data Handling And Quoting
Quote parameter expansions by default.
Use arrays for argument safety.
Avoid eval unless unavoidable and validated.
Replace magic numbers with named constants including units.
Validate external input before command execution.
Error Handling And Safety
Use explicit failure paths and non-zero return codes.
Use trap-based cleanup for temporary resources.
Avoid silent suppression patterns.
Fail early for missing required configuration.
Avoid exposing secrets in logs.
Testing And Verification
Add shell tests (zunit/project equivalent) for core and failure paths.
Document manual verification when automation is insufficient.
Check idempotency for scripts run by automation.
CI Required Quality Gates (check-only)
Run zsh -n on modified scripts.
Run lint checks configured by the repository (shellcheck where applicable).
Run shell tests (zunit/project equivalent).
Reject changes that hide failures or rely on implicit behavior.
Optional Autofix Commands (local)
Run repository formatter/lint autofix commands where available.
Re-run all check-only gates after autofix.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: kentoshimizu-sw-agent-skills-zsh-style-guide3description: ZSH Style Guide4---56# ZSH Style Guide78## Scope Boundaries9- Use this skill when the task matches the trigger condition described in `description`.10- Do not use this skill when the primary task falls outside this skill's domain.1112Use this skill to write and review Zsh scripts that intentionally rely on Zsh behavior while staying safe and maintainable.1314## Trigger And Co-activation Reference1516- If available, use `references/trigger-matrix.md` for canonical co-activation rules.17- If available, resolve style-guide activation from changed files with `python3 scripts/resolve_style_guides.py <changed-path>...`.18- If available, validate trigger matrix consistency with `python3 scripts/validate_trigger_matrix_sync.py`.1920## Quality Gate Command Reference2122- If available, use `references/quality-gate-command-matrix.md` for CI check-only and local autofix mapping.2324## Quick Start Snippets2526### Script skeleton for Zsh entrypoints2728```zsh29#!/usr/bin/env zsh30set -euo pipefail3132SCRIPT_NAME="${0:t}"33TEMP_DIR="$(mktemp -d)"3435cleanup() {36 rm -rf -- "${TEMP_DIR}"37}3839on_error() {40 local line_number="$1"41 local exit_code="$2"42 print -u2 -- "${SCRIPT_NAME}: failed at line ${line_number} (exit=${exit_code})"43}4445trap cleanup EXIT46TRAPERR() {47 on_error "$LINENO" "$?"48}4950main() {51 print -- "temp dir: ${TEMP_DIR}"52}5354main "$@"55```5657### Required environment variable check5859```zsh60: "${API_TOKEN:?API_TOKEN is required}"61: "${API_BASE_URL:?API_BASE_URL is required}"62```6364### Safe external command with arrays6566```zsh67local -a curl_args=(68 --fail69 --silent70 --show-error71 --header "Authorization: Bearer ${API_TOKEN}"72 "${url}"73)7475curl "${curl_args[@]}"76```7778### Bounded retry helper7980```zsh81typeset -ri MAX_ATTEMPTS=582typeset -ri RETRY_DELAY_SECONDS=28384retry_command() {85 local -i attempt=186 while (( attempt <= MAX_ATTEMPTS )); do87 if "$@"; then88 return 089 fi9091 if (( attempt == MAX_ATTEMPTS )); then92 print -u2 -- "command failed after ${MAX_ATTEMPTS} attempts"93 return 194 fi9596 sleep "${RETRY_DELAY_SECONDS}"97 (( attempt++ ))98 done99}100```101102## Structure And Readability1031041. Use explicit Zsh shebang for executable scripts.1052. Use strict mode for executable entrypoints.1063. Keep functions small and orchestration in `main`.1074. Use `local` and typed variables where it improves safety.1085. Keep comments short and focused on intent.109110## Data Handling And Quoting1111121. Quote parameter expansions by default.1132. Use arrays for argument safety.1143. Avoid `eval` unless unavoidable and validated.1154. Replace magic numbers with named constants including units.1165. Validate external input before command execution.117118## Error Handling And Safety1191201. Use explicit failure paths and non-zero return codes.1212. Use trap-based cleanup for temporary resources.1223. Avoid silent suppression patterns.1234. Fail early for missing required configuration.1245. Avoid exposing secrets in logs.125126## Testing And Verification1271281. Add shell tests (`zunit`/project equivalent) for core and failure paths.1292. Cover edge cases: empty input, whitespace paths, missing env vars, timeout/retry exhaustion.1303. Document manual verification when automation is insufficient.1314. Check idempotency for scripts run by automation.132133## CI Required Quality Gates (check-only)1341351. Run `zsh -n` on modified scripts.1362. Run lint checks configured by the repository (`shellcheck` where applicable).1373. Run shell tests (`zunit`/project equivalent).1384. Reject changes that hide failures or rely on implicit behavior.139140## Optional Autofix Commands (local)1411421. Run repository formatter/lint autofix commands where available.1432. Re-run all check-only gates after autofix.144145---146> Converted and distributed by [TomeVault](https://tomevault.io/claim/kentoshimizu) — claim your Tome and manage your conversions.147<!-- tomevault:4.0:skill_md:2026-04-16 -->
Run npx skillmds@latest add tomevault-io/kentoshimizu-sw-agent-skills-zsh-style-guide in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
ZSH Style Guide It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.