VSCode extension: /clear does not fire SessionEnd hook

Resolved 💬 3 comments Opened Apr 19, 2026 by DeveloperrOp Closed Apr 23, 2026

Summary

When running Claude Code inside the VSCode native extension, the /clear command does not trigger the SessionEnd hook. In the standalone CLI the same command correctly fires SessionEnd with reason: "clear" and then SessionStart with source: "clear".

This breaks any hook-based workflow that depends on transcript capture at /clear time (e.g. dumping transcripts for archival before the context is cleared).

Environment

  • Claude Code: 2.1.114
  • OS: Windows 11 Home (10.0.26200)
  • Shell: bash (Git Bash)
  • Hook registered in ~/.claude/settings.json under SessionEnd (no matcher, so it should fire for any reason).

Reproduction

  1. Configure a global SessionEnd hook in ~/.claude/settings.json that simply appends a line to a log file when it receives stdin.
  2. Open Claude Code inside the VSCode native extension, send a prompt, wait for a reply.
  3. Run /clear.
  4. Check the hook log — no new line written. Also the next SessionStart payload carries source: "startup" instead of source: "clear".
  5. Repeat the same procedure in a plain terminal (claude CLI, not VSCode). The hook log now shows a SessionEnd entry, and the next SessionStart carries source: "clear".

Expected behavior

/clear should fire SessionEnd with reason: "clear" and subsequent SessionStart with source: "clear" in both the CLI and the VSCode extension — consistent with the documented hook lifecycle (https://docs.claude.com/en/docs/claude-code/hooks).

Actual behavior (VSCode extension only)

  • SessionEnd hook is not invoked on /clear.
  • SessionStart fires for the new session but reports source: "startup" instead of source: "clear", making it impossible to distinguish a fresh launch from a /clear-induced restart.

Observed log diff

Same cwd, same \settings.json\, same hook script. Only the invocation surface differs.

VSCode extension (\/clear\ → new session, no SessionEnd):
\\\
19:24:10 session-start: unassigned cwd=d:\...\Бодя сайт (sid=468c0b09, source=resume)
19:39:19 session-start: unassigned cwd=d:\...\Бодя сайт (sid=6e44c44d, source=startup)
\
\\

CLI (\/clear\ → SessionEnd fires, source=clear):
\\\
19:45:36 session-start: unassigned cwd=D:\...\Бодя сайт (sid=982e74ee, source=startup)
19:46:07 sessionend: OK unassigned=Бодя сайт sid=982e74ee
19:46:07 session-start: unassigned cwd=D:\...\Бодя сайт (sid=3c268ce4, source=clear)
\
\\

View original on GitHub ↗

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