Skip to content

AI Best Practices

# Bad
"Fix this code"
# Good
"This React component re-renders too often.
How can I optimize it using useMemo and useCallback?"
# Bad
"How do I handle errors?"
# Good
"In this Express.js API endpoint, how should I handle
database connection errors and return appropriate HTTP status codes?"
1. "What's the best way to implement caching?"
2. "For a Node.js API with Redis, what strategies work best?"
3. "Show me cache invalidation for user data updates"
Terminal window
<leader>ar # Before committing
# Address suggestions before commit
Terminal window
<leader>ar # AI security review
# Check for:
# - Input validation
# - SQL injection prevention
# - Authentication checks
# Bad: Paste actual API keys
# Good: Use placeholders like "API_KEY"
Terminal window
# Check API keys
echo $GEMINI_API_KEY
# Test connectivity
curl -I https://generativelanguage.googleapis.com
  • Reduce request frequency
  • Use different AI tools alternately
  • Consider upgrading API plans
  • Be more specific in prompts
  • Reduce context size
  • Use shorter code snippets
Terminal window
<leader>ac # Quick AI chat
<leader>aa # AI actions menu
<leader>ar # Code review
<leader>af # Quick fixes
  • Supermaven: Real-time coding
  • CodeCompanion: Complex problems
  • Database AI: SQL queries
Terminal window
"Why did you suggest this approach?"
"What are the trade-offs?"
"Are there alternative approaches?"
  1. Morning: Plan features with AI
  2. Coding: Use completion tools
  3. Review: AI code review
  4. Evening: Document with AI help