Combo Test: Session-Aware Setup
Setup hooks can create session-specific temporary state that persists for the session's lifetime.
A setup hook that fires on session initialization, receives the session_id, and creates session-scoped temporary state (directories, files) that persists for the session's lifetime.
How It Works
The setup hook is a command defined in ~/.claude/settings.json under hooks.Setup. When Claude Code starts with --init, the hook receives a JSON input containing session_id, trigger, and cwd. The hook script extracts the session_id and uses it to create a session-specific directory in /tmp/claude-sessions/{session_id}/. This directory serves as temporary state storage shared across all tools and subsequent hooks within that session.
What the Test Found
The test ran echo "hi" | claude --init -p against a setup hook that created a session-scoped temp directory and logged initialization details. The hook executed successfully, created the expected directory structure at /tmp/claude-sessions/a5f6bfff-d19c-4b6d-b9c8-e71eb16a9661/, and wrote setup.log with timestamp, trigger type (init), and working directory. The session_id proved unique and reliably extractable from hook input. The test was VALIDATED on 2026-01-16.
Why It Matters
This primitive enables three critical patterns: (1) session-scoped temporary files that do not require cleanup hooks, (2) cross-tool state sharing where setup creates a known directory that later hooks read or write, and (3) centralized session activity logging without global side effects. A setup hook can prepare the workspace before the user's first command, eliminating race conditions and ambient state pollution across concurrent sessions.
Caveats
Directories created in /tmp/claude-sessions/ persist after the session ends; the test notes this as a potential cleanup concern. The session_id is a UUID, and cleanup logic must be external (cron, explicit shutdown hook, or OS temp-file policy). No performance data was collected on hook latency or filesystem contention under concurrent sessions.
- file2.1.10/tests/combo-01-session-aware-setup/TEST-RESULTS.md
primitive_a98e9bf024a7c50af4b1a16ded255199b87705613b1e2fd064d57fa75a6b679d2856ceafad6b1daa8f982493871b6dd722805d843c21e39de912198e034a800f37688db4cf6616db5688a01a54f9ac12487133b1860a5da14e7bacd890276b36da13464ff99106f6400b66448e6ce0eSigned with an ed25519 key held off the repo. Anyone can verify against the published public key; nobody without the secret key can forge it. Click verify: it recomputes the signature in your browser. The signature proves integrity and authorship of this exact content — not a third-party timestamp or that the underlying claim is objectively true. signedAt is when the @f3/attest pipeline ran, not when the work happened; the evidence refs carry the source dates.
- instance-of Skill Runtime Class
- introduces (in) 2.1.10 (2.1.10) Release
- verifies (in) Combo Test: Session-Aware Setup — runtime test Test