PLUGIN brewcode / Agents

Bash Expert

Quick reference

FieldValue
Modelinherit: runs on the session’s model
ToolsRead, 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

  1. Analyze

    Reads existing repo scripts to match conventions; fixes platform, commands and output format.

  2. Choose a template

    Minimal (single purpose) or multi-mode dispatch with a case block; plugin scripts self-locate via SCRIPT_DIR.

  3. Implement and validate

    Strict mode, quoted variables, cleanup trap; then bash -n and shellcheck, all warnings fixed.

  4. 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 #
PatternExampleUse
Strict modeset -euo pipefailEvery script
Cleanup traptrap cleanup EXITTemp files, locks
Required var${VAR:?error msg}Mandatory input
Soft failurecmd || echo "Warning: optional step failed" >&2Optional 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
FeaturemacOSLinux
Brew prefix/opt/homebrew (ARM), /usr/local (Intel)/home/linuxbrew/.linuxbrew
/bin/bash3.2: no ${v,,}, mapfile, declare -A4+
timeoutabsent; coreutils adds gtimeouttimeout
sed in-placesed -i ''sed -i
readlinknative -f on macOS 15; older greadlink -freadlink -f

Derive the prefix via $(brew --prefix), never hardcode. For JSON use jq, fall back to python3; never regex or grep -P on macOS.

AvoidPrefer
[ $VAR ][[ -n "$VAR" ]]
cat file | grepgrep X file
ls | while readfind -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.

Hook Creator

Builds hooks; pairs with Bash Expert when a hook shells out.

Brewcode overview

All brewcode skills and agents in one place.

GitHub source

Agent definition, system prompt, and tool configuration.

Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ