Short answer: create .claude/agents/sql-reviewer.md with a name, a description that says when to use it, a tools line limited to reading (Read, Grep, Glob), and the review instructions below. Call it by typing @ and picking it, or let Claude hand it the job when you ask for a review. It works in its own context window, so a long review does not crowd your main conversation.
Claude Code already has three built-in agents: Explore (searches code, read-only), Plan (researches for plan mode) and general-purpose. None of them knows your team's rules for SQL. A custom agent does, and it reviews the same way every time.
How is an agent different from a skill?
| | | Skill | Agent |
|---|---|---|
| Where it runs | In your main conversation | In its own context window |
| Tools | Whatever the session has | Only the ones you list |
| Good for | A checklist on one query | Reviewing many changed files |
| Called by | /name, or a matching request | @name, or a matching request |
What does the agent file look like?
---
name: sql-reviewer
description: Use after SQL files change, to review them before commit. Read-only.
tools: Read, Grep, Glob
---
You review SQL changes in this repository.
For each changed .sql file:
- Check joins for keys that are not unique (rows that repeat).
- Check date filters and NULL handling.
- Flag UPDATE or DELETE without WHERE.
- Compare column names with the files in schema/.
Answer as a table: file, line, problem, suggested fix.
If everything is fine, say so in one line.Because the tools are read-only, the reviewer can never "fix" a file on its own; it reports, and you decide.
When do you call it?
After a change and before the commit: "@sql-reviewer review the SQL I changed today". On a big pull request, it reads every file in its own context and returns one table.
Where can you check this?
- Claude Code docs: Subagents, built-in agents, file locations, fields and @-mentions
Where do you start?
For a lighter check on one query, see a skill that checks SQL. For a searching agent, see subagents for big schemas.