shell-scripting

Create, refactor, and review Bash scripts with strict mode, safe parsing, and structured logging.

7|5|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/nebius/nebius-ps-services --skill shell-scripting-nebius
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-scripting
Source: https://github.com/nebius/nebius-ps-services/tree/main/skills/shell-scripting
Command: npx skills add https://github.com/nebius/nebius-ps-services --skill shell-scripting-nebius

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Writing shell automation often produces fragile scripts that fail on edge cases, mishandle arguments, or corrupt state on re-runs. This Skill enforces Bash safety conventions so scripts are predictable, idempotent, and readable from the start. ## Core Features & Use Cases - Script Creation and Refactoring: Builds or improves Bash scripts starting from a reusable template with strict mode (set -euo pipefail), explicit argument parsing, and clear usage output. - Structured Logging and UX: Provides log helpers for errors, warnings, notes, and success messages with ANSI color that respects NO_COLOR and non-interactive terminals. - Validation Workflow: Verifies scripts with bash -n syntax checks, shellcheck when available, and safe smoke runs. - Use Case: Ask the agent to write a deployment helper script; it produces an idempotent Bash script with --help, --dry-run, dependency checks via command -v, and trap-based cleanup of temporary files. ## Quick Start Use the shell-scripting skill to create a Bash script that archives log files with a --dry-run flag and strict error handling.

Frequently Asked Questions about shell-scripting

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

FAQPage Schema
How do I write a safe Bash script with strict mode?

Start with #!/usr/bin/env bash and set -euo pipefail, then quote variable expansions and use local for function-scoped variables. The skill's template adds argument parsing, usage output, and logging helpers on top of this baseline.

How to add argument parsing and help output to a Bash script?

Use a while/case loop that handles -h/--help, fails on unknown options, and supports -- to end option parsing. The included template implements this pattern with styled usage sections for Usage, Options, and Examples.

Does the skill support shellcheck and script validation?

Yes, the workflow validates scripts with bash -n for syntax checking and runs shellcheck when available. It also recommends a small functional smoke run with safe inputs to confirm happy-path behavior.

How do I make a Bash script idempotent and safe to re-run?

Check before creating, modifying, or deleting resources, avoid appending duplicates, and require explicit opt-in flags for destructive actions. Use mktemp for temporary files and trap for cleanup so interrupted runs leave no residue.

Why does my script show broken color codes in logs or CI?

ANSI color should only be enabled when output is interactive (-t 1 or -t 2) and disabled when TERM=dumb or NO_COLOR is set. The skill's template handles this detection automatically in its init_output_style function.