{"version":"2.1.327","anchor":"new-shell-cwd-system-message-for-sdk-hosts","canonical_anchor":"new-shell-cwd-system-message-for-sdk-hosts","heading":"New shell_cwd message can replace hooks that only read the shell's folder","tier":"use","area":"SDK","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.327\/e\/new-shell-cwd-system-message-for-sdk-hosts","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.327","markdown":"### New shell_cwd message can replace hooks that only read the shell's folder\n\nSDK hosts that mark a hook matcher replacedByFrame: 'shell_cwd' get a shell_cwd system message with the shell's folder instead of a hook callback\n\n**What**\n\nPrograms that host Claude Code through the SDK can register hooks, which are their own code that Claude Code calls at set points. One such point is PostToolUse, which runs after a tool call succeeds. This release adds a cheaper way to learn which folder a shell command left you in.\n\n- `shell_cwd` is a new system message. It reports the folder a Bash or PowerShell call left its shell in.\n\n- `contextOnly` and `replacedByFrame` are two new internal fields on SDK hook callbacks (hook matchers).\n\n- When a host marks a hook matcher `replacedByFrame: 'shell_cwd'`, Claude Code sends `system\/shell_cwd` instead of calling callbacks that only read the shell folder. Only those hosts receive the message.\n\n**Why**\n\nThis changes the contract between Claude Code and the programs that host it, such as desktop apps. A host that only needs the shell's current folder can receive it as a message instead of running a hook after every command.\n\n- Area: SDK\n- Names: `shell_cwd`\n- Tier: Use it now\n- Useful: 4\/5\n- Signal: 3\/5\n- Scope: individual\n- Heads-up: no"}