The "Can I Even Show This Code to an AI?" Problem
You want AI to review your code before it ships. But your company's security policy won't let you send source code to cloud APIs — or maybe you're freelancing and the client's NDA explicitly forbids it. Either way, the code stays on your machine.
The fix is straightforward: run Google's open-source Gemma 4 locally and wire it into Antigravity's editor. Zero network calls, zero data leaving your laptop. I started using this setup for client projects a few months ago, and the biggest win wasn't even the privacy — it was eliminating the "is it okay to send this?" conversation entirely. Setup takes under 30 minutes.
Getting Gemma 4 Running Locally with Ollama
Ollama handles model downloads and inference server management in a single tool. It's the fastest path to a working local LLM.
# Install Ollama (macOS)
curl -fsSL https://ollama.com/install.sh | sh
# Download the Gemma 4 12B model
# Recommended: 16GB+ RAM for smooth inference
ollama pull gemma4:12b
# Verify the model works
ollama run gemma4:12b "Hello, respond with OK if you can hear me."
# Expected output: OK (or a similarly brief acknowledgment)For hardware requirements, the 12B parameter model needs roughly 8GB of VRAM or 16GB of system RAM. On Apple Silicon (M1 and later), Metal GPU acceleration kicks in automatically, so inference speed is practical for interactive use.
If GPU memory is tight, quantized versions work well for code review tasks.
# 4-bit quantized version (runs on 8GB RAM machines)
ollama pull gemma4:12b-q4_K_M
# Benchmark response time
time ollama run gemma4:12b-q4_K_M "Explain what a mutex does in one sentence."
# Expected output: A mutex (mutual exclusion) is a synchronization primitive...
# Typical latency: ~2-3 seconds on Apple M2The accuracy trade-off from quantization is negligible for code review. Tasks like catching typos in variable names, spotting logic contradictions, and flagging unsafe patterns are essentially pattern matching — the quantized 12B model handles them well.
Connecting Antigravity to Your Local Model
With Ollama running, configure Antigravity to use it as a custom model provider.
// Add to .antigravity/settings.json
{
"ai.providers": {
"ollama-local": {
"type": "openai-compatible",
"baseUrl": "http://localhost:11434/v1",
"models": [
{
"id": "gemma4:12b",
"displayName": "Gemma 4 12B (Local)"
}
]
}
}
}After saving, "Gemma 4 12B (Local)" appears in Antigravity's model selector. The key detail is that baseUrl points to localhost — all communication stays within your machine.
To verify the connection, open Antigravity's inline chat (Cmd+I), switch to the Gemma 4 Local model, and ask a simple question. If you get a response, you're good to go.
Setting Up a Code Review Prompt
Local LLMs have less contextual reasoning power than large cloud models. You compensate by giving them very specific instructions. Here's a review-focused system prompt that works well with the 12B model.
<\!-- .antigravity/prompts/code-review.md -->
# Code Review Agent
You are a senior software engineer. Review code for the following issues, in priority order:
## Review Criteria (Priority Order)
1. **Security**: SQL injection, XSS, authentication bypass, secrets exposure
2. **Bugs**: Null references, off-by-one errors, race conditions
3. **Performance**: N+1 queries, unnecessary re-renders, memory leaks
4. **Readability**: Naming consistency, overly complex conditionals
## Output Format
- Classify severity as [CRITICAL] / [WARNING] / [INFO]
- Include the specific line number
- Provide a concrete fix as code
- If no issues found, respond with "LGTM" only
## Constraints
- Respect the existing code style (don't flag style preferences)
- Only flag issues you're confident about (no speculation)Save this prompt and invoke it from Antigravity's command palette with @code-review. The 12B model follows structured instructions reliably, so specifying the output format tightly produces consistent, actionable results.
The Practical Workflow: Diff-Based Reviews
The most effective approach is reviewing git diffs rather than entire files. This focuses the local model's context window on what actually changed.
# Extract staged changes as a diff
git diff --staged > /tmp/review-target.diff
# Check the diff size (Gemma 4 12B context: 8K-128K tokens)
wc -l /tmp/review-target.diff
# Expected: 150 (a few hundred lines is fine)You can paste the diff into Antigravity's inline chat, or run the review directly from the terminal.
# Run review directly from terminal
cat /tmp/review-target.diff | ollama run gemma4:12b "
Review the following git diff.
Flag security issues, potential bugs, and performance problems.
Classify as [CRITICAL]/[WARNING]/[INFO].
If no issues, respond with LGTM.
$(cat /tmp/review-target.diff)
"In my experience reviewing TypeScript code, the Gemma 4 12B model showed these detection rates:
- Type mismatches: High accuracy (catches
string | undefinedtreated asstring) - Unhandled Promises: Reliably detects missing
awaitkeywords - SQL injection: Flags template literal SQL construction with high consistency
- Business logic errors: Misses these when domain knowledge is required
Compared to cloud models like Gemini 2.5 Pro, the local 12B model falls short on understanding business context. But for mechanical pattern detection — type errors, resource leaks, security holes — it's surprisingly capable.
Hybrid Strategy: When to Use Local vs. Cloud
Going fully local is the ideal, but some tasks genuinely benefit from larger cloud models. I use a sensitivity-based split.
Use local Gemma 4 for:
- Client business code, anything near API keys or secrets
- Internal authentication and payment logic
- Anything under NDA
- Offline environments (flights, secure facilities)
Use cloud Gemini for:
- Open-source projects (the code is public anyway)
- Architecture-level reviews requiring large context windows
- Your own personal projects with low sensitivity
Antigravity's model switching is a single click, so there's zero friction in this workflow. You open the file, pick the model, and start the review.
Troubleshooting Common Issues
Ollama Not Responding
# Check if Ollama is running
ps aux | grep ollama
# Expected: ollama serve process should be active
# Check if the port is in use
lsof -i :11434
# No output means Ollama isn't running
# Restart it
ollama serve &Extremely Slow Responses
If the 12B model takes more than 1 second per token, GPU acceleration likely isn't active.
# macOS: Check Metal GPU usage
# Open Activity Monitor > GPU tab > look for ollama's GPU usage
# Linux: Verify NVIDIA driver
nvidia-smi
# Confirm a CUDA-capable GPU is detected
# Fallback: switch to a lighter model
ollama pull gemma4:4bAntigravity Refuses to Connect
Check settings.json for typos in baseUrl. The most common mistake is using https instead of http. Local Ollama runs on plain HTTP, so https://localhost:11434 will fail silently.
Automating Reviews with a Git Pre-Commit Hook
If manual reviews feel like friction, automate the safety net with a pre-commit hook.
#\!/bin/bash
# .git/hooks/pre-commit
# Run Gemma 4 local review before every commit
DIFF=$(git diff --cached --diff-filter=ACMR)
if [ -z "$DIFF" ]; then
exit 0
fi
echo "🔍 Running Gemma 4 local review..."
REVIEW=$(echo "$DIFF" | ollama run gemma4:12b "
Check this diff for security issues or CRITICAL bugs only.
If none found, respond with LGTM.
$DIFF
")
if echo "$REVIEW" | grep -q "CRITICAL"; then
echo "❌ CRITICAL issue detected:"
echo "$REVIEW"
echo ""
echo "Commit blocked. Fix the issue and try again."
exit 1
fi
echo "✅ $REVIEW"
exit 0This hook runs on every git commit, and Gemma 4 scans the diff for critical issues. If it finds one, the commit is blocked. Reviews typically complete in a few seconds, so it doesn't disrupt your flow.
A word of caution: don't expect a pre-commit hook to catch everything. Treat it as a safety net for obvious security holes and bugs. For thorough reviews, use Antigravity's inline chat where you can have a back-and-forth conversation with the model about specific concerns.
What to Do Next
Get this setup running and use it for a week alongside your normal workflow. You'll notice an unexpected side benefit beyond privacy: your productivity doesn't drop when you're offline. For deeper model customization options, check the Gemma 4 and Antigravity integration guide. If you hit issues with the basic local LLM setup, the Antigravity local LLM configuration guide covers the fundamentals.