home / skills / masayan1126 / masayan-uni-code-plugins / bash-script-generator

This skill generates robust Bash scripts with error handling, argument parsing, and cleanup for reliable automation workflows.

npx playbooks add skill masayan1126/masayan-uni-code-plugins --skill bash-script-generator

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
557 B
---
name: bash-script-generator
description: ユーザー要件に基づき、ベストプラクティスに従った堅牢なBashスクリプトを生成する
---

# Bashスクリプト生成スキル

ユーザーの要件をヒアリングし、エラーハンドリング・引数解析・クリーンアップ処理を備えた堅牢なBashスクリプトを生成します。

## 詳細ドキュメント

For workflow, see [WORKFLOW.md](WORKFLOW.md).
For bash template, see [TEMPLATE.md](TEMPLATE.md).
For user input form, see [FORMS.md](FORMS.md).

Overview

This skill generates robust Bash scripts based on user requirements, following established best practices. It produces scripts that include argument parsing, error handling, cleanup routines, and clear usage output to make maintenance and automation safer and easier.

How this skill works

I ask targeted questions about inputs, expected behavior, environment constraints, and failure modes, then synthesize a complete Bash script scaffold. The generated script includes getopt/shift-based argument parsing, set -euo pipefail options, trap handlers for cleanup, logging hooks, and inline comments to explain nontrivial logic. Outputs are tailored for portability and can be adjusted for specific shells or platforms on request.

When to use it

  • You need a production-ready Bash script for automation, deployment, or data processing.
  • You want consistent argument parsing and help/usage text for command-line tools.
  • You require reliable error detection and cleanup in long-running or resource-sensitive scripts.
  • You need a starter script that follows shell best practices and is easy to review or extend.

Best practices

  • Provide clear functional requirements and example inputs/outputs up front.
  • Specify target shells and platforms (bash version, Linux distro, macOS) for portability adjustments.
  • Request idempotency and failure-recovery behavior when relevant.
  • Include required external commands or dependencies to embed defensive checks in the script.
  • Ask for logging level preferences and whether sensitive data should be redacted.

Example use cases

  • Generate a deployment script that pulls code, runs migrations, and restarts services with rollback on failure.
  • Create a backup script that accepts source/destination arguments, verifies space, and cleans temp files on exit.
  • Produce a data ingest pipeline wrapper with strict argument validation and retry logic for transient errors.
  • Build a developer utility that installs tooling, configures environment variables, and prints a compact help message.

FAQ

Can you produce scripts compatible with sh and dash?

Yes—specify the target shell. I will avoid bash-specific features and use POSIX-compatible constructs when requested.

Do generated scripts include tests or linting?

I can include simple unit-style checks and a suggested shellcheck configuration or CI snippet on request.

How do you handle secrets or credentials?

I recommend reading secrets from secure stores or environment variables and will add redaction and minimal exposure patterns when you ask.