Skip to main content

Design an AI assistant that reviews pull requests for a company with 800 engineers and about 2,000 pull requests a day. Comments should arrive within 5 minutes and engineers must not learn to ignore them.

System design · Pro 2

Short answer

Clarify what it should catch and that people still approve. Trigger on pull request events through a queue, gather context beyond the diff, combine linters and tests with model review, and post only a few high-confidence comments with reasons. Treat code as untrusted input, give no write access, and measure how often comments lead to a change.

Deeper answer

Requirements: which problems matter most (bugs, security, missing tests), which repositories, and where code may be sent. The assistant advises and a human approves. The main product risk is noise: if most comments are wrong or trivial, engineers stop reading.

Flow: a webhook puts each pull request on a queue. A worker fetches the diff and builds context: the changed files, nearby definitions found by code search, the description, and the team's guidelines. Static analysis and tests run first, because they are cheap and exact. The model then reviews in chunks and returns structured findings with file, line, severity and confidence. A filter removes duplicates and low-confidence items and caps the number of comments.

Trade-offs: more context improves quality but adds cost and latency, so use a cheaper model for a first pass and a strong one for risky files. Safety: the diff is untrusted text and may contain instructions, so the assistant has read-only access and cannot merge. Measure the share of comments that lead to a code change, the dismiss rate, and precision on a set of past pull requests with known bugs.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Design an AI system

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.