Free course › Module 1
Lesson 6 of 10 · 5 min
Challenging Your LLM and Improving Solutions
Continuing from our previous section on good prompts, let's talk about an essential strategy for getting the absolute best out of your AI assistant: actively challenging the solutions and ideas it provides.
Just like working with a human developer, your AI assistant's suggestions might initially seem great, but without deeper scrutiny and proactive questioning, they might miss important considerations. Encouraging your AI to critically evaluate both your ideas and its own proposals can uncover significant potential issues and lead to stronger, more robust solutions.
One common pitfall users face is getting trapped in a cycle of trying changes, finding they don't work, and either rolling them back, or leaving the code there but without gaining ground. This is common when you're trying to implement some major changes. Or diganosing some security errors in the logs. First off, just take a deep breath.
Now, prompt the AI clearly: "I've tried these changes, and they're not working. Let’s stop and reassess. Can you help me figure out why these solutions haven't worked? Please suggest additional options and give me your confidence level in them." Encouraging the AI to stop and take stock helps break frustrating cycles and usually reveals deeper problems or simpler solutions.
When you do fix your issue, you might introduce a new one, so in light of that it's crucial to remember that your AI assistant, while incredibly powerful, isn't flawless. AI can forget previous context, make assumptions, or occasionally introduce mistakes. It may sometimes remove essential code when editing or accidentally introduce bugs. So don't blindly accept every suggestion. Read the diff, and test each change, especially big ones, to make sure nothing else broke. Before you commit, get a review: in Claude Code, /code-review checks your changes and labels each finding Important, Pre-existing or Nit. In Codex, ask it to review the changes, or ask the other tool for a second opinion. If something does go wrong, clearly communicate this back to your AI assistant, offering precise feedback so it learns to improve its next suggestions.
Here's another example: Imagine you're building a user-authentication flow. The AI suggests altering your authentication logic. Don't immediately assume it's perfect. Carefully test all scenarios: user registration, login, session management, error handling, and security checks. If anything fails, document the issue and explain precisely back to the AI: "Your last edit caused new registrations to fail with this error message. Here's the detailed log output and related code. Can we carefully revisit and fix this?" This method ensures accuracy and reliability in your final product.
An example from one of my previous apps.
In a different app I built, I have a user dashboard. In this app you submit a link to a social media video and the app processes it for information. This processing with AI takes about 30-40 seconds. Your AI assistant suggests implementing a "polling" system, where the dashboard repeatedly checks (every few seconds) to show if the data is ready and changes an icon from processing > completed. At first glance, this seems perfectly reasonable, especially during testing or development.
But here's where challenging your AI assistant becomes crucial. What happens when your app moves from testing to production, with potentially thousands (or even tens of thousands) of users simultaneously using this feature? While polling might work smoothly during your testing phase, it can create enormous performance bottlenecks and scalability issues in a real-world environment. Frequent polling requests from thousands of concurrent users could overload your server, degrade performance, and negatively impact the user experience.
In this scenario, it's essential to prompt the AI to recognize your application's scale requirements explicitly. You might say something like, "Polling is great in a small test environment, but what about when we scale this to 10,000 simultaneous users? Could this approach cause performance issues, and what alternatives could better support this level of usage?" This kind of proactive questioning pushes your AI assistant to consider scalability concerns, prompting it to offer alternative solutions, such as WebSockets or server-sent events (SSE), both of which can provide real-time updates more efficiently at scale. I wasn't aware about WebSockets at the time, but it turned out to be a great suggestion to handle the volume.
Think about your mobile users
Another critical area to challenge is User Interface (UI) and User Experience (UX) design. Suppose the AI assistant suggests changes or additions to the desktop layout of your app. It’s important not to automatically assume these changes translate seamlessly to mobile devices. The AI might not automatically think about the mobile view unless explicitly instructed. Therefore, proactively ask, "How does this design change impact the mobile view? Can you ensure that this solution maintains usability and visual consistency across desktop and mobile devices?" This ensures your AI takes a more holistic and responsive approach to UI/UX design, helping you maintain a high-quality experience across all devices.
You can test this yourself, but you only own one phone.
Encouraging your AI assistant to critique its own proposals is equally valuable. You could instruct it: "Here’s my idea. Can you identify any potential problems or unintended consequences I might not have considered?" or "You've proposed this approach; what are some potential weaknesses or scalability concerns with your solution?" Asking for this kind of analysis uncovers hidden issues early and builds good habits.
Challenging your LLM pushes it beyond surface-level answers toward sturdier solutions, and it sharpens your own thinking too.
Best Practices for Effectively Challenging Your LLM:
-
Explicitly State Scale and Performance Goals:
Clearly mention your production goals, such as user capacity or performance requirements, to prevent short-sighted solutions. -
Ask for Critical Feedback:
Regularly prompt your LLM to evaluate and critique your ideas and its own solutions to catch potential issues early. -
Encourage Alternative Solutions:
When the AI suggests a solution, actively request other methods, particularly for scalability and performance considerations. -
Maintain a Mobile-first Perspective:
Ensure your LLM is reminded to consider responsive design, explicitly prompting it to evaluate desktop solutions against mobile compatibility. -
Clarify Long-term vs. Short-term Solutions:
Clearly distinguish between testing solutions and production-ready solutions, prompting your AI to recognize and address long-term requirements.
Questions to consider:
- Have you encountered scenarios where AI-generated solutions worked well in testing but failed in real-world conditions? How could clearer prompts have prevented this?
- Do you regularly challenge the AI to justify its recommendations, particularly around scalability, security, or compatibility issues?
- How can you consistently prompt the AI to think holistically about both desktop and mobile user experiences when developing UI solutions?