PreCompact hook receives empty transcript_path

Resolved 💬 4 comments Opened Dec 11, 2025 by multimonty Closed Feb 27, 2026

Description

The PreCompact hook receives an empty string for transcript_path instead of the actual path to the conversation transcript file.

Expected Behavior

According to the hooks documentation, the PreCompact hook should receive:

{
  "session_id": "abc123",
  "transcript_path": "~/.claude/projects/.../session-id.jsonl",
  "trigger": "manual",
  ...
}

Actual Behavior

The hook receives:

{"transcript_path": ""}

Steps to Reproduce

  1. Configure a PreCompact hook in ~/.claude/settings.json:
{
  "hooks": {
    "PreCompact": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "INPUT=$(cat); echo \"$INPUT\" >> /tmp/precompact-debug.log"
          }
        ]
      }
    ]
  }
}
  1. Start a Claude Code session
  2. Run /compact command
  3. Check the log - transcript_path is empty

Environment

  • OS: macOS (Darwin 25.0.0)
  • Claude Code: Latest version

Use Case

I'm trying to backup conversation transcripts before compaction. The hook logic is correct but fails because it receives no path to the transcript file.

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗