Feature: Auto-select model and effort level based on task complexity

Status Open
Maintainer reply None cached
Activity 6 comments · opened Apr 4, 2026

Problem

Currently, users must manually switch model (/model) and effort level (/effort) depending on task complexity. This creates friction — either you default to a powerful model and waste tokens on simple questions, or default to a lighter model and manually switch for complex tasks.

Proposed Solution

Allow Claude Code to automatically select (or interactively prompt the user to select) the appropriate model and effort level based on the complexity of the user's input.

Possible approaches:

  1. Auto-select: Use a lightweight classifier (e.g., Haiku) to evaluate the user's prompt and automatically set the model/effort before the main model processes it.
  1. Interactive prompt: Before each task, briefly prompt the user with a recommended model/effort choice based on the input, allowing them to confirm or override.
  1. Programmatic API: Expose model/effort switching via hooks or settings so that UserPromptSubmit hooks can dynamically adjust them. For example:

``json
{
"hooks": {
"UserPromptSubmit": [{
"type": "command",
"command": "classify-and-set-model.sh"
}]
}
}
``

Use Case

  • Simple Q&A, formatting, renaming → Sonnet + low effort
  • Daily feature development, bug fixes → Sonnet + medium effort
  • Architecture design, complex refactoring → Opus + high effort

Users shouldn't need to remember to switch manually — the tool should help optimize token consumption automatically.

Context

In a Go project with extensive documentation (4,827 lines of standards), session history analysis shows that model selection is one of the highest-leverage optimizations for token cost (20-40% savings). Currently there's no way to automate this via hooks or any other mechanism.

View original on GitHub ↗

5 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/39282
  2. https://github.com/anthropics/claude-code/issues/27665
  3. https://github.com/anthropics/claude-code/issues/34874

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

jmylot · 4 months ago

Cowork Scheduled Tasks Use Case

Thanks for this detailed feature request. I'd like to add a complementary use case specific to Cowork scheduled tasks:

Problem

Cowork scheduled tasks that perform lightweight, repetitive monitoring/polling operations (e.g., GitHub issue monitoring, health checks, log analysis) currently consume the same tokens as complex reasoning tasks, since all tasks default to the main model (Sonnet/Opus).

Example: A GitHub issue monitor that runs every 4-6 hours does mostly API polling and simple classification:

  • Fetch 50–100 issues via GitHub API (lightweight)
  • Classify new comments by author type (bot, staff, user) (lightweight)
  • Post auto-replies for common patterns (boilerplate)

This workload doesn't need Sonnet—Haiku would be sufficient and dramatically reduce cost.

Proposed Extension

Add per-task model configuration to create_scheduled_task / update_scheduled_task MCP tools:

create_scheduled_task(
    taskId="github-issue-monitor",
    prompt="...",
    cronExpression="0 9 * * *",
    model="haiku"  # NEW: Allow explicit model override per task
)

Or as a simpler alternative, expose model selection via task-level settings that can be read from a config file or environment variable.

Benefits

  • Cost optimization: Lightweight monitoring tasks run on Haiku (≈10% token cost vs. Sonnet)
  • No degradation: Haiku's classification/pattern-matching is more than adequate for polling workflows
  • User choice: Power users can optimize without affecting other tasks

This would complement your "auto-select" approach by allowing explicit per-task control for known lightweight workloads.

akshat4165 · 2 months ago

there's no way to automate this via hooks" — I tested exactly this and can confirm it empirically. A UserPromptSubmit hook that rewrites .claude/settings.json does not change the running session's model: the model is fixed for the lifetime of a session. The rewrite only takes effect on the next session start. So a live per-prompt classifier for the main thread isn't reachable from hooks today (which also matches why mid-session switching would be undesirable anyway — it invalidates the prompt cache).

What is reachable without that: route at the seams Claude Code already has — per-subagent model (you can pass it per invocation) and the per-project model in settings.json. I built a small plugin around that idea (calibrate): instead of classifying every prompt, it analyzes the repo once and writes a per-project policy (which tier plans / codes / reviews / explores, with escalation rules for risky paths), then routes phase subagents through it. On one verified run it cut cost 46.8% vs all-Opus — modest sample, but the routing is confirmed against the session logs, not self-reported.

Sharing mostly for the hooks finding, since it comes up whenever someone tries to build the per-prompt version. Happy to compare notes if anyone's going down this path.

sam-moreton · 1 month ago

+1 for this. We need a way for Claude Code to handle the switching of models based on task difficulty and intent.

jeevan-smartltd · 1 month ago

yes this will help huge token saving

Showing cached comments. Read the full discussion on GitHub ↗