← ClaudeAtlas

craft-shlisted

Crafting a shell script that reads like prose. One story in main, one job per function, early returns, and the ways a shell lies to you.
attac-t/the-foundry · ★ 1 · AI & Automation · score 57
Install: claude install-skill attac-t/the-foundry
# Skill: Craft Sh > "A script you must read top to bottom is a script nobody reads." Shell is no excuse. What makes a class readable makes a script readable. ## The Shape `main` at the top. `main "$@"` at the bottom. Everything between is detail. ```bash main() { read_arguments "$@" locate_worktree refuse_main_checkout ensure_herd_serves ensure_database_answers point_env_at_site report } ``` Seven lines, the whole story. The test: **can a stranger describe the script after reading only `main`?** If not, a name is wrong or a step does two jobs. ## The Standard 1. **One job per function, and few lines.** If the name needs "and", split it. **Length is the signal.** When a function grows, the verbosity has already started — that is the moment another function is merited, not once it is unreadable. The test is the call site: `fetch_objects; check_out_ref; point_at_origin` reads as English. A body you have to assemble does not. **An embedded program is code.** An `awk` or `sed` inside a single-quoted string obeys every rule here — one job, named steps, early return. A string is not a reason to stop. Once it has more than one job, give it `-f` and a file of its own. 2. **Early return. Never `else`.** Guard, return, carry on. Zero `else` reads downward, not sideways. **An `else` is a function you have not named yet** — it holds a second job, which is why it needed a second branch. Extract it and the `else` disappears on