[FEATURE] Separate IDE context from user prompt in UserPromptSubmit hook JSON

Resolved 💬 2 comments Opened Jan 17, 2026 by internationils Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

The current UserPromptSubmit hook returns a json where the prompt contains ide_* information (ide_selection, ide_opened_file, ide_opened_file_message, ...) and that content can sometimes be VERY long and contain any strings and characters, making it hard to reliably extract only the prompt itself.

I need to log the prompts for auditing purposes, and have lost prompts due to parsing issues related to the ide_* content. It would be very helpful to expand the json structure to separate these out from the direct users "prompt" text

Current hook json structure:

{
  "session_id": "778d0847-14a3-49e5-80d7-nnnn",
  "transcript_path": "/Users/username/.claude/projects/.../778d0847.jsonl",
  "cwd": "/Users/username/.../ai_content_development",
  "permission_mode": "default",
  "hook_event_name": "UserPromptSubmit",
  "prompt": "<ide_opened_file>The user opened file...</ide_opened_file>\n<ide_selection>selected text</ide_selection>\nactual user prompt"
}

Proposed Solution

Requested structure (Option A - grouped ide object):

{
  "session_id": "...",
  "prompt": "actual user prompt",
  "ide": {
    "opened_file": "/path/to/file.md",
    "selection": "selected text"
  }
}

Requested structure (Option B - ide array with type prefix):

{
  "session_id": "...",
  "prompt": "actual user prompt",
  "ide": [
    "opened_file: /path/to/file.md",
    "selection: selected text here"
  ]
}

Benefits:

  • No regex/perl filtering needed in hook scripts
  • IDE context available as structured data when needed
  • Cleaner separation of concerns
  • Option A groups related IDE context; Option B allows flexible typing with simple string parsing

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

I am logging all user prompts (auditing necessity!) and it is sometimes hard to get the actual prompt due to the extensive content in the ide_* details. Separating out would remove the need for parsing and allow direct usage of the content, and this should be easily doable in the existing json structure.

Additional Context

_No response_

View original on GitHub ↗

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