Deep Agents
Code Review Agent with Deep Agents
Build an AI code review agent that reads files, searches for patterns, analyzes code quality, and suggests improvements — with Deep Agents.
code reviewstatic analysisqualitydeveloper tools
Working Code
from deepagents import create_deep_agentfrom langchain_core.tools import tool
@tooldef read_file(path: str) -> str: """Read a file from the project.""" return Path(path).read_text()
@tooldef find_files(pattern: str) -> str: """Find files matching a glob pattern.""" files = list(Path(".").rglob(pattern)) return "\n".join(str(f) for f in files[:20])
@tooldef search_code(pattern: str, path: str = ".") -> str: """Search for a regex pattern in source files.""" import subprocess result = subprocess.run( ["grep", "-rn", pattern, path, "--include=*.py"], capture_output=True, text=True, ) return result.stdout[:3000] or "No matches found."
agent = create_deep_agent( model="anthropic:claude-sonnet-4-5-20250929", tools=[read_file, find_files, search_code], system_prompt="You are a code reviewer. Find relevant files, read them, search for patterns, and provide a structured review covering security, performance, and best practices.",)
result = agent.invoke({ "messages": [("user", "Review the Python files in src/ for common security issues")]})print(result["messages"][-1].content)Step by Step
1
Install dependencies
Install Deep Agents and the required tools for this use case.
2
Define your tools
Create the domain-specific tool functions your agent will use to interact with external services.
3
Create the agent and run
Initialize the Deep Agents agent with your tools, set the system prompt, and execute a query.
Build with other frameworks
Ready to build with Deep Agents?
Generate a production-ready project with Deep Agents pre-configured — FastAPI + Next.js, auth, streaming, and more.
Get StartedReady to build your first production AI agent?
Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.