Claude Sonnet 4.6: ignored Darwin platform context, emitted GNU grep flag
Summary
- Claude generated
grep -oP(GNU Perl flag) on macOS despite session context explicitly showingPlatform: darwin/OS Version: Darwin 25.5.0 - When correcting the rules files it updated, Claude skipped the canonical file its own project instructions named as the source of truth — caught twice by user
- Original task was never completed; session ended without delivering the goal
Reproduction
Model: Claude Sonnet 4.6
Interface: Claude Code CLI
Date: 2026-07-14
Platform: macOS Darwin 25.5.0 (Apple Silicon)
Steps
- Open Claude Code on macOS
- Ask Claude to write a bash script to extract href links from a URL
- Observe Claude emit
grep -oPwithout checking session platform context
Expected
- Claude reads
Platform: darwinfrom session context - Claude emits BSD-compatible
grep -Einstead of GNUgrep -P
Actual
- Claude emitted
grep -oP, which fails on macOS withinvalid option P - Required user correction to fix
Impact
| | Exchanges | Est. Tokens |
|---|---|---|
| Productive work | 7 | ~4,500 |
| Remediation | 11 | ~11,000 |
~11,000 tokens spent on a self-inflicted error. The original task (scraping href links from a web page) was never completed. User had to context-switch three times to catch cascading failures, then file a formal violation report.
Details
Session context injected at start:
Platform: darwin
OS Version: Darwin 25.5.0
Shell: zsh
Claude generated:
curl -s 'https://...' | grep -oP 'href="[^"]*"' | sort -u
macOS BSD grep has no -P flag. Error: invalid option P.
Second failure: when adding a platform-awareness rule to config files, Claude updated ~/.claude/rules/general.md first. The global CLAUDE.md explicitly states: "RULES — READ THESE at ~/.agents/rules/general.md — non-negotiable." Claude updated the wrong file and required two corrections before reaching the canonical file.
What Would Help
- Pre-tool-call behavioral check: before emitting any Bash command, read
Platformfrom session context and apply platform-appropriate syntax - On Darwin → BSD flags by default, no exceptions, no relying on training memory
- Session context is always present — this requires no inference
Environment
- macOS Darwin 25.5.0
- Shell: zsh
- Claude Code CLI