agentleFS
mikejhillmikejhill/agent-skills/skills/shell-scripts/SKILL.md

shell-scripts

Skill0 starsChanged yesterdayMITView on GitHub

Standards for Bash and PowerShell scripts and one-liners: structure, strict error handling, argument parsing, validation, and output streams. Use when writing, refactoring, or reviewing a .sh/.bash or .ps1 script or a terminal one-off.

5 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use git-workflow.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write shell code in one of two modes, in the language the target system runs.

    line 12
  2. Distinctive:

    Default to FullScript when the ask is ambiguous.

    line 21
  3. Distinctive:

    Follow the user's ask or the repository's existing scripts.

    line 25
  4. Distinctive:

    Do not hard-code paths or configurable values.

    line 34
  5. Distinctive:

    Keep business logic out of top-level code.

    line 35
  6. Very specific:

    Write temp files with mktemp or New-TemporaryFile, and remove them on exit.

    line 38

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Shell scripts

Write shell code in one of two modes, in the language the target system runs.

Pick the mode

ModeUse whenOutput
OneOffA one-liner, quick command, ad-hoc check, or terminal snippetSnippet: Bash 1-5 lines (max 10), PowerShell 1 line (max 5). No file unless asked.
FullScriptA script file, reusable CLI tool, or multi-step workflowOne file built from the template

Default to FullScript when the ask is ambiguous.

Pick the language

  • Follow the user's ask or the repository's existing scripts.
  • Otherwise use Bash for Linux and macOS targets, and PowerShell 7 for Windows targets. When a script must run on both, write both, or suggest Python instead.
  • Bash scripts assume Bash 4+. macOS ships 3.2 at /bin/bash, so say so when a script uses Bash 4 features.

Rules for both languages

  • Validate all inputs before any work. Use guard clauses and keep nesting to three levels.
  • Send primary output to stdout. Send logs, status, warnings, and errors to stderr (PowerShell: Write-Verbose, Write-Information, Write-Error; never Write-Host for diagnostics).
  • Fail fast. Never ignore a non-zero exit or swallow an error without a comment saying why it is safe.
  • Do not hard-code paths or configurable values. Use parameters or named constants.
  • Keep business logic out of top-level code. Top level holds only declarations, setup, and one call to main (Main).
  • Give errors enough to act on: what was being done, what failed, and how to fix it.
  • In a OneOff that deletes or changes things, show a preview first (-print, --dry-run, -WhatIf) and leave the destructive form for the user to run.
  • Write temp files with mktemp or New-TemporaryFile, and remove them on exit.

FullScript essentials

Bash (bash.md, template template.sh):

  • #!/usr/bin/env bash, a header comment (description, usage, changelog), then set -euo pipefail.
  • readonly constants, local variables in functions, integer 0/1 flags, named E_* exit codes.
  • die, log_*, usage, parse_args (using getopts with a leading :), and main, defined last.
  • Traps for EXIT (idempotent cleanup), INT (exit 130), and TERM (exit 143).

PowerShell (powershell.md, template template.ps1):

  • Comment-based help first (.SYNOPSIS, .DESCRIPTION, .PARAMETER for each parameter, .EXAMPLE, .NOTES), then [CmdletBinding()], param(), and Set-StrictMode -Version Latest.
  • Validation attributes on every parameter. Business logic in documented classes. A Main function, defined last and invoked once.
  • Return objects, not formatted text. Use SupportsShouldProcess for destructive actions.
  • #region blocks for Constants, Classes, Helpers, and Main.

Checklist

  • Mode and language match the ask.
  • FullScript follows the template's section order.
  • Bash passes shellcheck and bash -n. PowerShell passes Invoke-ScriptAnalyzer when available.
  • -h / Get-Help shows usage. Invalid arguments exit with the usage error code.

References

  • bash.md: read when writing or reviewing a Bash FullScript.
  • powershell.md: read when writing or reviewing a PowerShell FullScript.
  • template.sh, template.ps1: copy to start a FullScript.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.