agentleFS
posidoniposidoni/shell-skill/skills/shell/SKILL.md

shell

Skill1 starsChanged 4 months agoMITView on GitHub

Load before running or writing ANY shell — including throwaway one-liners you intend to run yourself, not just scripts you save. Trigger on the act, not the request: you are about to type awk, sed, cut, or a second pipe; you are parsing du/ps/ls/find output; a command needs a loop, a conditional, or arithmetic; you are writing $(...) inside another $(...); you need a file list, sizes, or process info; you are choosing a shebang or an interpreter; a command exceeds one line or will outlive this session; output must be machine-read, or must separate data from diagnostics; you are editing a Makefile recipe, Dockerfile RUN, CI run: block, cron entry, or .env; or you are reviewing or debugging shell someone else wrote. Answers "should this be shell at all?" first — usually jq, yq, sd, nu, Python or bun — then applies the Bash/Zsh/POSIX/Nushell safety rules to whatever survives that question.

  • Reads credentials

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Hard stop: if a pipeline needs three or more stages, or any awk beyond {print $1}, stop and write a script file.

    line 36
  2. Very specific:

    Never write bare bash and hope.

    line 67

“Common” is measured: kept by at least 6 in 10 of the 7 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

Most "shell problems" are solved by not writing shell. This skill decides that first, then enforces the rules for the parts that genuinely are shell.

1. Pick the tool before writing a line

The taskUseNot
JSON in, JSON outjqgrep/sed on JSON
YAML / TOML / XMLyqany regex
Substitute text in filessdsed -i (delimiter escaping, BSD-vs-GNU -i)
Find filesfdfind with -exec chains
Search contentsrggrep -r
Query the OS for structured facts (sizes, processes, files)nudu/ps + awk
String case/encoding transformssttrtr/awk
SQLitesqlite3 or a bun scriptshelling out per row
Anything with a data structure, two stages of logic, or arithmeticPython or a bun .ts filea pipeline

Hard stop: if a pipeline needs three or more stages, or any awk beyond {print $1}, stop and write a script file. A three-stage awk/sed/cut chain is unreadable, unportable (BSD vs GNU), and silently wrong on unusual input.

See reference/pipelines.md for the replacement table, BSD-vs-GNU traps, and worked rewrites.

1b. Do not invoke a tool from memory — check it

A recalled flag is a guess. Model memory for CLI flags is stale, version-skewed, and confidently wrong. Checking costs one command; guessing costs a silent wrong answer, which is worse than an error because nothing tells you.

Escalate in this order, stopping as soon as you know:

  1. <cmd> --help — always first. Fast, offline, matches the installed version. Modern Rust tools (sd, rg, fd) have excellent --help.
  2. man <cmd> — when --help is a summary and you need semantics. Not every tool ships one (nu and sttr do not; sd, rg, fd, jq, yq do — check with man -w <cmd>).
  3. <cmd> --version + context7 — for a library or a tool with real documentation, when behaviour differs across versions. Pin the answer to the installed version.
  4. Web search — last, for "why does X do Y" questions no reference answers.

Then run it once on a known input before trusting it in a pipeline.

Cached essentials and the gotchas that bite — reference/cli-cheatsheets.md.

2. Pick the interpreter deliberately

Never write bare bash and hope. On macOS /bin/bash is 3.2 (2007, frozen over GPLv3) — no mapfile, no associative arrays, no ${var^^}. Homebrew's bash 5.x lives at /opt/homebrew/bin/bash.

  • Portable script → #!/usr/bin/env bash and stay inside 3.2 features, or assert the version at the top.
  • Need bash 4+/5 features → require it explicitly, do not assume env finds it.
  • Interactive-shell config → that is Zsh on macOS, not bash.
  • Structured data → Nushell.

Details and the env -S flag trick: reference/shebang.md.

3. The non-negotiables (Bash)

#RuleEnforced by
1set -euo pipefail first line of every scriptstyle
2Quote every expansion: "$var", "$(cmd)"SC2086
3read -r, never bare readSC2162
4Declare local, then assign — local x="$(cmd)" hides the exit statusSC2155
5Arrays for lists; expand "${arr[@]}"SC2206
6[[ ... ]], not [ ... ]SC2292
7return in helpers; exit only in mainstyle
8trap '...' EXIT for cleanupstyle
9printf, never echo — builtins disagree on -n, -e, backslashesSC2028/SC2059
10${var} bracesSC2250
11readonly constants; command -v, not whichstyle
12Never parse ls; use a globSC2045
13No nested $( $( ) ) — assign an intermediate variablereadability

Full rationale and citations: reference/shell-standards.md.

4. Then the shell-specific reference

Load only the one you are actually writing:

  • Bash — pipefail semantics, trap ERR, BSD-vs-GNU coreutils, bash-3.2 traps → reference/bash.md
  • Zsh — emulate -L zsh, no automatic word-splitting, glob qualifiers, startup files → reference/zsh.md
  • POSIX sh — no local, no arrays, [ ] only, set -eu without pipefail → reference/posix-sh.md
  • Nushell — parse-time vs runtime, const for source, structured pipelines, save not >, ^cmd | complete → reference/nushell.md
  • Streams — stdout is data, stderr is diagnostics, exit codes, signals → reference/streams.md

5. Verify before claiming it works

shellcheck script.sh          # default severity — CI's --severity=warning hides SC2086
shfmt -d script.sh            # layout, and rewrites backticks
nu --ide-check script.nu      # parse + type errors for Nushell

task lint runs these across the repo. A script that has not been shellcheck'd at default severity has not been checked.

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.