PLUGIN brewcode / Agents
On this page
Bash Expert
Quick reference
| Field | Value |
|---|---|
| Model | inherit: runs on the session’s model |
| Tools | Read, Write, Edit, Glob, Grep, Bash, WebFetch |
| Triggers | ”create script”, “bash script”, “shell script” |
| Output | .sh file + bash -n + ShellCheck report |
Bash Expert writes and validates one bounded script. It matches repository conventions, adds error handling and quoting, and checks syntax and ShellCheck findings before handing the file back.
When to use
- Plugin lifecycle scripts: setup, install, teardown, version bump.
- CI helpers: health checks, environment bootstrap.
- Scripts that must run on macOS (ARM and Intel) and Linux unchanged.
- Idempotent installers and scripts printing markdown tables for skills.
Example
write an install script that works on macOS and Linux
Expected result: an executable .sh with strict mode, usage header and help subcommand, plus a report of bash -n and ShellCheck results.
How it works
- Analyze
Reads existing repo scripts to match conventions; fixes platform, commands and output format.
- Choose a template
Minimal (single purpose) or multi-mode dispatch with a
caseblock; plugin scripts self-locate viaSCRIPT_DIR. - Implement and validate
Strict mode, quoted variables, cleanup trap; then
bash -nandshellcheck, all warnings fixed. - Report
File path, purpose, platform and a checklist of verified properties.
It refuses batches such as “write the whole CI toolchain” and returns a split proposal instead. A brief missing consumer or acceptance gets a stated assumption or the question back. Generic rules: scope guard. The agent has no Agent tool and records each script’s status in .claude/reports/YYYYMMDD-HHMMSS_bash-expert/report.md. If it exhausts maxTurns (80), the caller resumes it with SendMessage.
Conventions, templates and platform handling #
| Pattern | Example | Use |
|---|---|---|
| Strict mode | set -euo pipefail | Every script |
| Cleanup trap | trap cleanup EXIT | Temp files, locks |
| Required var | ${VAR:?error msg} | Mandatory input |
| Soft failure | cmd || echo "Warning: optional step failed" >&2 | Optional steps |
Mode detection follows the canonical modes:
ARGS_LOWER=$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]')
case "$ARGS_LOWER" in
status|install|upgrade|enable|disable|uninstall|purge) MODE="$ARGS_LOWER" ;;
'') MODE="default" ;;
*) echo "Unsupported mode: $ARGS_LOWER" >&2; exit 2 ;;
esac
| Feature | macOS | Linux |
|---|---|---|
| Brew prefix | /opt/homebrew (ARM), /usr/local (Intel) | /home/linuxbrew/.linuxbrew |
/bin/bash | 3.2: no ${v,,}, mapfile, declare -A | 4+ |
| timeout | absent; coreutils adds gtimeout | timeout |
| sed in-place | sed -i '' | sed -i |
| readlink | native -f on macOS 15; older greadlink -f | readlink -f |
Derive the prefix via $(brew --prefix), never hardcode. For JSON use jq, fall back to python3; never regex or grep -P on macOS.
| Avoid | Prefer |
|---|---|
[ $VAR ] | [[ -n "$VAR" ]] |
cat file | grep | grep X file |
ls | while read | find -exec or glob |
cd dir; cmd; cd - | (cd dir && cmd) |
if [ $? -eq 0 ] | if cmd; then |
${CLAUDE_PLUGIN_ROOT} is substituted in plugin skill/agent text and hook/MCP commands, not in ordinary scripts: they receive or derive the root. Status symbols: 🟢 success, 🔴 error, ⚪ skipped, 🔵 active; warnings use Warning:.
Delivery checklist: shebang, strict mode, usage header, shellcheck clean, chmod +x, bash -n, help works, error paths tested, idempotent re-run.
Return contract #
Verdict first, at most 30 lines with path:line, one block per script. Failures name the failed check and path:line; long logs go to .claude/reports/<YYYYMMDD-HHMMSS>_bash-expert/, path only. /brewtools:agent-return-setup enforces ~2500 / ~6000 est-tokens when installed.
Related
Hook Creator
Brewcode overview
GitHub source
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ