[BUG] CLI crashes with panic on UTF-8 emoji in CLAUDE.md
Bug Description
The Claude Code CLI crashes with a Rust panic when processing emoji characters in the CLAUDE.md file. The error occurs during UTF-8 string processing when the code attempts to split a string at a non-character boundary inside a multi-byte emoji character.
Error Message
thread '<unnamed>' (19268) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 3 is not a char boundary; it is inside '🔴' (bytes 0..4) of `🔴'}</span>`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort claude
Steps to Reproduce
- Create a
CLAUDE.mdfile in your project root - Add emoji characters (e.g., 🔴, 🟡, 🟢) anywhere in the file
- Run the
claudecommand - The CLI immediately crashes with the panic error above
Expected Behavior
The CLI should handle UTF-8 multi-byte characters (including emoji) correctly without crashing.
Actual Behavior
The CLI crashes with a panic when attempting to process emoji characters, specifically when trying to index into the string at a byte position that falls within a multi-byte character boundary.
Environment
- Platform: macOS (Darwin 24.1.0)
- Claude Code Version: Latest (based on error timestamp)
- Shell: zsh
Workaround
Remove all emoji characters from CLAUDE.md and replace them with plain text alternatives.
Example fix:
- ### 🔴 Critical
+ ### [CRITICAL]
Root Cause Analysis
The error indicates that the CLI is attempting to slice a UTF-8 string at byte index 3, which falls inside the 4-byte emoji character '🔴'. This suggests the code is using byte indexing instead of character-aware string operations.
Suggested Fix
Use character boundary-aware string operations when parsing CLAUDE.md content. Rust's string slicing should use methods like:
str::char_indices()for iterating with proper boundariesstr::get(range)instead of direct indexing, which returnsNonefor invalid boundaries- Ensure all substring operations respect UTF-8 character boundaries
Additional Context
This is a critical bug as it prevents users from using emoji in their documentation files, which is increasingly common for visual clarity and categorization.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗