Then drop in your error message or code snippet. You can ask things like, “Why is this throwing a TypeError?” or “Can you fix the bug in this code block?” The AI can walk you through the issue and provide corrected code or suggestions.
2. Use Fix, Explain, or Related Commands via IDE
If you're using an IDE—or even a supported editor—Amazon Q offers quick actions like:
Explain — have it describe what the code does
Fix — ask it to debug the selected code
Refactor, Optimize, or Generate Tests also available You highlight the code, right-click, and choose the action. Q then provides suggestions or fixes you can insert.
3. Provide Context with @workspace and Clear Prompts
When working in chat mode, include helpful context:
Use @workspace to allow Q to view more of your project
Share the error, describe what you were doing, and open the related file to focus suggestions Tips like:
“Tell me how to fix – {error summary}”
“The code generates this error – {error summary}”
…help Q give targeted assistance.
4. Use the Enhanced CLI Agent for Automated Debugging
Amazon Q’s newer CLI agent (powered by Claude 3.7 Sonnet via Bedrock) can do more than just chat:
It reads and writes files in your local environment
It can execute commands, apply fixes, and iterate in multi-turn conversations
You get dynamic, back-and-forth debugging help direct in your terminal—no guesswork or manual copy-pasting needed.
Sample Workflow — Debugging in the Terminal
Open a chat session:
q chat
Provide context:
I’m getting a null pointer exception in file `main.py` when calling `load_data()`.
Here's the code around that function… (paste or reference it)
Ask for help:
Why is this error happening? Can you fix the bug and show me corrected code?
Review Q's suggestions:
Q might point out missing null checks, incorrect variable names, or reveal assumptions.
It will generate updated code blocks you can copy and run.
Iterate with follow-up questions:
That fixed the null pointer, but now I get a file not found error. Thoughts?
Use the agent’s file operations (if enabled):
Let Q open, edit, and save files directly (if allowed and you’ve set permissions).
Use @workspace for broader context if deeper project insight is needed.