agentsclimarketplace

Bash coding

Skill nguyenthdat/opencode-manager/registry/skills/bash-coding

Project-scoped OpenCode TUI plugin for grouping and managing MCP servers, custom agent skills, and pinned vendor skill registries.

Install
npx -y skills add nguyenthdat/opencode-manager --skill bash-coding

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 13 days oldThe repository was created 13 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Comprehensive idiomatic Bash/POSIX Shell guidance: 134 prioritized rules across 12 categories. Use when writing, reviewing, refactoring, or debugging shell scripts (`.sh`, `.bash`, `#!/bin/bash`, `#!/bin/sh`). Covers variable handling/quoting, error handling (errexit/pipefail), I/O and redirection, portability (POSIX sh vs Bash), security (injection/suid), function design, testing (Bats/shellspec), and anti-patterns. Target Bash 5.x+; distinguish Bash-isms from POSIX sh for portable scripts.

SKILL.md

20.4 KB, as published. Nobody here has run it

Bash / Shell Best Practices

Comprehensive guide for writing high-quality, idiomatic, and robust Bash/POSIX shell scripts. Contains 134 rules across 12 categories, prioritized by impact to guide LLMs in code generation and refactoring.

When to Apply

Reference these guidelines when:

  • Writing new Bash scripts or shell functions
  • Reviewing shell scripts for correctness and security
  • Debugging variable scoping, quoting, or exit code issues
  • Refactoring legacy shell scripts to modern standards
  • Writing scripts that must run on both Linux and macOS
  • Choosing between Bash features and POSIX-compatible alternatives
  • Setting up CI/CD with ShellCheck and Bats testing
  • Handling user input, secrets, or temporary files securely

Bash 5.x & Modern Shell Features

This skill targets Bash 5.x (released 2019) while noting POSIX compatibility. Key features to leverage:

  • Associative arrays (declare -A): string-keyed maps for configuration, caching, dispatch tables (Bash 4.0+)
  • Namerefs (declare -n, local -n): safe indirect variable/array access, replacing eval (Bash 4.3+)
  • Process substitution (<(cmd), >(cmd)): pipe without subshells, preserve variable state (Bash 4.0+)
  • Here-strings (<<<): single-string stdin without pipes or forks (Bash 4.0+)
  • [[ ]] conditional: regex matching (=~), pattern matching (==), safe unquoted variables
  • globstar (shopt -s globstar): recursive **/*.txt glob patterns (Bash 4.0+)
  • nullglob / failglob: control glob behavior for empty matches
  • extglob: extended patterns (@(), !(), +(), *(), ?())
  • readarray/mapfile: read file/command output directly into arrays
  • BASH_REMATCH: capture regex groups from [[ =~ ]] matching
  • EPOCHSECONDS / EPOCHREALTIME: wall-clock timestamps without date fork (Bash 5.0+)
  • BASH_SOURCE vs $0: reliably determine script location regardless of how it's invoked
  • Subshell vs command grouping: (cmd) is a subshell (variable changes lost), { cmd; } is in-process

For POSIX sh (#!/bin/sh, dash, ash, busybox sh), avoid all of the above and see port-avoid-bashisms.

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1Variable Handling & QuotingCRITICALvar-14
2Error Handling & Exit CodesCRITICALerr-13
3Input/Output & RedirectionHIGHio-12
4SecurityHIGHsec-11
5Function DesignHIGHfn-11
6Portability (POSIX vs Bash)HIGHport-11
7Naming & Style ConventionsMEDIUMname-11
8Arrays & Data StructuresMEDIUMarr-9
9Testing (Bats/shellspec)MEDIUMtest-10
10Debugging & LoggingMEDIUMdebug-9
11Performance & EfficiencyMEDIUMperf-9
12Anti-patternsREFERENCEanti-14

Quick Reference

1. Variable Handling & Quoting (CRITICAL)

2. Error Handling & Exit Codes (CRITICAL)

3. Input/Output & Redirection (HIGH)

4. Security (HIGH)

5. Function Design (HIGH)

6. Portability (POSIX vs Bash) (HIGH)

7. Naming & Style Conventions (MEDIUM)

8. Arrays & Data Structures (MEDIUM)

9. Testing (Bats/shellspec) (MEDIUM)

10. Debugging & Logging (MEDIUM)

11. Performance & Efficiency (MEDIUM)

12. Anti-patterns (REFERENCE)


Recommended Shell Settings

#!/usr/bin/env bash
# Safer bash defaults — include at top of every script
set -euo pipefail
IFS=$'\n\t'

# Additional safety options (opt-in)
shopt -s nullglob          # Non-matching globs → empty (not literal *)
shopt -s inherit_errexit   # Subshells inherit errexit (Bash 4.4+)
shopt -s shift_verbose     # shift errors when count exceeds $#

# For debuggable scripts:
# shopt -s failglob        # Non-matching globs → error (stricter than nullglob)

How to Use

This skill provides rule identifiers for quick reference. When generating or reviewing shell scripts:

  1. Check relevant category based on task type
  2. Apply rules with matching prefix
  3. Prioritize CRITICAL > HIGH > MEDIUM > REFERENCE
  4. Read rule files in rules/ for detailed examples with Bad/Good code

Rule Application by Task

TaskPrimary Categories
New script skeletonerr-, fn-, name-
Variable handlingvar-, sec-
Function writingfn-, var-
File/pipe processingio-, perf-
Security reviewsec-, anti-
Cross-platform scriptport-, name-
Test writingtest-, debug-
Debugging failuresdebug-, err-
Code reviewanti-, sec-

Related Skills

  • design-patterns — choosing and implementing GoF/idiomatic patterns in shell scripts (pipeline/filter, command dispatch).
  • security-review — cross-language security/correctness review methodology (phases, finding format, severity guidance) applies to shell-script reviews; it does not yet ship a dedicated shell bug-class reference file, so apply the general workflow to injection, unsafe eval/word-splitting, and TOCTOU risks.

Sources

This skill synthesizes best practices from:

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.