2.1.47 untested · changelog-derived

Claude Code 2.1.47

**`last_assistant_message` hook field**: Stop and SubagentStop hooks can now access the final assistant response text directly without parsing transcript files, enabling cleaner automation of agent result capture and persistence.

4 new primitives 2 workflow recipes 63 fixes

New primitives

ctrl+f background agent killkeybinding

Terminate all background agents at once while allowing manual agent lifecycle control

Use `ctrl+f` to kill all background agents instead of double-pressing ESC. Background agents now continue running when you press ESC to cancel the main thread, giving you more control over agent lifecycle.
last_assistant_messagehook

Access the final assistant response text in Stop and SubagentStop hook inputs without parsing transcripts

Added `last_assistant_message` field to Stop and SubagentStop hook inputs, providing the final assistant response text so hooks can access it without parsing transcript files.
chat:newline keybinding actionkeybinding

Configure custom keybindings for multi-line input control

Added `chat:newline` keybinding action for configurable multi-line input (anthropics/claude-code#26075)
added_dirs statusline fieldsetting

Expose workspace directories added via `/add-dir` to external scripts and dashboards

Added `added_dirs` to the statusline JSON `workspace` section, exposing directories added via `/add-dir` to external scripts (anthropics/claude-code#26096)

Workflow recipes

Background agent fan-out with zero-copy result capture
ctrl+f keybinding + last_assistant_message hook field + ESC-detach for background agent lifecycle

The decoupling of background agent termination (ctrl+f to kill all) from main-thread control (ESC still works), combined with direct access to final answers in hook payloads, enables a cleaner multi-agent orchestration pattern where external systems can collect agent results without parsing transcripts.

Spawn N background agents with SubagentStop hooks that capture last_assistant_message to a result queue (database, message broker, or event log). Press ESC to detach the main thread while agents continue running. When ready, press ctrl+f to terminate the agent pool. The hook payloads already contain each agent's final answer, so result collection is O(1) per agent, not O(lines) through transcript parsing. Enables fan-out patterns for parallel research, multi-model evaluation, or batch agent workflows without transcript I/O bottlenecks.

Live workspace dashboard with agent-synchronized context
added_dirs statusline field + last_assistant_message hook field + external script integration

External orchestration scripts can now watch both the active workspace context (via added_dirs in statusline JSON) and the latest agent outcomes (via last_assistant_message), enabling a dashboard that surfaces project context alongside agent-derived insights in real time.

Write an external script that polls the Claude Code statusline JSON to extract workspace.added_dirs (active project directories) and installs a Stop hook that writes last_assistant_message to a shared state file. A dashboard consumes both signals: green-light directories where work is active, paired with the last agent summary/decision for those dirs. Useful for multi-workspace setups where context and outcomes need to stay in sync — the agent can report "completed analysis for /dir/a" and the dashboard immediately knows to refresh views only for that directory.

Agentic relevance

The `last_assistant_message` primitive enables cleaner agent orchestration: hook payloads can now capture final answers directly without parsing transcripts, simplifying dashboard integration and result persistence. Combined with improved background agent lifecycle control (`ctrl+f` keybinding), this version enables better multi-agent coordination patterns. The `added_dirs` statusline field supports external workspace awareness for agent dashboards tracking active project directories.

Hardening & fixes (63)

  • Fixed FileWriteTool line counting to preserve intentional trailing blank lines
  • Fixed Windows terminal rendering bugs with `os.EOL` (`\r\n`) causing incorrect line counts
  • Improved VS Code plan preview auto-updates, comment gating, and rejection handling
  • Fixed markdown bold/colored text shifting to wrong characters on Windows due to line endings
  • Fixed compaction failing with many PDF documents by stripping document blocks
  • Improved memory usage in long-running sessions through API stream buffer and agent context cleanup
  • Improved startup performance by deferring SessionStart hook execution (~500ms reduction)
  • Fixed bash tool output silently discarded on Windows with MSYS2/Cygwin shells
  • Improved `@` file mention performance with pre-warming index and session-based caching
  • Improved memory usage by trimming agent task message history after completion
  • Eliminated O(n²) message accumulation in long agent sessions
  • Fixed bash permission classifier hallucinating match descriptions
  • Fixed user-defined agents only loading one file on NFS/FUSE filesystems with zero inodes
  • Fixed plugin agent skills silently failing when referenced by bare name
  • Display search patterns in collapsed tool results with quotes for clarity
  • Fixed Windows CWD tracking temp file accumulation
  • Fixed API 400 errors in sessions with concurrent agents from interleaved streaming blocks
  • Simplified teammate navigation to Shift+Down only (with wrapping)
  • Fixed single file write/edit error aborting parallel file mutations
  • Fixed custom session titles lost after resume
  • Fixed collapsed read/search hint text overflow on narrow terminals
  • Fixed bash commands with backslash-newline continuation producing spurious empty arguments
  • Fixed built-in slash commands hidden in autocomplete when many skills installed
  • Fixed MCP servers not appearing in MCP Management Dialog after deferred loading
  • Fixed session name persisting in status bar after `/clear` command
  • Fixed crash when skill `name` or `description` is bare number
  • Fixed /resume silently dropping sessions when first message exceeds 16KB
  • Fixed `claude doctor` misclassifying mise and asdf-managed installations
  • Fixed zsh heredoc read-only file system errors in sandboxed commands
  • Fixed agent progress indicator showing inflated tool use count
  • Fixed image pasting on WSL2 with BMP format from Windows clipboard
  • Fixed background agent results returning raw transcript data
  • Fixed Warp terminal incorrectly prompting for Shift+Enter setup
  • Fixed CJK wide characters causing misaligned timestamps and layout elements
  • Fixed custom agent `model` field ignored when spawning team teammates
  • Fixed plan mode lost after context compaction
  • Fixed `alwaysThinkingEnabled: true` not enabling thinking on Bedrock and Vertex
  • Fixed `tool_decision` OTel telemetry event not emitted in headless/SDK mode
  • Fixed session name lost after context compaction
  • Increased initial resume picker session count from 10 to 50
  • Fixed Windows worktree session matching with differing drive letter casing
  • Fixed `/resume <session-id>` failing with >16KB first message
  • Fixed "Always allow" on multiline bash commands creating invalid permission patterns
  • Fixed React crash (error #31) with YAML sequence syntax in skill `argument-hint`
  • Fixed crash when using `/fork` on sessions with web search (null deserialization)
  • Fixed read-only git commands triggering FSEvents loops on macOS
  • Fixed custom agents/skills not discovered in git worktrees
  • Fixed non-interactive subcommands blocked inside nested Claude sessions
  • Fixed Windows loading same CLAUDE.md twice with differing drive letter casing
  • Fixed inline code spans incorrectly parsed as bash commands
  • Fixed teammate spinners not respecting custom spinnerVerbs
  • Fixed shell commands permanently failing after deleting own working directory
  • Fixed hooks silently failing on Windows by using Git Bash instead of cmd.exe
  • Fixed LSP findReferences returning gitignored file results
  • Moved config backup files to `~/.claude/backups/` directory
  • Fixed sessions with >16KB first prompts disappearing from /resume list
  • Fixed shell functions with double-underscore prefixes not preserved across sessions
  • Fixed spinner showing "0 tokens" before receiving tokens
  • Fixed VSCode conversation messages dimmed during AskUserQuestion dialog
  • Fixed background tasks failing in git worktrees with URL resolution
  • Fixed Right Alt key leaving `[25~` escape sequence residue on Windows/Git Bash
  • Updated `/rename` command to change terminal tab title by default
  • Fixed Edit tool corrupting Unicode curly quotes

Raw changelog

## 2.1.47

- Fixed FileWriteTool line counting to preserve intentional trailing blank lines instead of stripping them with `trimEnd()`.
- Fixed Windows terminal rendering bugs caused by `os.EOL` (`\r\n`) in display code — line counts now show correct values instead of always showing 1 on Windows.
- Improved VS Code plan preview: auto-updates as Claude iterates, enables commenting only when the plan is ready for review, and keeps the preview open when rejecting so Claude can revise.
- Fixed a bug where bold and colored text in markdown output could shift to the wrong characters on Windows due to `\r\n` line endings.
- Fixed compaction failing when conversation contains many PDF documents by stripping document blocks alongside images before sending to the compaction API (anthropics/claude-code#26188)
- Improved memory usage in long-running sessions by releasing API stream buffers, agent context, and skill state after use
- Improved startup performance by deferring SessionStart hook execution, reducing time-to-interactive by ~500ms.
- Fixed an issue where bash tool output was silently discarded on Windows when using MSYS2 or Cygwin shells.
- Improved performance of `@` file mentions - file suggestions now appear faster by pre-warming the index on startup and using session-based caching with background refresh.
- Improved memory usage by trimming agent task message history after tasks complete
- Improved memory usage during long agent sessions by eliminating O(n²) message accumulation in progress updates
- Fixed the bash permission classifier to validate that returned match descriptions correspond to actual input rules, preventing hallucinated descriptions from incorrectly granting permissions
- Fixed user-defined agents only loading one file on NFS/FUSE filesystems that report zero inodes (anthropics/claude-code#26044)
- Fixed plugin agent skills silently failing to load when referenced by bare name instead of fully-qualified plugin name (anthropics/claude-code#25834)
- Search patterns in collapsed tool results are now displayed in quotes for clarity
- Windows: Fixed CWD tracking temp files never being cleaned up, causing them to accumulate indefinitely (anthropics/claude-code#17600)
- Use `ctrl+f` to kill all background agents instead of double-pressing ESC. Background agents now continue running when you press ESC to cancel the main thread, giving you more control over agent lifecycle.
- Fixed API 400 errors ("thinking blocks cannot be modified") that occurred in sessions with concurrent agents, caused by interleaved streaming content blocks preventing proper message merging.
- Simplified teammate navigation to use only Shift+Down (with wrapping) instead of both Shift+Up and Shift+Down.
- Fixed an issue where a single file write/edit error would abort all other parallel file write/edit operations. Independent file mutations now complete even when a sibling fails.
- Added `last_assistant_message` field to Stop and SubagentStop hook inputs, providing the final assistant response text so hooks can access it without parsing transcript files.
- Fixed custom session titles set via `/rename` being lost after resuming a conversation (anthropics/claude-code#23610)
- Fixed collapsed read/search hint text overflowing on narrow terminals by truncating from the start.
- Fixed an issue where bash commands with backslash-newline continuation lines (e.g., long commands split across multiple lines with `\`) would produce spurious empty arguments, potentially breaking command execution.
- Fixed built-in slash commands (`/help`, `/model`, `/compact`, etc.) being hidden from the autocomplete dropdown when many user skills are installed (anthropics/claude-code#22020)
- Fixed MCP servers not appearing in the MCP Management Dialog after deferred loading
- Fixed session name persisting in status bar after `/clear` command (anthropics/claude-code#26082)
- Fixed crash when a skill's `name` or `description` in SKILL.md frontmatter is a bare number (e.g., `name: 3000`) — the value is now properly coerced to a string (anthropics/claude-code#25837)
- Fixed /resume silently dropping sessions when the first message exceeds 16KB or uses array-format content (anthropics/claude-code#25721)
- Added `chat:newline` keybinding action for configurable multi-line input (anthropics/claude-code#26075)
- Added `added_dirs` to the statusline JSON `workspace` section, exposing directories added via `/add-dir` to external scripts (anthropics/claude-code#26096)
- Fixed `claude doctor` misclassifying mise and asdf-managed installations as native installs (anthropics/claude-code#26033)
- Fixed zsh heredoc failing with "read-only file system" error in sandboxed commands (anthropics/claude-code#25990)
- Fixed agent progress indicator showing inflated tool use count (anthropics/claude-code#26023)
- Fixed image pasting not working on WSL2 systems where Windows copies images as BMP format (anthropics/claude-code#25935)
- Fixed background agent results returning raw transcript data instead of the agent's final answer (anthropics/claude-code#26012)
- Fixed Warp terminal incorrectly prompting for Shift+Enter setup when it supports it natively (anthropics/claude-code#25957)
- Fixed CJK wide characters causing misaligned timestamps and layout elements in the TUI (anthropics/claude-code#26084)
- Fixed custom agent `model` field in `.claude/agents/*.md` being ignored when spawning team teammates (anthropics/claude-code#26064)
- Fixed plan mode being lost after context compaction, causing the model to switch from planning to implementation mode (anthropics/claude-code#26061)
- Fixed `alwaysThinkingEnabled: true` in settings.json not enabling thinking mode on Bedrock and Vertex providers (anthropics/claude-code#26074)
- Fixed `tool_decision` OTel telemetry event not being emitted in headless/SDK mode (anthropics/claude-code#26059)
- Fixed session name being lost after context compaction — renamed sessions now preserve their custom title through compaction (anthropics/claude-code#26121)
- Increased initial session count in resume picker from 10 to 50 for faster session discovery (anthropics/claude-code#26123)
- Windows: fixed worktree session matching when drive letter casing differs (anthropics/claude-code#26123)
- Fixed `/resume <session-id>` failing to find sessions whose first message exceeds 16KB (anthropics/claude-code#25920)
- Fixed "Always allow" on multiline bash commands creating invalid permission patterns that corrupt settings (anthropics/claude-code#25909)
- Fixed React crash (error #31) when a skill's `argument-hint` in SKILL.md frontmatter uses YAML sequence syntax (e.g., `[topic: foo | bar]`) — the value is now properly coerced to a string (anthropics/claude-code#25826)
- Fixed crash when using `/fork` on sessions that used web search — null entries in search results from transcript deserialization are now handled gracefully (anthropics/claude-code#25811)
- Fixed read-only git commands triggering FSEvents file watcher loops on macOS by adding --no-optional-locks flag (anthropics/claude-code#25750)
- Fixed custom agents and skills not being discovered when running from a git worktree — project-level `.claude/agents/` and `.claude/skills/` from the main repository are now included (anthropics/claude-code#25816)
- Fixed non-interactive subcommands like `claude doctor` and `claude plugin validate` being blocked inside nested Claude sessions (anthropics/claude-code#25803)
- Windows: Fixed the same CLAUDE.md file being loaded twice when drive letter casing differs between paths (anthropics/claude-code#25756)
- Fixed inline code spans in markdown being incorrectly parsed as bash commands (anthropics/claude-code#25792)
- Fixed teammate spinners not respecting custom spinnerVerbs from settings (anthropics/claude-code#25748)
- Fixed shell commands permanently failing after a command deletes its own working directory (anthropics/claude-code#26136)
- Fixed hooks (PreToolUse, PostToolUse) silently failing to execute on Windows by using Git Bash instead of cmd.exe (anthropics/claude-code#25981)
- Fixed LSP `findReferences` and other location-based operations returning results from gitignored files (e.g., `node_modules/`, `venv/`) (anthropics/claude-code#26051)
- Moved config backup files from home directory root to `~/.claude/backups/` to reduce home directory clutter (anthropics/claude-code#26130)
- Fixed sessions with large first prompts (>16KB) disappearing from the /resume list (anthropics/claude-code#26140)
- Fixed shell functions with double-underscore prefixes (e.g., `__git_ps1`) not being preserved across shell sessions (anthropics/claude-code#25824)
- Fixed spinner showing "0 tokens" counter before any tokens have been received (anthropics/claude-code#26105)
- VSCode: Fixed conversation messages appearing dimmed while the AskUserQuestion dialog is open (anthropics/claude-code#26078)
- Fixed background tasks failing in git worktrees due to remote URL resolution reading from worktree-specific gitdir instead of the main repository config (anthropics/claude-code#26065)
- Fixed Right Alt key leaving visible `[25~` escape sequence residue in the input field on Windows/Git Bash terminals (anthropics/claude-code#25943)
- The `/rename` command now updates the terminal tab title by default (anthropics/claude-code#25789)
- Fixed Edit tool silently corrupting Unicode curly quotes (\u201c\u201d \u2018\u2019) by replacing them with straight quotes when making edits (anthropics/claude-code#26141)
- Fixed OSC 8 hyperlinks only being clickable on the first line when link text wraps across multiple terminal lines.