claude-code-ultimate-guide/examples/scripts/sonnetplan.sh
Florian BRUNIAUX 01283fafec docs: SonnetPlan hack — budget Sonnet+Haiku hybrid via env var remap
- guide/ultimate-guide.md §OpusPlan: new "Budget Variant: SonnetPlan"
  section with shell function, Plan/Act routing table, caveat on
  unreliable model self-report, link to GitHub issue #9749
- examples/scripts/sonnetplan.sh: new ready-to-use shell function
  with installation instructions and verification guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 17:58:25 +01:00

32 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# sonnetplan — Budget hybrid mode: Sonnet 4.6 (plan) + Haiku 4.5 (act)
#
# How it works:
# Claude Code's `opusplan` alias routes to Opus (plan) + Sonnet (act).
# By remapping the environment variables that resolve the `opus` and `sonnet`
# aliases, we effectively create a cheaper Sonnet→Haiku hybrid.
#
# Usage:
# sonnetplan # Start Claude in current directory
# sonnetplan --project /path # Start in specific project
#
# Installation:
# Add this function to your ~/.zshrc or ~/.bashrc:
#
# source /path/to/sonnetplan.sh
#
# Or copy the function body directly into your shell config.
#
# Verification:
# After running `sonnetplan` and typing `/model opusplan`, check the
# status bar — it should show "Model: Sonnet 4.6" in plan mode.
# Do NOT rely on asking the model "what model are you?" — that self-report
# is unreliable. Use the status bar or your billing dashboard instead.
#
# GitHub issue tracking native support: https://github.com/anthropics/claude-code/issues/9749
sonnetplan() {
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-sonnet-4-6 \
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-haiku-4-5-20251001 \
claude "$@"
}