user-prompt Hook
The user-prompt hook fires when the user submits a prompt to Claude Code. It captures the prompt text for future full-text search, detects references to plan files, and automatically links sessions to tasks.
Trigger Event
Fires on every user prompt submission.
What It Does
- Creates session record if it does not exist, including the current git branch
- Scans for plan file references (e.g.,
docs/plans/2026-02-10-feature.md) - Links session to task if a plan file is detected (auto-extracts task ID from filename)
- Counts prompt number (sequential within the session)
- Stores the prompt in the
user_promptstable for FTS5 search
Example Input
json
{
"session_id": "abc123-def456",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/Users/dev/my-app",
"hook_event_name": "user_prompt",
"prompt": "Implement P3-002 from docs/plans/2026-02-10-migration.md"
}Task Linking
When a prompt mentions a plan file, the hook:
- Extracts the file path from the prompt
- Derives a task ID from the plan filename (e.g.,
2026-02-10-migration) - Links the session to that task ID
- Enables cross-session task progress tracking via
massu_memory_sessions
This means all sessions working on the same plan automatically share progress information.
Tips
- Reference your plan file in your first prompt to enable task linking
- All prompts are searchable via
massu_prompt_analysis(observability tool) - Empty or whitespace-only prompts are silently ignored