# Write Safer Shell Scripts

Shell scripts often fail because of quoting, error handling, and unclear input rules. This skill gives Claude, Codex, and Claude Code practical Bash and zsh patterns for safer automation.

## Install

```bash
npx skillstore add joseph obrien/89jobrien-shell-scripting
```

## Metadata

- Status: approved
- Slug: 89jobrien-shell-scripting
- Version: 1.0.1
- Author version: 1.0.1
- Skillstore revision: r1
- Version status: valid
- Tree hash: 2bff3fac40f5871ee53810e0bed2c687d740557abc43b87da231a18e8235728f
- Author: Joseph OBrien
- GitHub username: 89jobrien
- License: MIT
- Repository: https://github.com/89jobrien/steve/tree/main/steve/skills/shell-scripting
- Ref: 7db9b9f06e0ab79c575b58bc48c4d8dc9849f424
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: blocked
- Manual install advisory: allowed\_with\_warning
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem
- Quality score: 38
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/89jobrien-shell-scripting
- Manifest: https://skillstore.pages.dev/api/skills/89jobrien-shell-scripting/manifest

## Capabilities

- Provides a reusable Bash script template with strict mode, help output, and main function structure.
- Explains error handling with set options, cleanup traps, and explicit command failure checks.
- Shows safe variable expansion, arrays, associative arrays, conditionals, and loop patterns.
- Covers input prompts, file reading, output redirection, and common text processing tools.
- Lists practical do and do not guidance for quoting, ShellCheck, eval, and maintainable scripts.

## Use Cases

- Create reliable automation scripts: Use the template and strict-mode guidance to build scripts for repeated local or CI tasks.
- Debug shell command failures: Apply the error handling and logging patterns to find where a script fails and why.
- Build small command-line tools: Use argument parsing, help output, and exit-code guidance to create simple team utilities.

## Prompt Templates

### Begin a safe script

```
Use the shell-scripting skill to draft a Bash script template for my task. Include strict mode, usage help, argument parsing, logging, and dry-run support.
```

### Improve an existing script

```
Review this shell script with the shell-scripting skill. Focus on quoting, strict mode, cleanup traps, exit handling, and unsafe input assumptions.
```

### Automate file processing

```
Use the shell-scripting skill to design a Bash workflow that processes these files. Show safe loops, input handling, output redirection, and clear failure behavior.
```

### Design a production CLI helper

```
Use the shell-scripting skill to plan a production-ready Bash CLI helper. Include subcommands, validation boundaries, logging, cleanup, test ideas, and ShellCheck considerations.
```

## Limitations

- It is documentation only and does not run ShellCheck or execute tests for generated scripts.
- Examples are focused on Bash and zsh, not fish, PowerShell, or Windows batch files.
- It does not include a full testing framework for shell scripts.
- One included awk example should be changed before publication because it reads /etc/passwd.

## Best Practices

- Ask for the target shell and operating system before generating commands that depend on platform behavior.
- Use dry-run mode for scripts that modify files, deployments, or system state.
- Run ShellCheck and a small test case before using generated scripts on real data.

## Anti Patterns

- Do not paste generated destructive commands into a production shell without review and a dry run.
- Do not use eval or unquoted variables with user-controlled input.
- Do not treat short shell examples as complete security-reviewed production scripts.

## Security Audit

- Audited at: 2026-07-09T01:46:49.423\+00:00
- Summary: Most static findings are false positives caused by Markdown code fences, inline shell syntax, and benign shell examples. One finding is confirmed: the text processing example reads /etc/passwd, which is a sensitive host file and should not appear as a general-purpose scripting example.

## Stats

- Views: 267
- Downloads: 13
- Favorites: 1
- Popularity score: 0
