Skip to content

feat(cli): add --doctor to report install health - #818

Open
diegoalvarezf wants to merge 1 commit into
JuliusBrussee:mainfrom
diegoalvarezf:feat/doctor-command
Open

feat(cli): add --doctor to report install health#818
diegoalvarezf wants to merge 1 commit into
JuliusBrussee:mainfrom
diegoalvarezf:feat/doctor-command

Conversation

@diegoalvarezf

Copy link
Copy Markdown

What

Adds caveman --doctor: a read-only report on an existing install. It never writes anything, so a broken install is diagnosed here and fixed by re-running the installer or --uninstall.

$ caveman --doctor
🪨 caveman doctor
  config dir: /home/u/.claude
  install mode: standalone hooks (or plugin not detected)

  problem  missing hook file: caveman-parse.js
  problem  orphaned SessionStart hook points at missing script: /home/u/.claude/hooks/caveman-activate.js
  note     statusline badge not configured

2 problem(s) found

Why

Half-broken installs are hard to diagnose today. A hook file deleted or edited by hand, a settings.json that stopped parsing after a manual edit, entries left behind pointing at scripts that no longer exist (#471), or standalone hooks still wired alongside the plugin so every event fires twice (#392). The symptom is a session that crashes at start, double-fires, or silently does nothing, and nothing tells the user which piece is wrong.

How

Doctor probes for the plugin the same way installClaude does (claude plugin list) and applies the checks that fit the mode it finds:

  • No plugin detected — the standalone hook files must all be present, unmodified against the shipped checksums.sha256, and wired into settings.json.
  • Plugin detected — the plugin owns that wiring, so missing standalone files are expected; standalone wiring found on top of the plugin is the conflict, and gets reported by name.

Orphaned entries are reported in either mode, since migrating between the two paths in either direction can strand them. A user hook whose path merely contains a caveman-like name is never flagged, reusing the exact-basename rule the settings helpers already apply.

Bare node invocations and a missing statusline are reported as notes rather than problems: the installer already migrates the former on re-run, and neither breaks anything.

Exits 1 when at least one problem was found, 0 otherwise. Honors --config-dir and --no-color.

Tests

19 tests in tests/installer/doctor.test.mjs covering both install modes, including a fake claude binary on PATH so the outcome never depends on what the machine running the suite happens to have installed, and a check that a broken install is left byte-for-byte untouched.

npm test passes 144/144 (125 existing + 19 new).

🤖 Generated with Claude Code

Half-broken installs are hard to diagnose today: a hook file deleted or
edited by hand, a settings.json that stopped parsing, entries left behind
pointing at scripts that no longer exist (JuliusBrussee#471), or standalone hooks still
wired alongside the plugin so every event fires twice (JuliusBrussee#392). The symptom
is a session that crashes, double-fires, or silently does nothing, with no
hint of which piece is wrong.

`caveman --doctor` reports on an existing install and exits without
touching anything. It probes for the plugin the same way installClaude
does and applies the checks that fit: with no plugin, the standalone hook
files must all be present, unmodified, and wired; with the plugin, that
wiring is the conflict rather than the requirement. Orphaned entries are
reported either way since migrating between the two paths can strand them.

Bare `node` invocations and a missing statusline are reported as notes,
not problems, because the installer already migrates the former on re-run.
Exits 1 when anything is wrong, 0 otherwise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant