Last updated 13 October 2026
Use Claude Code to review pull requests
Preparing your workspace for an automated review
Reviewing code often feels like a bottleneck in a busy development cycle. You look at a pull request and see dozens of files changed across different modules. You have your own features to ship but your team is waiting for feedback. You need a way to speed up the process without missing critical logic flaws or security risks. Claude Code allows you to perform these reviews directly from your terminal where you already have the codebase and your favorite tools. This local access is the key to a fast and thorough analysis of any pull request.
To begin a review you must first get the code onto your local machine. Use your standard version control tools to fetch the remote branch and switch to it. This ensures the agent has access to the exact state of the code that needs reviewing. Once you are on the correct branch you can start the agent by typing the claude command in the root of your project. The agent will initialize and scan your project structure to understand the context. It respects your ignore files so it will not waste time looking at build artifacts or node modules.
Setting project standards in CLAUDE.md
The agent needs to know what your team considers good code. Every project has its own style and specific rules that a general model might not know. You can define these rules in a file called CLAUDE.md located in your project root. This file acts as a permanent set of instructions for the agent. If you want the agent to prioritize certain design patterns or avoid specific libraries you should list those requirements here. The agent reads this file every time a session starts or when it needs to make a decision about how to handle your code.
You can create a specific section in CLAUDE.md dedicated to code reviews. Tell the agent to look for common issues like missing error handling or inefficient database queries. You might also include instructions on how to format feedback. For example you can ask the agent to provide a summary of the changes first and then list specific line by line suggestions. By putting these instructions in a file rather than typing them every time you ensure consistency across all reviews performed on that project. The agent will always have your team standards at its fingertips.
Analyzing changes with built-in tools
Once the session is active you can ask the agent to find the differences between the current branch and the main branch. The agent uses the Bash tool to run shell commands like git diff to see exactly what has changed. It can then use the Read tool to open specific files and examine the code in detail. Unlike a simple text search the agent understands the logic and the flow of the program. It can follow function calls across different files to see how a change in one place affects the rest of the application.
You can give the agent specific tasks during this process. You might ask it to find any new environment variables that were added without being documented. You could also ask it to use the Glob tool to find all files in a specific directory and check if they follow the new architecture. The agent combines its ability to run commands with its understanding of programming languages to provide a level of insight that goes beyond basic linting. It acts as a pair programmer that has already read every line of your project.
Using specialized subagents for deep analysis
Sometimes a single session is not enough for a complex review. You might want a dedicated security expert to look at the code or a performance specialist to check for slow loops. You can create specialized agents by placing markdown files in the .claude/agents directory. These subagents can have their own specific personas and sets of instructions. When you are in a main session you can use the /agents command to see your available specialists and task them with a deep dive into a specific part of the pull request.
This modular approach allows you to separate different types of feedback. One subagent might focus entirely on unit test coverage and ensuring that new tests follow the correct patterns. Another subagent could focus on documentation and check if the CLAUDE.md file itself needs an update based on the new code. This keeps your main session clean and allows you to delegate complex tasks to narrow experts. It mimics the way a real team might have different people look at different aspects of a large change.
Managing multiple reviews with adhdTerminal
Switching between different pull requests can be mentally taxing for a developer. Each PR has its own context and its own set of problems to solve. If you are using the standard terminal you have to constantly quit sessions and switch branches which breaks your flow. This is where adhdTerminal becomes a significant help. It allows you to run multiple Claude Code sessions side by side as separate tiles on a single wall. You can have one tile dedicated to a backend refactor and another tile focused on a frontend bug fix.
Each tile in adhdTerminal maintains its own state and its own branch context. You can see at a glance which review is still processing and which one is waiting for your input. The color coded tiles and names make it easy to remember which PR you are currently looking at. Because the app resumes your sessions after a restart you do not have to worry about losing the progress of a long review. This layout is designed for the reality of modern development where you are often juggling several tasks at once and need to keep them organized.
Handling large diffs and context limits
If a pull request is very large the conversation can quickly fill up the available context window. When this happens the agent might start to forget the earlier parts of the review. You can use the /compact command to handle this situation. This command tells the agent to summarize the conversation so far and clear out the unnecessary details. This frees up space for the agent to continue reading more files and providing more feedback without losing the overall goal of the session.
It is also helpful to use the /clear command if you want to start the review from a fresh state without closing the terminal. If you find that the agent is getting confused by too many conflicting instructions a quick clear can reset its focus. You can also use the /memory command to see what the agent is currently tracking about your project. Managing the context window is a skill that helps you get better results from the agent especially on large legacy codebases where the amount of information can be overwhelming.
Running single pass reviews with prompts
You do not always need an interactive session to get a quick check on a small change. You can use the claude -p command to run a single prompt and get a direct answer. This is useful for simple questions like asking if a specific file follows the naming conventions defined in your project. You can pipe the output of a git command directly into this prompt to give the agent the context it needs. This allows you to integrate the agent into your existing shell scripts or pre-commit hooks.
Using the -p flag is a fast way to get a second opinion before you even push your code to the remote repository. It provides an immediate feedback loop that catches simple mistakes before they ever reach another human reviewer. This saves time for everyone on the team and keeps the quality of the main branch high. You can even combine this with the /cost command afterwards to see how much that specific check cost you in terms of API usage. This transparency helps you manage your resources while still getting the benefits of an automated review.
Exporting feedback and final approval
After the agent has finished its analysis you need to get that feedback back into your version control system. You can use the /export command to save the entire conversation or just the relevant parts of the review. This creates a record of the logic behind the changes and the suggestions made by the agent. You can then paste these comments into your PR platform or use them to make direct edits to the code. If the agent suggests changes you can use the Edit tool to apply them immediately within the same session.
Once you are happy with the state of the code you can use the /status command to see a summary of what has been done. If you need to stop for any reason you can use Ctrl+C to quit the session. If you need to come back to it later the claude --continue command will bring you right back to where you left off. This workflow turns the terminal into a powerful command center for code quality. You spend less time waiting for manual reviews and more time shipping code that you know has been thoroughly checked by a capable agent.
Questions people ask
Can I use this to review code that is not in a Git repository?
Yes you can run the agent in any folder on your machine. However it is much more effective within a Git repository because the agent can use the Bash tool to compare different branches and commits. Without Git you will have to manually tell the agent which files to read and compare.
How do I make sure the agent does not change my code without permission?
The agent operates in a default permission mode where it asks for your approval before using tools like Edit or Write. You can also use the Shift+Tab shortcut inside a session to cycle through different permission modes. If you want to be extra safe you can use the plan mode which only allows the agent to describe what it would do without actually performing any actions.
Does the agent understand private libraries or internal company frameworks?
The agent only knows what is in the files it can read or what you have told it in CLAUDE.md. If your project uses internal frameworks you should provide examples or documentation within the repository. The agent can then use the Read and Grep tools to learn how those frameworks work and provide relevant feedback based on that local context.
Read next
- Add build instructions to your CLAUDE.md fileImprove project context by adding specific build commands and environment requirements to your CLAUDE.md file for the AI to follow.
- Add common error fixes to CLAUDE.mdImprove project memory by adding a section for common errors and their fixes to your CLAUDE.md configuration file.
- Add custom shell aliases for Claude CodeSpeed up your workflow by creating shell aliases for common Claude Code invocations and project-specific startup commands.
- Add test commands to a CLAUDE.md fileUnderstand how to define specific test runners and environment flags in your CLAUDE.md file so the tool runs the correct test suite.