← 2.1.9 Test tested · runtime-test

${CLAUDE_SESSION_ID} Substitution — runtime test

Hands-on runtime battle-test of ${CLAUDE_SESSION_ID} Substitution. Result: PASS.

${CLAUDE_SESSION_ID} Substitution is a runtime feature that replaces the placeholder ${CLAUDE_SESSION_ID} with the active session's UUID whenever a skill is loaded, enabling session-scoped state management and coordination.

How It Works

At skill load time, the Claude Code harness scans the skill's SKILL.md frontmatter and body text for the literal string ${CLAUDE_SESSION_ID} and substitutes each occurrence with the current session's UUID. The substitution is literal and happens before the skill instructions are presented to the agent; the session ID is then available as a concrete value throughout the skill's execution lifetime.

The Test

A skill was created with ${CLAUDE_SESSION_ID} embedded in its text. The skill was then invoked. The substitution occurred correctly: the placeholder was replaced with the observed session UUID 0ae83877-5583-4169-9adc-ea36d4a4392f. Four verified behaviors confirmed the feature's completeness: substitution worked, the ID remained consistent within the session, substitution succeeded in both frontmatter paths and body text, and no failures occurred under the test conditions.

Use Cases

The feature enables session-scoped state files (storing data in /tmp/state-${CLAUDE_SESSION_ID}.json), session-attributed logging, cross-skill coordination via session-specific file paths, and debugging attribution of artifacts back to their originating session. A single session ID can tag all output from a multi-skill workflow, making audit trails and state isolation straightforward.

Implementation Note

The substitution happens once, at load time, rather than dynamically on each reference. This makes the session ID a stable constant within the skill's execution, avoiding both evaluation complexity and the risk of ID instability mid-execution.

Primary source
⎘ 2.1.9/tests/01-session-id/TEST-RESULTS.mdverbatim from the corpus

Test Results: ${CLAUDE_SESSION_ID} Substitution

Feature: Added ${CLAUDE_SESSION_ID} string substitution for skills to access the current session ID

Tested: 2026-01-16 Version: 2.1.9

Test Method

  1. Created skill with ${CLAUDE_SESSION_ID} in SKILL.md text
  2. Invoked skill
  3. Verified substitution occurred

Result: PASS

Session ID observed: 0ae83877-5583-4169-9adc-ea36d4a4392f

The ${CLAUDE_SESSION_ID} placeholder was replaced with the actual session ID when the skill was loaded.

Verified Behaviors

  1. Substitution works - Placeholder replaced with actual UUID
  2. Consistent within session - Same ID appears throughout
  3. Works in skill frontmatter paths - Can be used in allowed-tools paths, etc.
  4. Works in skill body text - Substituted in instructions

Use Cases

  1. Session-scoped state files - Store state in /tmp/state-${CLAUDE_SESSION_ID}.json
  2. Logging with session attribution - Log files tagged with session ID
  3. Cross-skill coordination - Skills can share state via session-specific paths
  4. Debugging - Know which session generated which artifacts

Test Skill

See .claude/skills/test-session-id/SKILL.md for the test skill.

Notes

Clean implementation. The substitution happens at skill load time, making the session ID available throughout the skill's execution.

Status: PASS

Evidence & receipt
◇ ed25519 receipt
idtest_15b2fd343ba908bdbdd8fdae
alged25519
pubkey9b87705613b1e2fd064d57fa75a6b679d2856ceafad6b1daa8f982493871b6dd
sig805401fd8ffb1b15e614e4c1794dffe6135bb7deb3127d0a4714707c1c02e81e6df86ec7c82f8e552e834468dd8a653ee51a99c4dbf55abbf9af3b4b2522c70f

Signed 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.

Connected