Skip to content

fix(commands): register /caveman-stats so Claude Code doesn't reject it (#470)#505

Open
ousamabenyounes wants to merge 1 commit into
JuliusBrussee:mainfrom
ousamabenyounes:fix/issue-470
Open

fix(commands): register /caveman-stats so Claude Code doesn't reject it (#470)#505
ousamabenyounes wants to merge 1 commit into
JuliusBrussee:mainfrom
ousamabenyounes:fix/issue-470

Conversation

@ousamabenyounes

Copy link
Copy Markdown

Summary

Fixes #470

commands/ ships only 4 .toml files (caveman.toml, caveman-commit.toml,
caveman-init.toml, caveman-review.toml). caveman-stats.toml is missing,
so Claude Code rejects /caveman-stats as Unknown command before the
UserPromptSubmit hook in src/hooks/caveman-mode-tracker.js ever sees the
prompt — even though both README.md and INSTALL.md advertise the command and
the hook contains a statsMatch regex that intercepts and injects the stats
output as the hook reason.

This PR adds the missing commands/caveman-stats.toml so the slash command
is registered. The prompt field is /caveman-stats {{args}} so the resolved
prompt (after args substitution) matches the live hook regex and reaches the
existing stats handler.

Test verification (RED → GREEN)

Three regression tests live in tests/installer/slash-commands.test.mjs. They
mirror the live hook regex from src/hooks/caveman-mode-tracker.js so they
stay representative if the hook shifts.

RED (with commands/caveman-stats.toml stashed):

# tests 3
# pass 0
# fail 3
not ok 1 - #470 commands/caveman-stats.toml exists so Claude Code registers /caveman-stats
  error: 'Missing commands/caveman-stats.toml — Claude Code rejects /caveman-stats as "Unknown command" before the UserPromptSubmit hook can intercept (issue #470).'
not ok 2 - #470 caveman-stats.toml declares a non-empty description for the slash-command picker
  error: "ENOENT: no such file or directory, open '.../commands/caveman-stats.toml'"
not ok 3 - #470 caveman-stats.toml prompt is intercepted by the mode-tracker regex
  error: "ENOENT: no such file or directory, open '.../commands/caveman-stats.toml'"

GREEN (with the new toml applied):

# tests 3
# pass 3
# fail 0
ok 1 - #470 commands/caveman-stats.toml exists so Claude Code registers /caveman-stats
ok 2 - #470 caveman-stats.toml declares a non-empty description for the slash-command picker
ok 3 - #470 caveman-stats.toml prompt is intercepted by the mode-tracker regex

Full suite baseline preserved:

  • before: npm test → 47 pass / 4 fail (4 pre-existing opencode-installer failures, unrelated)
  • after: npm test → 50 pass / 4 fail (same 4, plus the 3 new tests above)

No green test flipped to red.

Files changed

File Change
commands/caveman-stats.toml NEW — registers /caveman-stats with description + prompt = "/caveman-stats {{args}}" so the resolved prompt matches the existing hook regex.
tests/installer/slash-commands.test.mjs NEW — three node:test cases pinning file presence, non-empty description, and prompt-matches-hook-regex for #470.

…an-stats

Without commands/caveman-stats.toml on disk Claude Code rejects
/caveman-stats as 'Unknown command' before the UserPromptSubmit
hook in src/hooks/caveman-mode-tracker.js can intercept it. README
and INSTALL.md both advertise the command; this brings the slash
command registry in line with the docs.

Fixes JuliusBrussee#470

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

/caveman-stats reports 'Unknown command' in Claude Code — missing commands/caveman-stats.toml

1 participant