Access Claude Sonnet 4 in Amazon Q Developer CLI

Wait 5 sec.

Amazon Q Developer now supports Claude Sonnet 4 within the CLI, bringing advanced coding and reasoning capabilities to your development workflows at no additional cost. This latest model excels in coding with a state-of-the-art 72.7% for agentic coding on the SWE-bench (see Claude 4 announcement for more information). With enhanced coding and reasoning capabilities, it helps you analyze complex code, optimize everyday development tasks, implementing bug fixes, running bash commands, and developing new features with immediate feedback loops and more precise responses. To help you leverage Claude Sonnet 4, Amazon Q Developer lets you easily select specific Claude Sonnet models, giving you increased flexibility the CLI. Claude Sonnet 4: High-performance model with balanced intelligence Claude Sonnet 3.7: High-performance model with extended thinking capability Claude Sonnet 3.5: High-performance intelligent model For detailed information about Claude model capabilities and comparison, refer to the Anthropic models overview. In this blog, I will show you how to select Claude Sonnet 4 as your model within the Q Developer CLI and then walk you through a quick demo. How to Choose Claude Sonnet 4 Make sure to update to the latest version (v1.11.0 onwards) of Amazon Q Developer CLI. Refer installing Amazon Q for command line for installation instructions. You can access Claude Sonnet 4 through these options: During an active chat, use the /model command and select claude-4-sonnet Start a new chat with q chat --model claude-4-sonnet Set it as your default model using q settings chat.defaultModel claude-4-sonnet. The supported model names for the --model parameter and settings are: claude-3.5-sonnet claude-3.7-sonnet (default) claude-4-sonnet Model Selection Priority Order Q Developer CLI selects models in the following order: Current session model selections (via /model or --model) User-configured preferences in settings System default (Claude 3.7 Sonnet) Key Behaviors The Q Developer CLI agent defaults to Claude 3.7 Sonnet when no specific model is selected. During active chat sessions, you can seamlessly switch between models using the /model command. Chat continuity is maintained across sessions, with the system retaining the previously selected model when conversations are resumed. If you prefer Claude Sonnet 4, setting it as the default model in user settings will automatically apply to all new chat sessions, though this can be overridden with specific model selections as needed. Figure 1: Q Developer CLI showing the model loaded for the session Claude Sonnet 4 with Q Developer CLI in Action After switching to Claude Sonnet 4 in Q Developer CLI, let’s explore its capabilities with a practical coding example. Here’s the prompt I’ll use for this demonstration: Create a Python command-line to-do list app with these features:- Add tasks with descriptions and priorities (low/medium/high)- Mark tasks as complete by index- Display tasks sorted by priority, then insertion order- Show completion status ([x] done, [ ] pending)- Handle errors for empty tasks and invalid indices- Store tasks in memory onlyPlease provide the code to implement this application. Figure 2: Q Developer CLI interface showing Claude Sonnet 4 in action In the above demonstration, Q Developer CLI with Claude Sonnet 4 went beyond what was asked in the provided requirements in the prompt by implementing sophisticated command parsing with quoted descriptions, comprehensive error handling, and clean object-oriented design enhanced by type hints. The interface features a helpful guidance system with clear error messages, elegant enum-based priority management, and formatted output for clear task representation. Additionally, Q Developer CLI with Claude Sonnet 4 also generated documentation in the README for the to-do application, including practical error handling examples and clear usage instructions – transforming the prompt requirements into a well-structured, user-friendly application. Conclusion The availability of Claude Sonnet 4 represents a significant advancement in Amazon Q Developer’s capabilities. From intricate code refactoring to streamlined documentation creation, Claude Sonnet 4 helps you accomplish both complex and routine development tasks efficiently. Whether selecting Claude Sonnet 4 for complex tasks or using other models for specific needs, Amazon Q Developer adapts to your preferences, optimizing AI assistance while maintaining efficiency in your workflow. The latest version(v1.11.0) of Amazon Q Developer awaits in the CLI, ready to support your development journey with enhanced model capabilities and selection options. Refer Installing Amazon Q for Command line for installation instructions. To learn more about Amazon Q Developer’s features and pricing details, visit the Amazon Q Developer product page. About the Author Kirankumar Chandrashekar is a Generative AI Specialist Solutions Architect at AWS, focusing on Amazon Q Developer. Bringing deep expertise in AWS cloud services, DevOps, modernization, and infrastructure as code, he helps customers enhance their development workflows using Amazon Q Developer. Kirankumar is passionate about solving complex customer challenges and enjoys music, cooking, and traveling.