archibate/dotfiles-opencode / skills/writing-bash-scripts
writing-bash-scripts
VerifiedCreate and refactor Bash scripts following conventions (strict mode, fct_ naming, quoting). Includes shellcheck linting. Use when creating shell scripts, refactoring existing scripts, debugging shell errors, or linting scripts.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.6 KB |
| references/pref_bash.md | markdown | 9.9 KB |
| references/requirements.md | markdown | 5.3 KB |
| scripts/pref_bash_script_template.sh | script | 10.4 KB |
| scripts/run_shellck.sh | script | 1.2 KB |
SKILL.md
View on GitHub---
name: writing-bash-scripts
description: Create and refactor Bash scripts following conventions (strict mode, fct_ naming, quoting). Includes shellcheck linting. Use when creating shell scripts, refactoring existing scripts, debugging shell errors, or linting scripts.
---
# Bash
Use this skill whenever the user asks to create/update/refactor a Bash script (`.sh`) or lint shell scripts.
## Defaults
- Shebang: `#!/usr/bin/env bash`
- Strict mode: `set -Eeuo pipefail`
- Functions: `fct_<descriptive_snake_case>() { ... }`
- Variables: quote expansions like `"${var}"`, prefer `printf`, use `readonly` for constants and `local` inside functions
## Workflow
### Creating/Refactoring Scripts
1. Copy `scripts/pref_bash_script_template.sh` to the target path and rename it.
2. Update the SCRIPT INFO / USAGE header blocks.
3. Implement behavior in `fct_execute_this`, keep `fct_main` + `trap` structure.
4. Follow the detailed conventions in `references/pref_bash.md`.
5. Run shellcheck linting (see below).
### Linting Scripts
Run shellcheck on scripts using the provided wrapper:
```bash
# Lint all scripts in scripts/ directory (default)
.opencode/skill/bash/scripts/run_shellck.sh
# Lint specific files or directories
.opencode/skill/bash/scripts/run_shellck.sh path/to/script.sh
.opencode/skill/bash/scripts/run_shellck.sh scripts/ other/dir/
```
The linting script:
- Automatically detects shell scripts by extension (`.sh`, `.bash`, `.zsh`) or shebang
- Exits non-zero on shellcheck failures
- Defaults to scanning `scripts/` when no arguments provided
See `references/pref_bash.md` section 14 for shellcheck integration details.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |