Skip to main content
skill CX Codex

bash-scripting · mindrally — Bash skill for Claude Code: scripting rules

This skill gives the agent rules for writing Bash scripts: input validation, error handling, portability. Useful when the agent writes deploy, backup or cron tasks.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Mindrally/skills --skill bash-scripting -a claude-code
Open on GitHub

What bash-scripting does

The skill turns the agent into a careful shell script author. It requires set -euo pipefail, trap for cleaning up temporary files, and explicit checks of return codes. Variable names use lowercase with underscores, and every major section or function gets a comment.

What's inside is a set of guidelines, not ready-made scripts. Input is validated with getopts or manual checks, and every variable expansion is quoted to avoid word splitting. For linting the skill points to shellcheck; for portability it asks for POSIX-compliant syntax. Output is split between stdout and stderr and redirected to log files.

A separate block covers automation: cron jobs with authentication, SCP/SFTP transfers over key-based auth, lock files against concurrent runs. If your project has deployment or provisioning scripts, this skill is worth installing — the agent stops writing one-liners with no error checks.

What it helps with

  • The agent writes a Bash script with no error handling and it fails silently halfway through.
  • You need command-line argument validation via getopts.
  • The script must run across different shells, not just bash.
  • Temporary files are left behind after a failure — you need trap cleanup.
  • A cron job runs twice in parallel and needs a lock file.

Example prompts for the agent

  • Write a backup_files.sh script with set -euo pipefail and a trap for temp file cleanup.
  • Add getopts argument validation to the script with clear error messages.
  • Check this script for portability and suggest shellcheck fixes.

How to install bash-scripting

1Skills CLI (Vercel)

npx skills add Mindrally/skills --skill bash-scripting -a claude-code

2Manually: put the files in place

~/.claude/skills/bash-scripting/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/bash-scripting/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about bash-scripting

How do I install bash-scripting in Claude?

Run npx skills add Mindrally/skills --skill bash-scripting -a claude-code. The skill file lands at ~/.claude/skills/bash-scripting/SKILL.md.

What does this skill actually do?

It gives the agent rules for Bash scripts: input validation, strict error handling, portability, logging and safe automation.

Why does it require set -euo pipefail?

The skill uses it for strict error handling: the script stops on a failed command, an unset variable or a pipeline error.

Source text

SKILL.md · Apache-2.0
---
name: bash-scripting
description: Bash scripting guidelines covering security, portability, error handling, and automation best practices for DevOps.
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Bash Scripting

You are an expert in Bash scripting with deep knowledge of shell programming, automation, and DevOps practices.

## Core Principles

- Write portable, maintainable scripts
- Prioritize security and input validation
- Use proper error handling throughout
- Follow consistent naming and formatting

## Naming & Structure

- Use descriptive names for scripts and variables (e.g., `backup_files.sh`, `log_rotation`)
- Employ modular scripts with functions to enhance readability and facilitate reuse
- Include comments for each major section or function
- Use lowercase with underscores for variable names

## Input Validation & Security

- Validate all inputs using `getopts` or manual validation logic
- Avoid hardcoding; use environment variables or parameterized inputs
- Apply the principle of least privilege in access and permissions
- Quote all variable expansions to prevent word splitting
- Sanitize user input before use

## Code Quality

- Ensure portability by using POSIX-compliant syntax
- Use `shellcheck` to lint scripts and improve quality
- Redirect output to log files where appropriate, separating stdout and stderr
- Use meaningful exit codes

## Error Handling & Cleanup

- Use `trap` for error handling and cleaning up temporary files
- Implement `set -euo pipefail` for strict error handling
- Check command return codes explicitly when needed
- Provide informative error messages

## Best Practices

```bash
#!/usr/bin/env bash
set -euo pipefail

# Trap for cleanup
trap cleanup EXIT

cleanup() {
    # Clean up temporary files
    rm -f "${TEMP_FILE:-}"
}

# Use functions for modularity
main() {
    validate_input "$@"
    process_data
}

validate_input() {
    [[ $# -lt 1 ]] && { echo "Usage: $0 <arg>"; exit 1; }
}

main "$@"
```

## Automation Best Practices

- Automate cron jobs securely with proper authentication
- Use SCP/SFTP for remote transfers with key-based authentication
- Implement proper logging for auditing
- Use lock files to prevent concurrent execution

## Specific Use Cases

- Automate VM or container provisioning
- Bootstrap servers and configure environments
- Manage backups with reliable, auditable processes
- Implement deployment scripts with rollback capability

© Mindrally · Apache-2.0 · Mindrally/skills

Similar skills

Everything for DevOps and infrastructure →

bash-scripting by other authors comes first.

From the same set168

mongodb-development MongoDB development rules: schemas, indexes, aggregation pipelines, Mongoose and Payload CMS. Useful when the agent writes a TypeScript backend. CX Codex +1 891installs scikit-learn-best-practices A skill that hands your agent scikit-learn conventions: pipelines, cross-validation, metrics, model persistence. Useful when you write ML code in Python. CX Codex +1 888installs astro A skill that tells the agent how to build Astro sites: static generation, partial hydration, file-based routing and as little client-side JavaScript as possible. CX Codex +1 886installs beautifulsoup-parsing Teaches AI agents to parse HTML and XML with BeautifulSoup in Python. Helps write cleaner scrapers with safe data extraction and DOM navigation. CX Codex +1 877installs swr SWR data-fetching guidelines for React and TypeScript apps. It guides agents on caching, request deduplication, and optimistic mutations. CX Codex +1 870installs django-rest-api-development A skill that gives your coding agent a house style for Django REST APIs: project layout, serializers, JWT auth and query performance. CX Codex +1 868installs data-jupyter-python Tells your agent how to write data analysis code: pandas and numpy, matplotlib and seaborn plots, reproducible notebooks, fewer loops. CX Codex +1 865installs openai-api-development A skill that steers your coding agent through Anthropic API work: Claude calls, function calling, embeddings and Assistants API, with Python examples. CX Codex +1 864installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor