config-health
Config Health
A real-time monitoring layer. delivery-gate blocks at session end; config-health catches problems during the session — when cheap to fix.
When to Activate
- After installing delivery-gate and wanting defense in depth
- When hooks silently stop firing
- When config rules accumulate but you're unsure which still work
- At session startup for config integrity scan
- Optionally before high-risk Edit/Write operations; this is opt-in, not default
How It Works
Session Start → config-health scans rules/hooks (soft warnings, never blocks)
Session Work → optional PreToolUse guard, only if you wire it yourself
Session End → delivery-gate verifies (hard block, exit 2)
Boundary: "Can this be fixed retroactively?" Config drift → config-health warns. Missing growth-log → delivery-gate blocks (hard exit 2).
What It Monitors
- Hook Wiring Audit: every script a hook command references, checked against
disk. Runs at session start by default. An optional PreToolUse mode can also
run it per matched Edit/Write call; that mode is not part of the default
wiring and is not recommended unless you want the recurring cost.
- Rule Health: every
rules/*.mdreferenced fromCLAUDE.mdexists. - Guard Staleness: rules whose fire counter has been zero across the last five
sessions recorded in rule-health.jsonl — the last five *records*, then
filtered down to the ones complex enough to judge, so a verdict needs at
least five records in total.
The default wiring is SessionStart only. PreToolUse is available as an opt-in
mode, but it is not recommended by default: it adds a fresh-process parse of
this script to every matched Edit and Write without adding tool-specific
evidence. See PreToolUse Cost.
Hook Paths
Hook commands are split the way a shell splits them before any path is
checked, so a normal plugin install does not report every hook as missing:
~/.claude/scripts/x.py,$HOME/scripts/x.pyand${USERPROFILE}/…resolve
against the user home.
${CLAUDE_PLUGIN_ROOT}/…and${CLAUDE_PROJECT_DIR}/…are expanded.- A bare relative path (
.claude/scripts/x.py,scripts/hooks/x.js) is resolved
under the project dir, the user home and the plugin root, because a hook
command does not say which of those it runs from. It is reported only when it
is missing from all three.
- A quoted word is one argument, so
python3 "C:\Program Files\ecc\guard.py"
is not cut at the space, and ; | & inside quotes are part of the name
rather than separators. One deliberate exception to shell quoting: a
backslash escapes only whitespace, quotes and shell metacharacters — never
another backslash, $ or a backtick. So C:\Users\me\guard.py,
\\server\share\x.py and C:\$Recycle.Bin\x.py survive intact, which a
POSIX escaper would mangle into paths that do not exist.
- An interpreter's program body is not a script path, and the two kinds are
treated differently. sh -c "python3 x.py" is a command line, so it is
scanned again as one; -c, -lc and --command all count, and an option
in between (bash -x -c, bash -o pipefail -c) does not orphan the body.
A node -e or python -c body is source in another language, where a
string is a string: p.join(r,'scripts/hooks/x.js') is assembled at
runtime and is not a file anything will open, so it is skipped. A missing
file *named inside* a JS body is therefore not reported — the monitor cannot
tell a path from a string.
What is skipped rather than reported: a token carrying a placeholder this
monitor does not resolve, a placeholder whose expansion lands outside the
audited roots, a single-quoted placeholder (the shell does not expand it), a
command with an unclosed quote anywhere in it including inside a sh -c
payload, and a sh -c chain nested deeper than three.
--check prints what was left unjudged, because a blind spot nobody can see
is not a health check:
| N hook path(s) not audited | placeholders or paths the monitor would not judge, plus commands it could not parse |
| N hook command(s) have an unclosed quote | commands with a quote that never closes — a typo, not a design decision |
| N hook command(s) nested sh -c deeper than 3 levels | nesting the monitor stopped following; the rest of the command was still audited |
| N interpreter program body/bodies were skipped unjudged | node -e / python -c bodies, where a file named inside is a string in another language and cannot be checked |
| N settings file(s) could not be read | a warning, not info: a malformed settings file is the one input whose contents decide the answer, and it was not audited |
| N relative hook path(s) were satisfied by the user home or plugin root | the multi-root trade: a project-scoped hook that is genuinely broken looks exactly like a healthy plugin one here |
| $CLAUDE_PLUGIN_ROOT resolved to … | the root it judged against |
On a healthy ECC install the last two lines are the interesting ones: a real
one reports 0 findings with 23 program bodies skipped and 17 relative paths
satisfied by the plugin root.
Env Inputs
Findings are a function of the settings files and these variables, not of the
process environment:
| Variable | Effect |
|----------|--------|
| CONFIG_HEALTH_USER_HOME | user home; also what ~ and $HOME resolve to |
| CLAUDE_CONFIG_DIR | Claude data root; user settings and the rule-health log; default ~/.claude |
| CLAUDE_PROJECT_DIR | project dir |
| CONFIG_HEALTH_PLUGIN_ROOT | pins the plugin root |
| CLAUDE_PLUGIN_ROOT | plugin root; CONFIG_HEALTH_PLUGIN_ROOT wins |
When a launcher sets CLAUDE_CONFIG_DIR, `~/.
