[BUG] Bad substitution: key.padEnd" error causes Claude Code to crash
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code crashes with a "Bad substitution" error when processing test coverage output.
### Error Message
Error: Bad substitution: key.padEnd
at D (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:80:79195)
### Context
- What was happening: Running test coverage with
pnpm test:coverageon a Next.js project - Claude Code version: 1.0.117
- Node version: v22.15.0
- OS: macOS Sequoia 15.6.1
- Project type: Next.js with Vitest
### Steps that led to the error
- Claude was working on improving test coverage
- Running
pnpm test:coveragecommand - The coverage report was being processed
- Error occurred during output parsing
### Additional Information
The error appears to be in the shell command parser trying to interpret JavaScript method names as shell variable substitutions.
What Should Happen?
Claude Code should successfully parse and display the test coverage output from pnpm test:coverage without crashing. The coverage report should be shown in the terminal, and Claude should be able to continue working on improving test coverage based on the results.
Error Messages/Logs
Error: Bad substitution: key.padEnd
at D (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:80:79195)
at file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:80:79854
at Array.map (<anonymous>)
at VX9 (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:80:78933)
at Object.A (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:80:80018)
at nv6 (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1741:31727)
at ov6 (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1741:35696)
at file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1741:36245
at Array.every (<anonymous>)
at $2B (file:///Users/[REDACTED]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1741:36183)
Steps to Reproduce
### Steps to Reproduce
- Open a Next.js project with Vitest configured for testing
- Have Claude Code work on improving test coverage for service files
- Run
pnpm test:coverage(or equivalent coverage command) - When the coverage report generates output with formatted tables containing JavaScript-related content
- Claude Code crashes while processing/displaying the coverage report output
### Additional Context
- The crash occurred specifically when working on tests for service files with 0% initial coverage
- The coverage report was showing improvements (from 73.42% to 77.04% overall)
- The error suggests the CLI's shell parser incorrectly interpreted JavaScript method names (like
padEnd) in the output as shell variable substitutions
Note: The exact trigger seems to be when the coverage report output contains certain patterns that the shell parser misinterprets. It's likely related to how the tool processes formatted table output
or JavaScript code snippets that might appear in test results.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
1.0.117
Platform
Other
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗