Claude Sonnet 4.6: ignored Darwin platform context, emitted GNU grep flag

Open 💬 0 comments Opened Jul 14, 2026 by thecatfix

Summary

  • Claude generated grep -oP (GNU Perl flag) on macOS despite session context explicitly showing Platform: 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

  1. Open Claude Code on macOS
  2. Ask Claude to write a bash script to extract href links from a URL
  3. Observe Claude emit grep -oP without checking session platform context

Expected

  • Claude reads Platform: darwin from session context
  • Claude emits BSD-compatible grep -E instead of GNU grep -P

Actual

  • Claude emitted grep -oP, which fails on macOS with invalid 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 Platform from 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

View original on GitHub ↗