diff --git a/README.md b/README.md index eeb3cd6..f45625c 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,57 @@ Codex: Install once. Use in all sessions after that. One rock. That it. +### Optional: SessionStart Hook + Visible Mode Badge + +If you want Claude Code to auto-load caveman rules at session start **and** show a persistent `[CAVEMAN]` badge in your statusline (so you can see at a glance that caveman mode is loaded), wire up the hook in `hooks/caveman-activate.js`. + +> [!NOTE] +> This is a **Claude Code-only** optional addition. The core skill install above works fine without it. Skip this section if you're using Cursor, Codex, or another agent. + +**1. Install the hook** — copy `hooks/caveman-activate.js` to `~/.claude/hooks/caveman-activate.js`, then add it to `~/.claude/settings.json`: + +```json +{ + "hooks": { + "SessionStart": [ + { + "hooks": [ + { + "type": "command", + "command": "node \"~/.claude/hooks/caveman-activate.js\"", + "statusMessage": "Loading caveman mode..." + } + ] + } + ] + } +} +``` + +The hook writes a flag file at `~/.claude/.caveman-active` and emits the caveman ruleset reminder as SessionStart context. + +**2. Add the badge to your statusline** — in your Claude Code statusline script, check for the flag file and prepend a badge: + +```js +const fs = require('fs'); +const path = require('path'); +const os = require('os'); + +// ...existing statusline logic... + +let cavemanBadge = ''; +const cavemanFlag = path.join(os.homedir(), '.claude', '.caveman-active'); +if (fs.existsSync(cavemanFlag)) { + cavemanBadge = '\x1b[1;38;5;208m[CAVEMAN]\x1b[0m │ '; +} + +process.stdout.write(`${cavemanBadge}${rest_of_your_statusline}`); +``` + +Restart Claude Code and an orange `[CAVEMAN]` badge sits in your statusline for the entire session. + +**Why a flag file?** `SessionStart` hook stdout is injected as hidden system-reminder context — useful for Claude, invisible to users. The statusline runs as a separate process and can't see that context. A flag file is the simplest bridge between "the hook ran" and "the statusline can prove it." + ## Usage Trigger with: diff --git a/hooks/caveman-activate.js b/hooks/caveman-activate.js new file mode 100644 index 0000000..d86e798 --- /dev/null +++ b/hooks/caveman-activate.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node +// caveman — optional Claude Code SessionStart activation hook +// +// When wired into ~/.claude/settings.json as a SessionStart hook: +// - Writes a flag file at ~/.claude/.caveman-active so a statusline +// script can prove caveman mode is loaded (see README for the badge +// snippet — SessionStart stdout is otherwise invisible to users) +// - Emits a short ruleset reminder as SessionStart context +// +// This is a pure addition — if you don't wire it up, nothing changes. +// Install instructions: see the "Optional: SessionStart Hook" section +// in README.md. + +const fs = require('fs'); +const path = require('path'); +const os = require('os'); + +const flagPath = path.join(os.homedir(), '.claude', '.caveman-active'); + +try { + fs.mkdirSync(path.dirname(flagPath), { recursive: true }); + fs.writeFileSync(flagPath, String(Date.now())); +} catch (e) { + // Silent fail -- flag is best-effort, don't block the hook +} + +process.stdout.write( + "CAVEMAN MODE ACTIVE. Rules: Drop articles/filler/pleasantries/hedging. " + + "Fragments OK. Short synonyms. Pattern: [thing] [action] [reason]. [next step]. " + + "Not: 'Sure! I'd be happy to help you with that.' " + + "Yes: 'Bug in auth middleware. Fix:' " + + "Code/commits/security: write normal. " + + "User says 'normal' or 'stop caveman' to deactivate." +);