Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Shell Scripting

BSecurity

Specialized knowledge of Bash and Zsh scripting, shell automation, command-line tools, and scripting best practices. Use when the user needs to write, debug, or optimize shell scripts, work with command-line tools, automate tasks with bash/zsh, or asks for shell script help.

416 stars
0 votes
0 copies
3 views
Added 2/7/2026
developmentrustshellbashgitsecurityperformance

Security Analysis

B85/100
highPerforms destructive filesystem operations

Pro scans all 5 files and shows the line behind each finding

Scanned 2/12/2026

$npx -y skills add aiskillstore/marketplace --skill shell-scripting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Shell Scripting?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Shell Scripting
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/aiskillstore-shell-scripting/badge)](https://www.skillsdirectory.com/skills/aiskillstore-shell-scripting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: shell-scripting
description: Specialized knowledge of Bash and Zsh scripting, shell automation, command-line tools, and scripting best practices. Use when the user needs to write, debug, or optimize shell scripts, work with command-line tools, automate tasks with bash/zsh, or asks for shell script help.
---

# Shell Scripting Expert

Expert guidance for writing robust, maintainable Bash and Zsh scripts with best practices for automation and command-line tool usage.

## Script Structure Essentials

Start every script with:
```bash
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
```

- `set -e`: Exit on error
- `set -u`: Error on undefined variables
- `set -o pipefail`: Catch errors in pipes
- `IFS=$'\n\t'`: Safer word splitting

## Critical Best Practices

1. **Always quote variables**: `"$variable"` not `$variable`
2. **Use `[[` for conditionals** (Bash): `if [[ "$var" == "value" ]]; then`
3. **Check command existence**: `if command -v git &> /dev/null; then`
4. **Avoid parsing `ls`**: Use globs or `find` instead
5. **Use arrays for lists**: `files=("file1" "file2")` not space-separated strings
6. **Handle errors with traps**:
   ```bash
   trap cleanup EXIT
   trap 'echo "Error on line $LINENO"' ERR
   ```

## Common Patterns

### Argument Parsing
```bash
while [[ $# -gt 0 ]]; do
    case $1 in
        -h|--help) usage; exit 0 ;;
        -v|--verbose) VERBOSE=true; shift ;;
        -*) echo "Unknown option: $1"; exit 1 ;;
        *) break ;;
    esac
done
```

### Safe File Iteration
```bash
# Prefer this (handles spaces, newlines correctly):
while IFS= read -r -d '' file; do
    echo "Processing: $file"
done < <(find . -type f -name "*.txt" -print0)

# Or with simple globs:
for file in *.txt; do
    [[ -e "$file" ]] || continue  # Skip if no matches
    echo "Processing: $file"
done
```

### User Confirmation
```bash
read -rp "Continue? [y/N] " response
if [[ "$response" =~ ^[Yy]$ ]]; then
    echo "Continuing..."
fi
```

### Colored Output
```bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'  # No Color

echo -e "${GREEN}Success${NC}"
echo -e "${RED}Error${NC}" >&2
```

## Modern Tool Alternatives

When appropriate, suggest these modern replacements:
- `ripgrep` (rg) → faster than grep
- `fd` → faster than find
- `fzf` → interactive filtering
- `jq` → JSON processing
- `yq` → YAML processing
- `bat` → cat with syntax highlighting
- `eza` → enhanced ls

## Function Organization

```bash
usage() {
    cat <<EOF
Usage: ${0##*/} [OPTIONS] <args>
Description of what this script does.
OPTIONS:
    -h, --help      Show this help
    -v, --verbose   Verbose output
EOF
}

main() {
    # Main logic here
    :
}
```

## Zsh-Specific Features

When user specifies Zsh:
- Advanced globbing: `**/*.txt` (recursive), `*.txt~*test*` (exclude pattern)
- Parameter expansion: `${var:u}` (uppercase), `${var:l}` (lowercase)
- Associative arrays: `typeset -A hash; hash[key]=value`
- Extended globbing: Enable with `setopt extended_glob`

## Security Considerations

- **Never** `eval` untrusted input
- Validate user input before use
- Use `mktemp` for temporary files: `TEMP_FILE=$(mktemp)`
- Be explicit with `rm -rf` operations
- Check for TOCTOU (Time-Of-Check-Time-Of-Use) race conditions
- Don't store secrets in scripts; use environment variables or secret managers

## Performance Tips

- Use built-ins over external commands (`[[ ]]` vs `test`, `$(( ))` vs `expr`)
- Avoid unnecessary subshells: `var=$(cat file)` → `var=$(<file)`
- Use `read` not `cat | while`: `while read -r line; do ... done < file`
- Consider `xargs -P` or GNU `parallel` for parallel processing

## Quick Reference Template

See references/template.sh for a complete, production-ready script template with all best practices incorporated.

Attribution

aiskillstoreaiskillstore
View sourceSee grades on GitHubMore from aiskillstore →
SSkills Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills Directory ProSkills Directory

Get any skill into Claude in one click.

Download any skill as a ZIP for Claude.ai, Claude Desktop, or .claude/skills. $9/mo.

See Pro

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

285172 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10341 votes
View all in development →