phylax¶
phylax adds opt-in Claude Code hooks. Each is off until you switch it on in /config.
Use it when¶
- A repo or an employer bans attribution lines in commit messages and PR bodies.
- A
COMMITS.mdscratchpad must never be committed. - You work with several Claude sessions and want a warning before committing in a main checkout that has linked worktrees.
- A subagent should never silently inherit the session's model.
- You leave sessions open and want them moved onto an updated Claude Code without losing the conversation.
Install¶
Needs¶
Claude Code 2.1.288 or later for the guard mod. On 2.1.287 the mod runs but breaks Bash in worktree subagents, and on an older version the guards run from the command hook instead. Any option that is on needs python3 3.9 or newer; the git guards also need git. restart_on_update needs Linux or WSL, plus tmux or Windows Terminal, and the claude command on PATH.
Set up¶
Switch the options you want on in /config, under the phylax plugin's options. Then run /reload-plugins and /phylax:setup. It prints each option's value and checks what the options that are on need. ok means on; n/a means off, or not set, which is off. The last line is result: ready, or result: missing with the names of the required checks that failed. Claude follows the setup runbook.
Skills¶
| Skill | Use it to |
|---|---|
phylax:setup |
Show which options are on and check what they need. |
Configuration¶
| Option | What it does |
|---|---|
block_attribution_trailers |
Refuses git commit and gh pr create, gh pr edit or gh pr merge when the message, title or body has a Claude-Session, claude.ai/code/session, Co-Authored-By: Claude or Generated with Claude Code line, and blanks the trailer and footer Claude Code asks Claude to write. |
block_commits_md |
Refuses git add of a file named COMMITS.md, and git commit when the commit would include one. |
warn_main_checkout_commit |
Warns, without blocking, when git commit runs in a repo's main checkout while linked worktrees exist. |
require_subagent_model |
Refuses an Agent call to a built-in agent type that runs on the session's model (general-purpose, claude, Explore or Plan, or no type) when it names no model. Other agent types are left to their own definitions, since a model named in the call would override one the definition pins. A managed, project or user agent that reuses one of those names replaces the built-in, so its own model decides: a model it names allows the call, inherit refuses it, and none is treated like general-purpose's. Definitions passed with --agents or found in an --add-dir folder are not visible to the hook. A CLAUDE_CODE_SUBAGENT_MODEL that names a model (not inherit) satisfies it for general-purpose and claude; Explore and Plan pin inherit, which wins over that variable. While CLAUDE_CODE_SUBAGENT_MODEL_FORCE or CLAUDE_CODE_COORDINATOR_FORCE_WORKER_INHERIT_MODEL is set, Claude Code drops or withholds the call's model, so the guard stands down. |
email_greeting |
Refuses an epistole create_draft or update_draft, or a Gmail connector create_draft, update_draft, send_message or reply (a second Gmail connector too), whose body does not open with Good morning before 12:00, Good afternoon from 12:00 to 17:00 or Good evening after, or opens with Hi, Hello, Hey or Dear. A first line in another language passes: one opening with a common Spanish, Portuguese, French, Italian or German greeting (Hola, Bonjour, Guten Tag), or holding a letter outside ASCII. Within 10 minutes of 12:00 or 17:00 either greeting passes. It checks both the plain-text body and the HTML body's visible text; an update that keeps the body passes. email_timezone sets the clock (an IANA name such as America/New_York; empty is this machine's local time), and a name the system does not know refuses every draft until it is fixed. Needs python3 only. |
restart_on_update |
Moves an idle session onto an updated Claude Code in a new tmux window or Windows Terminal tab, keeping the conversation. Any key during the 15 second countdown cancels it. |
budget_mode |
While the 5-hour or 7-day usage runs ahead of the time gone, tells each routed session to route work to Sonnet and Haiku, and in frugal runs an Agent call that names Opus, Fable or best on Sonnet unless its description says "final review". Routes background agents (PHYLAX_BUDGET_ROLE=background) and opted-in interactive sessions (PHYLAX_BUDGET=on); /phylax:budget pauses the latter. Reads the usage the status line saves; budget_lean_pace, budget_lean_used, budget_frugal_pace, budget_frugal_used and budget_state_file tune it. |
Configuration describes what each guard reads and its limits, Restart on update the restart, and Budget mode its levels and the status line step it needs. To turn a git guard off in one repo, set its camelCase git config key, such as git config phylax.blockCommitsMd false.
Denied-calls log¶
Each refusal from a guard above is one JSON line in ~/.local/state/phylax/denied-calls.jsonl (256 KB, then rotated to .jsonl.1), mode 0600, never sent anywhere. The same session's next call that a phylax hook sees (a Bash or run_command, Agent or Task, or email-draft call; other tools run no phylax hook) is logged under the same id, with same_action (a word-overlap guess that it runs the same kind of action: commit after commit, push after push, a draft after a greeting refusal) and seconds_after. When Claude Code runs several calls at once, the next call can be one sent in the same batch as the refused one, before the refusal was seen; a small seconds_after marks it. Of two calls at once, only one logs. Commands and reasons pass through a redactor for token shapes (GitHub, GitLab, OpenAI, Anthropic, AWS, Slack, Google, Stripe, Hugging Face, PyPI, npm, JWTs), private key blocks, URL credentials, command-line credentials, spaced, attached or quoted and anywhere in the call once it names the command, which also redacts the same flag on another command in the line: for git, a user:pass@ proxy and --smtp-pass/sendemail.smtpPass; for curl, -u/-U (bundled too, as in -su), --proxy-user, -x user:pass@proxy, -b/--cookie, --pass, -E/--cert, --proxy-pass, --proxy-cert and --oauth2-bearer; for wget, password = settings; for gh, secret set --body; for uv and twine, publish/upload/auth login -p and -t; for npm, set and config set …_authToken or …_password; for docker, login -p; for kubectl, config set users.….token, password or client-key-data and --from-literal; for aws, --value, the --sse-c keys, aws_secret_access_key and ParameterValue=; for gcloud, proxy/password; for az, -p, --value and the --account-key style key flags; for sshpass, -p, and for ssh-keygen, -N and -P; for the mysql tools, -p, password X, user:pass@host and SQL that sets a password, which psql's -c and password= get too. Then the values of any flag whose name holds token, password, secret or api-key (--secret-string, --client-secret), credential headers after -H or in http.extraHeader (Authorization, PRIVATE-TOKEN, X-API-Key, a subscription key, Cookie; a scheme word such as Bearer stays), a long token as a URL's whole userinfo, Authorization values after a scheme word such as token or Bearer, Bearer and Basic credentials (16+ characters mixing upper and lower case with a digit, +, / or =), and KEY=value and "key": "value" secrets (JSON with escaped quotes inside a shell string too) (a name holding secret, token, password or api_key anywhere, or ending in pat, pwd, pass, passphrase, key or auth), then are cut to 1,000 characters. A KEY= followed by None, null, nil, true, false, undefined, a space, or a quote and a space (a search pattern) is not a secret. Where prose and a secret look alike, the redactor redacts: a title naming --token loses the word after it. Redaction is best effort: a secret in no known shape stays, as it does in Claude Code's own session transcripts, which hold the same commands on the same machine. A call with nothing pending pays one access() check. A refusal made because a guard could not run (python3 missing or failing, a crash, a timeout) is not logged; one for a folder that is gone is, under the guard that could not check it. An Agent or Task refusal logs the call's input (its prompt), and an email refusal logs the draft, recipients included, both redacted and cut the same way. Within a session, each subagent's records are its own (agent_id). /phylax:setup prints this week's denials and linked next calls.
Troubleshooting¶
this command runs in <folder>, which is not an existing folder. The session's folder was removed, usually a worktree deleted while the session stood in it. Runcdto an existing folder, alone or ascd <repo> && git ...; a command withgit -C <repo>is checked as usual. A subagent's commands go through the command hook, which Claude Code starts in the session's folder, so they can still fail withposix_spawnandENOENTuntil the session moves.- A guard does not fire. Run
/phylax:setup. An option shown asn/ais off; switch it on in/config. On Claude Code older than 2.1.287 the guards run from the command hook instead of the mod; 2.1.287 runs the mod but needs 2.1.288 for Bash in worktree subagents. Either way they rungit_guards.pyon the system python3, which/phylax:setupchecks. - The restart never happens. It needs Linux or WSL, tmux or Windows Terminal, and the
claudeon PATH. The hook's log,$XDG_RUNTIME_DIR/phylax-restart-<uid>/log, says why a session has not moved. - The new tab shows
Wsl/Service/0x8007274candCould not access starting directory. WSL did not answer the new tab in time (Windows Terminal'swsl.exetimed out), so the handoff never ran and the old session was never stopped: keep using its tab. The log ends athandoff launched via wtwith nostoppedline, anddmesgusually showsUtilAcceptVsockwaits from the same minutes. After 10 minutes the next idle prompt tries again. If it keeps happening, the WSL VM is short of memory or running many sessions.