Skip to content
Back to skills

Writing Bash Scripts

ASecurity

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.

  • 106 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added September 12, 2026
code-qualityshellbashdebuggingrefactoring

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add archibate/dotfiles-opencode --skill writing-bash-scripts --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Writing Bash Scripts?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Writing Bash Scripts
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/archibate-writing-bash-scripts/badge)](https://www.skillsdirectory.com/skills/archibate-writing-bash-scripts)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Files in this skill

  • SKILL.md1.6 KB
  • references/pref_bash.md9.9 KB
  • references/requirements.md5.3 KB
  • scripts/pref_bash_script_template.sh10.4 KB
  • scripts/run_shellck.sh1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.