[BUG] Shell snapshot generator double-prefixes aliases starting with "-", causing "alias: --: not found" error
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?
When the shell has an alias whose name starts with - (e.g., -='cd -'), Claude Code's shell snapshot generator produces an invalid alias definition. Bash's alias -p already outputs such aliases with the -- end-of-options marker:
alias -- -='cd -'
The snapshot generator adds another alias -- prefix, resulting in:
alias -- -- -='cd -'
When this snapshot is sourced before running a command, bash throws:
/Users/.../.claude/shell-snapshots/snapshot-bash-....sh: line 326: alias: --: not found
This error message appears in the output of every shell command executed through the snapshot (e.g., commands run by skills like speckit).
What Should Happen?
The snapshot generator should use the output of alias -p verbatim, or check whether -- is already present before adding it as a prefix. The alias should be restored without errors.
Error Messages/Logs
/Users/md/.claude/shell-snapshots/snapshot-bash-1774621387268-ytt60w.sh: line 326: alias: --: not found
Relevant line in snapshot file:
alias -- -- -='cd -'
Steps to Reproduce
- Add the following alias to your shell config (
~/.zshrcor~/.bashrc):
alias -- -='cd -'
- Start a new shell session and verify the alias is active:
alias -p | grep "^alias -- -=" - Start Claude Code
- Run any command through a Claude Code skill that uses a shell snapshot (e.g., a speckit command like
node_modules/.bin/tsc --noEmit) - Observe the error
alias: --: not foundin the command output
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Root cause: alias -p in bash outputs aliases starting with - using the -- end-of-options marker as required. The snapshot generator does not account for this and adds an additional -- prefix, which causes bash to interpret -- as the alias name — which is invalid.
The error is cosmetic (no early script termination since set -e is not active in the snapshot), but it pollutes the stdout/stderr output of every command run through the snapshot, making it harder to read tool output.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗