write-script-bash

Create reusable Bash scripts with positional parameters and JSON stdout output.

17.5k|1.1k|Updated May 5, 2022
One-click install
npx skills add https://github.com/windmill-labs/windmill --skill write-script-bash
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-script-bash
Source: https://github.com/windmill-labs/windmill/tree/main/system_prompts/auto-generated/skills/write-script-bash
Command: npx skills add https://github.com/windmill-labs/windmill --skill write-script-bash

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill provides a clear, guideline-driven approach to creating reusable Bash scripts for automating simple CLI tasks, reducing setup time and errors.

Core Features & Use Cases

  • Argument handling: Use positional parameters ($1, $2, ...) with validation to ensure predictable inputs.
  • Structured output: Emit JSON to stdout for seamless integration with other tools and workflows.
  • Best-practice guidance: Avoid unnecessary shebang lines and follow a consistent, testable pattern.
  • Use Case: Create a small automation script that accepts two inputs and returns a JSON summary for downstream steps.

Quick Start

Create a Bash script named my-script.sh, read two arguments ($1 and $2), and print a JSON object to stdout. Make the script executable and run: ./my-script.sh hello 123

Frequently Asked Questions about write-script-bash

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Bash script that accepts command-line arguments and outputs JSON?

Bash scripts accept arguments using positional parameters ($1, $2, etc.) and can emit JSON to stdout for tool integration. Read your arguments, validate them, and use echo or printf to output a JSON object. This pattern enables automation workflows where downstream steps parse the JSON output.

What's the best way to structure a reusable shell script for automation?

Follow a consistent pattern: accept positional parameters for inputs, validate them early, perform your task, and emit structured JSON output to stdout. Avoid shebangs in automation contexts and make scripts executable. This approach reduces setup time and integrates cleanly with orchestration tools.

Can I use positional parameters in Bash for argument handling?

Yes, positional parameters ($1, $2, $3, etc.) are the standard way to handle arguments in Bash scripts. Validate each parameter to ensure predictable inputs, then use them in your script logic. This method works reliably across different shells and automation environments.

Why should I output JSON from my Bash scripts instead of plain text?

JSON output enables seamless integration with downstream tools and workflows—other scripts, APIs, and dashboards can parse it programmatically. Structured JSON is more reliable than plain text for automation pipelines and reduces parsing errors in dependent steps.

Do I need a shebang line in my Bash script for automation workflows?

No, shebangs are optional in automation contexts where the shell is invoked explicitly (e.g., `bash my-script.sh`). Omitting shebangs follows best practices for deterministic execution and portability across different automation platforms.

How do I test that my Bash script correctly handles different argument inputs?

Test each positional parameter with valid and invalid inputs to verify validation logic works. Check that your script outputs valid JSON by piping output to a JSON parser. Run scripts in the same automation environment where they'll be deployed to catch environment-specific issues early.