The hook
In the terminalela --spec the-hook
The hook keeps Claude Code's Bash tool on ela. It refuses a command that is not ela, and its reason holds the ela that does the job, ready to run:
ela --agent hook: this shell runs ela, and the command is bash: run it as ela, as below ela <<'EOF'cd sitemake ci 2>&1 | tail -3EOFela --lint - checks it before it runs; ela --agent prints the guide.
ela --agent --hooks [folder] writes <folder>/.claude/settings.json with a hook that sends
every command of the Bash tool through ela --agent hook:
{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "ela --agent hook" } ] } ] }}
A settings file that is there already is never edited. ela prints the hook to merge into it by hand, says so and exits 1.
How the hook decides:
- Before each Bash call, Claude Code hands the hook the call as JSON on stdin: its command in
tool_input.commandand its folder incwd. - The hook reads the command with the parsers of bash and of ela.
- A command that is ela throughout, each of its commands an
elawith no bash around it, goes through with nothing printed. The agent's own permissions then decide on it. - Any other command is refused. The hook prints
permissionDecisiondenyand a reason, which the agent reads. - A call of another tool goes through. So does one the hook can't read as JSON, with a line on stderr that says so: a fault in the hook's input never stops a session.
What a refusal holds:
- bash:
ela --translate bash's translation of it. A line the translation leaves for hand stays a# bash:comment in the script, and its message follows the script:line 1: bash's shopt has no ela form: rewrite it by hand. python -c,perl -e,awkandjq: the script that does their job, with the procs named:json.decodeforjq,str.fieldsforawk '{print $2}',re.replaceforperl -pi -e 's/a/b/g'. The script uses the input the command names.- A job with no ela form, such as Python that imports neither
json,yaml,csvnorre: a plain refusal.