AI · · 5 min read
How I Use Gemini for Code Reviews Without Losing Control
I share my simple, honest method for using Gemini to review Python code in VS Code, focusing on specific prompts and keeping the final decisions in my hands.
When I started building my Python chatbots, I quickly realized that writing code is only half the battle. The other half is making sure it actually works the way I intended. Living in Pundri, I don't have a team of senior developers to check my work or a formal code review process. So, I started using AI tools like Gemini in a very specific way: as a reviewer, not a writer. I began using Gemini for code reviews in my daily workflow, and it has genuinely changed how reliable my projects are. It’s not about letting the AI write everything; it’s about asking it to look for the holes I missed.
The Problem with Letting AI Write Everything
In the beginning, I used to paste context to Gemini and ask it to generate full scripts. It was exciting, but soon I found bugs in loops and logic errors in data handling. The AI would produce code that looked perfect on the surface but failed when I fed it real data from Supabase. I learned that if I don't understand every line, I can't debug it when it breaks. I still use AI to speed things up, but I never let it obscure my understanding. If I can't explain a function to myself, I don't ship it. This mindset helped me when I built JARVIS, my own AI assistant, where I had to manually trace the voice-to-text flow to ensure it handled Indian accents correctly without dropping frames.
My Simple Prompting Strategy for Reviews
I stopped asking Gemini to 'write better code.' Instead, I started asking it specific questions about the code I had already written. I open VS Code, select a function, and send it to the assistant with a clear instruction. The key is specificity. Vague prompts get vague answers. I want to know what can break, not just if it works. Here is the basic structure I use, which has saved me hours of debugging late at night.
- Provide the exact context: Tell it what the function is supposed to do in one sentence.
- Ask for risk assessment: Ask it to identify potential edge cases or logic errors.
- Request simple explanations: If it suggests a fix, ask it to explain why the previous version was wrong.
- Keep it local: I only share the relevant snippet, not my entire database schema or API keys.
Prompt Example:
"Here is my Python function `process_message` that sends data to Supabase.
It's failing occasionally when the message is null.
1. What are three likely reasons for this error?
2. Suggest a minimal fix that keeps my existing logic.
3. Explain the fix in simple terms."
This approach keeps me in the driver's seat. I am the one deciding if the fix makes sense. I recently applied this when adding sentiment analysis to my chatbot. I had a loop that was processing text, but it didn't handle empty strings well. Instead of rewriting the whole module, I asked Gemini to spot the null check issue. It pointed out that I was calling a method on None. I added a simple if statement, and the bug disappeared. It feels less like magic and more like having a patient friend who never gets annoyed when you ask the same question twice.
Staying Honest About the Limitations
I have to be honest: Gemini gets it wrong sometimes. It might suggest a library I haven't installed or a syntax that isn't valid for my Python version. I never copy-paste a suggestion without testing it first. Code review is a collaboration, not a command. If the suggested fix seems too complex, I usually reject it and look for a simpler way. I remember when I was setting up my vector search with Supabase, the AI suggested a complex index structure that slowed down my queries. I ignored it because I knew my dataset was small. Simplicity often wins over cleverness in small-town development where we don't have massive servers to burn through.
How I Keep My Code Base Clean
Using Gemini for reviews also helps me write cleaner code from the start. I know that I will be asking the AI to scrutinize my work, so I try to keep my variables named clearly and functions short. If my code is messy, the AI's feedback is also messy. I treat my code like I'm writing a letter to a friend; I want it to be easy to read. This discipline came from learning to code with just a laptop, where I had no one to correct my habits. Now, I have a tool that helps me maintain standards, even when I'm working alone in my room in Kaithal. It’s a humble way to grow, but it works.
If you are starting out, don't be afraid to use AI to check your work. It’s not cheating; it’s using modern tools. But remember, the AI doesn't know your user's intent. It doesn't know that your app is for farmers in Haryana who might not have stable internet. It only knows the code. You know the context. That is your edge. Keep the human in the loop, ask specific questions, and always test the result. If you want to see how I structure my projects, you can look at my other projects to see how these tools fit together in real apps. This method has made me a more confident builder, even without a team.
Frequently asked questions
Does using AI for code reviews mean I can stop learning?
No, it actually helps you learn faster. When the AI points out a bug, you have to understand why it was a bug to fix it properly. It acts as an instant feedback loop, which is much faster than waiting for a mentor or a crash. You still need to understand the logic to verify the AI's suggestions.
What is the best prompt to use for code review?
The best prompts are specific and ask for risks rather than just fixes. For example, ask 'What are the potential edge cases in this function?' or 'Why might this fail if the input is null?' Avoid vague prompts like 'improve this code,' as they often lead to unnecessary changes.
Can I trust the code suggestions from Gemini?
You should treat them as suggestions, not commands. Always test the code in your local environment before deploying. AI models can hallucinate library names or syntax, so you must verify that the suggested code runs correctly with your specific setup and dependencies.
Is this method suitable for beginners?
Yes, it is very suitable for beginners. It helps you catch common mistakes early and teaches you how to think about edge cases. However, beginners should be careful not to copy-paste without understanding, as this can lead to confusion later when debugging complex issues.