fix: auto-create .claude/current-mode if missing for coordination hooks

The UserPromptSubmit hook requires .claude/current-mode to determine work mode
and gate coordination lock checks. This file is machine-local (gitignored) but
had no initialization logic for fresh clones, causing hooks to fail.

Changes:
- check-messages.sh: Added auto-creation logic with "general" as default
- CLAUDE.md: Documented auto-initialization behavior
- ONBOARDING.md: Added machine-local configuration section
- session-logs/2026-05-19-session.md: Documented investigation and fix

Impact:
- Fixes coordination hooks on all machines
- Prevents first-clone hook failures
- No manual setup required
- Backwards compatible

Resolves: "cood hook seems to be broken on all my machines"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 09:47:28 -07:00
parent efb15f0aa6
commit 90fcbb6895
4 changed files with 170 additions and 0 deletions

View File

@@ -67,6 +67,8 @@ echo dev > .claude/current-mode # substitute the actual mode name
```
This file is gitignored (machine-local). The `UserPromptSubmit` hook reads it to gate the lock check on dev mode.
**Auto-initialization:** If `.claude/current-mode` is missing (e.g., fresh clone), the UserPromptSubmit hook automatically creates it with "general" as the default mode. No manual setup required.
---
## Identity: You Are a Coordinator

View File

@@ -27,6 +27,21 @@ When you open Claude Code for the first time on a new machine, Claude will ask w
After that, every session log and git commit is attributed to you.
### Machine-local configuration
Some configuration files are **machine-local** (gitignored, not synced) because they contain machine-specific paths or settings:
| File | Purpose | Auto-created? |
|------|---------|---------------|
| `.claude/identity.json` | Your name, email, vault path | YES — during onboarding |
| `.claude/current-mode` | Work mode (dev, infra, client, etc.) | YES — defaults to "general" |
**`.claude/current-mode`** is used by coordination hooks to determine behavior:
- In `dev` mode: Hooks show active locks as warnings but don't block
- In other modes: Hooks enforce coordination protocol more strictly
You never need to manually create this file — the UserPromptSubmit hook initializes it automatically on first run. Claude updates it when switching modes (e.g., when you say "work on Dataforth" switches to client mode).
### GuruRMM repo — one-time setup per machine
The GuruRMM repo (`projects/msp-tools/guru-rmm/`) requires one extra step after cloning or first use. Run this from the repo root:

View File

@@ -5,6 +5,14 @@ API="http://172.16.3.30:8001"
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
MODE_FILE="${SCRIPT_DIR}/current-mode"
# --- Initialize mode file if missing -----------------------------------------
# The mode file is machine-local (gitignored) and required by this hook.
# If missing, create it with "general" as the default mode.
if [ ! -f "$MODE_FILE" ]; then
echo "general" > "$MODE_FILE"
echo "[INFO] Created .claude/current-mode with default mode: general" >&2
fi
# Read short username alias from identity.json (if present)
IDENTITY_FILE="${SCRIPT_DIR}/identity.json"
USER_ALIAS=""