# Write Safer Shell Scripts

Shell scripts often fail because of quoting, error handling, and portability mistakes. This skill gives Claude, Codex, and Claude Code practical Bash and Zsh guidance for safer automation.

## Install

```bash
npx skillstore add codingkaiser/shell-scripting
```

## Metadata

- Status: approved
- Slug: codingkaiser-shell-scripting
- Skillstore revision: r1
- Version status: missing
- Tree hash: 698e54440adaee009e06aff2597603b86d4bd01ef38a31805d62c2b1f5d375c9
- Author: CodingKaiser
- GitHub username: CodingKaiser
- License: MIT
- Repository: https://github.com/CodingKaiser/claude-kaiser-skills/tree/main/shell-scripting
- Ref: 7db9b9f06e0ab79c575b58bc48c4d8dc9849f424
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: filesystem, external\_commands, network
- Quality score: 79
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/codingkaiser-shell-scripting
- Manifest: https://skillstore.pages.dev/api/skills/codingkaiser-shell-scripting/manifest

## Capabilities

- Explains Bash and Zsh script structure, strict mode, traps, and safer word splitting.
- Provides patterns for argument parsing, file iteration, input handling, and colored output.
- Suggests safer alternatives for common shell mistakes such as parsing ls or leaving variables unquoted.
- Includes reference patterns for files, arrays, processes, text processing, dates, network commands, and JSON handling.
- Provides a reusable Bash template with options, logging, cleanup, and command dispatch.

## Use Cases

- Build reliable automation scripts: Create Bash scripts with strict mode, argument parsing, cleanup traps, and predictable error behavior.
- Debug fragile shell commands: Find quoting, globbing, subshell, and pipeline problems in scripts before they affect users.
- Learn safer shell patterns: Use concise examples to understand file loops, process handling, text tools, and Zsh-specific features.

## Prompt Templates

### Create a simple Bash script

```
Help me write a Bash script that takes one directory argument, checks that it exists, and prints each text file safely.
```

### Review a script for common mistakes

```
Review this shell script for quoting, error handling, unsafe file loops, and portability issues. Explain each recommended change.
```

### Convert commands into reusable automation

```
Turn these manual terminal commands into a reusable Bash script with help text, dry-run mode, logging, and cleanup traps.
```

### Design a production script template

```
Design a robust Bash or Zsh script structure for a deployment workflow, including argument parsing, validation, rollback steps, and safe command execution.
```

## Limitations

- It provides guidance and examples, not a complete static analyzer for every shell script.
- Examples may require adaptation for Linux, macOS, Bash, or Zsh differences.
- It cannot guarantee safety for scripts that run commands on production systems.
- Network and filesystem examples should be reviewed before execution.

## Best Practices

- Ask the skill to explain why each shell pattern is safe before running it.
- Provide the target shell and operating system when requesting scripts.
- Review commands that write files, delete files, call networks, or manage processes before execution.

## Anti Patterns

- Do not paste generated scripts into production without reading every command.
- Do not use shell snippets with secrets, tokens, or private paths unless you have reviewed redaction and logging behavior.
- Do not ask for broad destructive commands when a scoped file or directory operation is enough.

## Security Audit

- Audited at: 2026-07-09T01:32:22.757\+00:00
- Summary: The static findings are shell syntax examples, reference snippets, and a standard Bash template rather than malicious behavior. No prompt injection, credential theft, hidden persistence, or unauthorized network exfiltration intent was found in the reviewed files.

## Stats

- Views: 180
- Downloads: 15
- Favorites: 2
- Popularity score: 0
