diff --git a/src/content/docs/guides/agent-workflows/how-to-review-prs-like-a-senior-dev.mdx b/src/content/docs/guides/agent-workflows/how-to-review-prs-like-a-senior-dev.mdx index 6fdd4d6bb..f6c119b73 100644 --- a/src/content/docs/guides/agent-workflows/how-to-review-prs-like-a-senior-dev.mdx +++ b/src/content/docs/guides/agent-workflows/how-to-review-prs-like-a-senior-dev.mdx @@ -11,92 +11,165 @@ tags: --- import VideoEmbed from '@components/VideoEmbed.astro'; -import { Steps } from '@astrojs/starlight/components'; -Learn how to prompt Warp’s AI to review pull requests like an experienced engineer — focusing on structure, red flags, and clarity. +AI can summarize a pull request in seconds — but a summary isn't a review. This guide shows you how to prompt Warp's agent to produce structured, prioritized feedback that mirrors how a senior engineer would approach a large PR: start with risk, surface blockers, and give a clear merge recommendation. Plan on about 10 minutes to complete. +## Prerequisites + +- A **Git-tracked project** with a branch or open PR to review +- The [GitHub CLI](https://cli.github.com) (`gh`) if you want to pull diffs directly from GitHub + +## Why structured review matters + +Generic AI summaries describe what changed. Structured reviews tell you what to care about: + +- **Risk Assessment** flags blast radius before you've read a single line of code +- **Critical Issues** surface blockers first, so you don't spend time on style when there's a security hole +- **Merge confidence scoring** gives reviewers a shared signal for go/no-go decisions + +The prompt in this guide forces the agent to follow this structure, which produces output that's much faster to act on than a prose summary. The same workflow applies to large PRs, design docs, or any feature diff you need to triage quickly. + +## 1. Get the PR diff + +Before the agent can review the PR, it needs to see the changes. There are a few ways to get the diff into your Warp session: + +**Option A: GitHub CLI** + +If the PR is on GitHub, pull the diff directly: + +```bash +# View the diff as text +gh pr diff PR_NUMBER + +# Or open the PR in your browser for full context +gh pr view PR_NUMBER --web +``` + +**Option B: Git diff** + +If you have the branch checked out locally: + +```bash +git diff main... +``` + +**Option C: Warp Code Review panel** + +If you have the branch checked out, open Warp's Code Review panel with `⌘+Shift++` (macOS) or `Ctrl+Shift++` (Windows/Linux) to see a visual diff of all changes. You can select diff hunks and attach them as context to your agent prompt. + +## 2. Start an agent session and provide context + +Open a new agent session in Warp and navigate to your project directory: + +```bash +cd ~/your-project +``` + +Attach the diff as context so the agent can reason about the actual code. You have a few options: + +- **Select terminal output** — Run `gh pr diff PR_NUMBER` or `git diff`, then select the output block and attach it using the block action menu. +- **Reference specific files** — Use `@path/to/file` in your prompt to point the agent at changed files. +- **Paste inline** — For smaller diffs, paste the diff directly into the agent input. + +## 3. Use the structured review prompt + +Once the diff is attached as context, paste this prompt into Warp's agent input. The structure forces the agent to lead with risk, surface blockers with file-level precision, and end with a merge recommendation: + +``` +## Prompt: Structured PR Review Format + +Review this pull request and format your response for rapid scanning by a busy maintainer. Follow the structure below. + --- - +### 1. 🚨 Risk Assessment + +**Overall Risk:** 🔴 HIGH | 🟠 MEDIUM | 🟢 LOW +**Complexity:** [Simple | Moderate | Complex | Very Complex] +**Blast Radius:** [Isolated | Module-wide | System-wide | External APIs affected] +**Requires Immediate Review:** [YES / NO – why] + +--- -1. #### Intro +### 2. 🔍 Critical Issues +_If none, write "None found" and skip to the next section._ - This tutorial teaches you how to use Warp to make **pull-request reviews faster and smarter**.\ - Instead of relying on AI summaries, you’ll prompt Warp to generate an **index and priority list**, guiding your review order while flagging risky sections. +#### 1. [CRITICAL ISSUE TITLE] +**File:** `path/to/file.js:L125` +**Impact:** Data loss / Security hole / System crash +**Fix:** +// Quick code fix example here - Although this example focuses on large PRs, the same workflow applies to **code reviews**, **design docs**, or **feature diffs**. +--- -2. #### The problem +### 3. ⚠️ Concerns +_Should discuss or fix before merge. If none, write "None found."_ - Large PRs are difficult to parse.\ - AI summaries gloss over nuance and may miss subtle issues — you need structured, prioritized insight instead. +Examples: +- [PERFORMANCE] Unindexed query on large table +- [SECURITY] Missing input sanitization in login form -3. #### The prompt +--- - Use this in Warp’s AI input: +### 4. 🎯 Maintainer Decision Guide - ``` - ## Prompt: Structured PR Review Format +**Merge confidence:** [0–100]% +- □ Safe to merge after fixing blockers +- □ Needs architecture discussion first +- □ Requires performance testing +- □ Get security team review +- □ Author should split into smaller PRs - > Review this pull request and format your response for rapid scanning by a busy maintainer. Follow the structure below. +**Time to properly review:** ~[X] minutes +**Recommended reviewer expertise:** [Backend | Security | Database | Frontend] - --- +--- - ### 1. 🚨 Risk Assessment +### 5. 🧭 Formatting rules - **Overall Risk:** 🔴 HIGH | 🟠 MEDIUM | 🟢 LOW - **Complexity:** [Simple | Moderate | Complex | Very Complex] - **Blast Radius:** [Isolated | Module-wide | System-wide | External APIs affected] - **Requires Immediate Review:** [YES / NO – why] +- Use emoji headers for instant visual recognition +- Keep sections short; if empty, say "None found" +- Blockers get full detail, everything else stays concise +- Include code examples only for blockers +- Bold key impact/risk words +- Use consistent prefixes like [SECURITY], [PERFORMANCE], [LOGIC] for easy scanning +- If PR is genuinely fine, end with: ✅ "This PR is safe to merge as-is." +``` - --- +## 4. Understand the output - ### 2. 🔍 Critical Issues - _If none, write “None found” and skip to the next section._ +Here's what each section means and what to do with it: - #### 1. [CRITICAL ISSUE TITLE] - **File:** `path/to/file.js:L125` - **Impact:** Data loss / Security hole / System crash - **Fix:** - // Quick code fix example here +- **Risk Assessment** — Read this first. It tells you the PR's overall risk level, how complex the changes are, how many parts of the system they affect (blast radius), and whether it needs urgent review. If the blast radius is "System-wide" and you weren't expecting that, stop and discuss before going further. - --- +- **Critical Issues** — These are blockers. Each issue includes the specific file and line number, the type of impact (data loss, security hole, crash), and a suggested fix. Address all of these before merge. If the section says "None found," the PR cleared the most important bar. - ### 3. ⚠️ Concerns - _Should discuss or fix before merge. If none, write “None found.”_ +- **Concerns** — These are "should fix" items: performance risks, missing tests, design trade-offs. They don't block merge by default, but they should be tracked and discussed. - **Examples:** - - [PERFORMANCE] Unindexed query on large table - - [SECURITY] Missing input sanitization in login form +- **Maintainer Decision Guide** — The merge confidence score (0–100%) gives you and your team a shared signal. The checklist tells you what still needs to happen: architecture discussion, security review, performance testing, or splitting the PR. - --- +- **Formatting Rules** — This section is instructions to the agent, not output for you. Ignore it in the response. - ### 4. 🎯 Maintainer Decision Guide +## Tips for iterating - **Merge confidence:** [0–100]% - - □ Safe to merge after fixing blockers - - □ Needs architecture discussion first - - □ Requires performance testing - - □ Get security team review - - □ Author should split into smaller PRs +The initial output is a starting point. Use follow-up prompts to go deeper on anything that stands out: - **Time to properly review:** ~[X] minutes - **Recommended reviewer expertise:** [Backend | Security | Database | Frontend] +- **Focus on a specific file**: "Look more closely at `auth/middleware.js` — are there edge cases in the token expiration logic?" +- **Dig into a concern**: "Explain the performance risk you flagged. How significant is it at 10k requests per minute?" +- **Get a fix drafted**: "Write the fix for the input sanitization issue in the login form." +- **Check scope creep**: "Does this PR include changes unrelated to the stated goal? List anything that seems out of scope." +- **Split a large PR**: "Suggest how to split this PR into smaller, independently reviewable pieces." - --- +If the PR is large, break it into logical groups of files and run the prompt once per group. The output is easier to act on when you're reviewing one area of the codebase at a time. - ### 5. 🧭 Formatting Rules +## Next steps - - Use emoji headers for instant visual recognition - - Keep sections short; if empty, say “None found” - - Blockers get full detail, everything else stays concise - - Include code examples only for blockers - - Bold key impact/risk words - - Use consistent prefixes like [SECURITY], [PERFORMANCE], [LOGIC] for easy scanning - - If PR is genuinely fine, end with: ✅ “This PR is safe to merge as-is.” +You now have a structured, repeatable workflow for PR reviews that surfaces risk, blockers, and merge confidence fast. - ``` +Explore related guides and features: - +- [Review AI-generated code](/guides/agent-workflows/how-to-review-ai-generated-code/) — review and comment on code diffs directly in Warp's Code Review panel +- [Attach agent session context to GitHub PRs](/guides/agent-workflows/how-to-attach-agent-session-context-to-github-prs/) — embed the prompt, plan, and agent decisions into the PR for your reviewers +- [Code Review panel](/code/code-review/) — full reference for visual diffs and inline comments in Warp diff --git a/src/content/docs/guides/external-tools/how-to-set-up-ollama.mdx b/src/content/docs/guides/external-tools/how-to-set-up-ollama.mdx index b620bcf5e..a2f48bff7 100644 --- a/src/content/docs/guides/external-tools/how-to-set-up-ollama.mdx +++ b/src/content/docs/guides/external-tools/how-to-set-up-ollama.mdx @@ -11,76 +11,211 @@ tags: --- import VideoEmbed from '@components/VideoEmbed.astro'; -Running AI models locally just got easier — and faster — with Ollama.\ -\ -In this guide, we’ll walk through how to use Warp to install, profile, and integrate Ollama into your local setup. +Run AI models locally — with no API costs, no data leaving your machine, and your choice of model. This guide walks through installing Ollama, running your first model, integrating it into an existing app, and customizing model behavior using Warp. ---- +## Prerequisites -### 1. Check your system specs +**Hardware requirements** -Before running large language models (LLMs) locally, confirm your hardware can handle them. +You'll need enough memory to load the model weights. As a general estimate, plan on roughly 1GB of memory per billion parameters. -Example setups: +| Model size | Example models | Minimum RAM/VRAM | +|---|---|---| +| 3B | Llama 3.2 3B, Phi-3 Mini (3.8B) | 4GB | +| 7–8B | Mistral 7B, Llama 3.1 8B | 8GB | +| 13B | Llama 2 13B | 16GB | +| 22–34B | Codestral (22B), Mixtral (46.7B total) | 24GB | +| 70B | Llama 3.1 70B | 48GB | -* Mac: 64GB unified memory — good for larger models but with lower throughput. -* Windows (NVIDIA RTX 5090): 32GB VRAM — excellent performance, but limited by VRAM capacity. +On Apple Silicon Macs, unified memory is shared between CPU and GPU. An M2 Mac with 16GB unified memory can run 7–8B models comfortably. -> 🧠 Rule of thumb: You’ll need roughly 1GB of VRAM per billion parameters. +**Software requirements** ---- +- macOS 14 Sonoma+, Windows 10+, or Ubuntu 20.04+ +- No account required — Ollama is free and open source -### 2. Run your first model +## 1. Install Ollama -Run a model locally: +**macOS** -> ollama run gpt-oss +Run the install script in your terminal: -For example: +```bash +curl -fsSL https://ollama.com/install.sh | sh +``` -* Try GPT-OSS 20B (requires ≥16GB VRAM, supports tool calling). -* Then try Mistral 8B for a faster, smaller alternative. +Or download the macOS app manually from [ollama.com/download](https://ollama.com/download/Ollama.dmg). The app runs as a background service and appears in your menu bar. -Compare their performance and quality side-by-side.\ -Use Warp to easily monitor GPU usage and model response time. +**Linux** ---- +```bash +curl -fsSL https://ollama.com/install.sh | sh +``` -### 3. Understanding model terms +On systemd-based Linux distributions, the installer typically registers Ollama as a service. To start it and enable it on boot, run: -Here’s a quick glossary for choosing the right local model: +```bash +sudo systemctl enable ollama +sudo systemctl start ollama +``` -| Term | Meaning | -| ---------------- | ------------------------------------------------------------------ | -| **Thinking** | The model “thinks” before answering; better for complex reasoning. | -| **Tools** | Models can use external utilities (e.g., web search). | -| **Vision** | Can process and respond to images. | -| **Embedding** | Converts text to numeric form for search or RAG pipelines. | -| **Quantization** | Reduces memory use by lowering precision (e.g., 4-bit). | +**Windows** ---- +Run this in PowerShell: -### 4. Integrate Ollama into your app +```powershell +irm https://ollama.com/install.ps1 | iex +``` -Most apps use OpenAI-compatible APIs, so integration is simple. +Or download the installer manually from [ollama.com/download](https://ollama.com/download). Ollama runs as a background service after installation. -1. Open your app’s code in Warp. -2. Locate the OpenAI client initialization. -3. Replace the base URL with Ollama's -4. Update your API key and model name. +## 2. Run your first model -Warp helps you quickly locate, edit, and test the integration directly from the terminal. +Pull a model to download it locally. This example uses Llama 3.2 (3B), a lightweight model that runs on most hardware: ---- +```bash +ollama pull llama3.2 +``` + +Then start an interactive chat session: + +```bash +ollama run llama3.2 +``` + +Type your prompt and press Enter. Type `/bye` to exit the session. + +To try a larger model with stronger reasoning: + +```bash +ollama run llama3.1:8b +``` + +Use `ollama ls` to see all models you've downloaded, and `ollama ps` to see which models are currently loaded in memory. + +## 3. Understand model types + +When browsing [ollama.com/library](https://ollama.com/library), you'll see labels on models that indicate their capabilities: + +| Label | Meaning | +|---|---| +| **thinking** | The model reasons step-by-step before answering; better for complex problems. | +| **tools** | The model can call external functions or utilities (e.g., web search). | +| **vision** | The model can process and respond to images. | +| **embedding** | Converts text to numeric vectors for search or RAG pipelines. | + +Quantized models (e.g., `q4_0`, `q8_0` variants) use significantly less memory than full-precision originals. Start with a quantized version if you're memory-constrained. + +## 4. Compare model performance + +To benchmark models side by side, Warp makes it easy to run prompts in parallel tabs and compare results. Pass a prompt and the `--verbose` flag to get timing stats alongside the response: + +```bash +ollama run --verbose llama3.2 "Summarize the Rust ownership model in one paragraph" +``` + +Run the same prompt on two different models to compare output quality and throughput before committing to one. + +To see which models are currently loaded and their memory usage: + +```bash +ollama ps +``` + +## 5. Integrate Ollama into your app + +Ollama exposes an OpenAI-compatible REST API at `http://localhost:11434/v1/`. You can drop it in wherever you're currently using the OpenAI API — just update three values: + +1. **Base URL** → `http://localhost:11434/v1/` +2. **API key** → any non-empty string (e.g., `"ollama"` — required by the SDK but ignored by Ollama) +3. **Model name** → the name of your local model (e.g., `"llama3.2"`) + +**Python (OpenAI SDK)** + +```python +from openai import OpenAI + +client = OpenAI( + base_url="http://localhost:11434/v1/", + api_key="ollama", # required by the SDK but ignored by Ollama +) + +response = client.chat.completions.create( + model="llama3.2", + messages=[ + {"role": "user", "content": "Explain async/await in Python"} + ] +) + +print(response.choices[0].message.content) +``` + +**Node.js (OpenAI SDK)** + +```javascript +import OpenAI from "openai"; + +const client = new OpenAI({ + baseURL: "http://localhost:11434/v1/", + apiKey: "ollama", // required by the SDK but ignored by Ollama +}); + +const response = await client.chat.completions.create({ + model: "llama3.2", + messages: [{ role: "user", content: "Explain async/await in Python" }], +}); + +console.log(response.choices[0].message.content); +``` + +Ollama also provides official native libraries if you prefer an SDK built specifically for Ollama rather than the OpenAI compatibility layer: `pip install ollama` for Python and `npm i ollama` for JavaScript. See the [Ollama README](https://github.com/ollama/ollama) for details. + +Open your app's code in Warp and use the agent to locate the OpenAI client initialization, swap in the new values, and test the connection — all from the same terminal session. + +## 6. Customize model behavior + +You can create a custom model variant by writing a `Modelfile` — a configuration file that sets a system prompt, adjusts generation parameters, or builds on any existing Ollama model. + +Create a file called `Modelfile`: + +``` +FROM llama3.2 + +SYSTEM """ +You are a focused code review assistant. +Always identify security issues first, then logic errors, then style. +Keep feedback concise and actionable. +""" + +PARAMETER temperature 0.3 +PARAMETER num_ctx 8192 +``` + +Then build and run your custom model: + +```bash +ollama create code-reviewer -f ./Modelfile +ollama run code-reviewer +``` + +Your custom model is saved locally and available any time you run `ollama run code-reviewer`. Ask Warp's agent to generate a Modelfile for a specific use case — describe what you want the model to do, and let the agent write the configuration. + +## Productivity tips -### 6. Customize model behavior +- **Unload to free memory** — Use `ollama stop ` to unload a model from memory before loading a larger one. +- **Script with the REST API** — For quick testing without the SDK: `curl http://localhost:11434/api/chat -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "Hello"}], "stream": false}'` +- **Keep a model inventory** — `ollama ls` shows all locally cached models with their sizes and download dates. Use `ollama rm ` to delete models you no longer need. +- **Compare models in parallel** — Open side-by-side Warp tabs and run the same prompt against two different models to compare quality and speed before deciding which to use in your app. -Pull and modify a model. +## Next steps -Then save it as a custom model with new settings like temperature or system prompt. +You have Ollama installed, a model running locally, and a path to integrate it into any app using the OpenAI-compatible API. -Use Warp to generate a model file automatically. +Explore related guides and features: -This adds a structured system prompt for that task — ready to use instantly. +- [Set up Claude Code](/guides/external-tools/how-to-set-up-claude-code/) or [Set up Codex CLI](/guides/external-tools/how-to-set-up-codex-cli/) — use cloud-based agents alongside your local Ollama setup +- [Run multiple agents at once](/guides/agent-workflows/how-to-run-multiple-ai-coding-agents/) — run Ollama and a cloud agent in parallel to compare outputs on the same task +- [Ollama model library](https://ollama.com/library) — browse all available models with size and capability details +- [Ollama documentation](https://github.com/ollama/ollama/blob/main/README.md) — advanced configuration, GPU setup, and environment variables