Learning resourcesReviewed · Anysphere

Build a PR reviewer with Agent SDK

This Cursor Agent SDK tutorial teaches developers to build a GitHub pull request reviewer, but its size-based decisions and patches that are capped or omitted limit review depth. It combines TypeScript tools, agent instructions and GitHub event handling to approve changes or post comments asking for human review.

Researched 14 Nov 2026

In short.

This Cursor Agent SDK tutorial helps developers build an automated GitHub pull request reviewer, but its simple size rules and incomplete patch context limit its reliability as an approval authority. The example fetches pull request data, classifies changes as trivial, moderate or large, and lets an agent approve changes or comment that human review is needed. It supplies local setup, direct tool checks and GitHub triggers; deployment details are linked separately. Review accuracy, operating costs and runtime behavior are not established by the evidence.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete captured page at [https://cursor.com/docs/agent-sdk/quickstart.md]: its coding-agent prompt, prerequisites, setup, instructions, parser, tools, verification examples, GitHub channel, replay steps and deployment pointers. Linked deployment, evaluations, tool-reference, GitHub-guide, dashboard and sitemap pages are excluded. Only inline code examples are supplied; no separate package files or explicit license notices are included. Expected outputs are documentation claims, and runtime behavior, review correctness, deployment success and costs remain unverified.

The overview

Identity

The resource is Cursor's documentation tutorial at [https://cursor.com/docs/agent-sdk/quickstart.md]. It teaches one concrete Agent SDK application: a GitHub pull request reviewer. The page includes agent instructions, two TypeScript tools, a shared URL parser, a GitHub channel and commands for local development. It links to separate deployment and reference documentation.

Assessment

The tutorial is useful for learning how an agent combines written instructions with tools that read and write GitHub data. Its small example makes the boundary between deterministic classification and model judgment visible.

Its suitability for automatic approval is less established. Change size determines the complexity label, while the model must judge whether the visible patches are safe. The page supplies expected classification results, but no evidence of defect detection, approval accuracy or resistance to misleading pull request content.

Users

The tutorial is aimed at developers who want to build a GitHub-connected agent using Node.js and TypeScript. Beginners receive file locations and commands, but still need familiarity with terminals, pull requests and repository permissions. Experienced developers can use the example to examine tool definitions, GitHub API calls and event-triggered agent sessions.

Teams seeking a finished review service would need additional work: the page does not establish production review quality or provide a complete operational configuration.

Capabilities

The inspect_pr tool retrieves a pull request's title, draft status, change counts and file information. For trivial and moderate changes it returns each file's patch limited to 3,000 characters (longer patches are cut off and a patch may be absent); for large changes it omits patches. The submit_review tool can post an approval or a comment asking for human review.

The GitHub channel starts reviews for opened, reopened and ready_for_review events, excluding drafts. The tutorial also describes direct tool calls without a model turn, replaying a GitHub event locally, and inspecting tool calls and the verdict in a playground.

Using it

Requirements

The stated prerequisites are Node 22.13 or newer and a Cursor login for model turns. The documented CLI package is @grok/agent-sdk, installed globally through npm. The example uses TypeScript, Zod input schemas and a host-provided GitHub client. The captured page does not establish who publishes the @grok/agent-sdk package on npm.

Posting a review requires GitHub write access and a pull request the user did not author. The page says pull access is sufficient for event replay. Detailed GitHub authorization setup, account-tier requirements and deployment prerequisites are not established within this page.

Mechanism

Classification uses additions plus deletions and the number of changed files. A change is trivial when it changes at most 25 lines across at most two files. Otherwise, it is moderate when it changes at most 400 lines across at most 15 files. All remaining changes are large. These are size thresholds, not measurements of semantic difficulty or security risk.

The instructions tell the agent to inspect first, never approve drafts, approve trivial changes only when they match the title and look safe, and approve moderate changes only when every patch is understood and appears safe. Large changes should go directly to human review.

Human escalation is implemented as a GitHub COMMENT review containing a request for human attention. It does not assign a reviewer or submit a REQUEST_CHANGES review.

Setup

The documented sequence installs the CLI with npm install -g @grok/agent-sdk, authenticates with agent-sdk login, creates a project with agent-sdk init ./pr-reviewer, and starts agent-sdk dev inside that directory. A second terminal sends an introductory message to confirm that the agent replies.

The reader then replaces bot/instructions.md, adds the parser at bot/lib/github.ts, creates inspect_pr.ts and submit_review.ts under bot/tools, and adds bot/channels/github.ts. The repository placeholders must be replaced with the intended repository.

The page offers both a coding-agent-assisted path and manual steps. The assisted path calls for agent-sdk validate --dir . and the project's TypeScript check, but does not supply an exact TypeScript-check command. Deployment requires following a separate linked page.

Example

The page supplies two direct inspect_pr examples. It expects [https://github.com/facebook/react/pull/35623] to return trivial and [https://github.com/facebook/react/pull/25229] to return large without patch fields. These are documented expectations; no captured command outputs establish their results.

For a complete review, the tutorial uses the placeholder [https://github.com/acme/checkout/pull/42]. It asks the reader to confirm that inspect_pr precedes submit_review, inspect the resulting GitHub review, and replay an opened event to see both tool calls and the verdict in the playground.

Assessment & evidence

Limitations

Non-large patches are capped at 3,000 characters per file, and a patch can also be absent. Large changes provide no patches. The file-list request asks for up to 100 files and includes no pagination, so large pull requests may have incomplete file listings. The reviewer tools do not run tests or inspect CI results.

The inspect-first and never-approve-drafts rules are written instructions. The submission tool does not enforce prior inspection, check draft status or bind approval to the commit that was inspected. Consequently, those safeguards depend on agent behavior and timing.

The supplied event filter excludes synchronize events, so later commit pushes do not independently trigger a review through that action. The URL parser checks path components and a parseInt result, but does not validate the hostname or require the entire pull request number string to be numeric.

No dedicated handling of instructions embedded in pull request titles or patches is shown. Runtime reliability, review quality, latency and deployment behavior remain unassessed.

Reasoning

Separating data collection, size classification and review submission makes the example easy to inspect and extend. Omitting large patches bounds the information passed to the model, while the instructions direct those changes toward human attention.

The tradeoff is reduced review context. A small change can still have serious consequences, and a moderate patch may be truncated before the agent sees it. These are inferences from the supplied thresholds and truncation logic. The design supports learning tool integration, but its code and examples do not establish that automated approvals are dependable.

Alternatives

The page offers two ways to build the same reviewer: give its supplied prompt to a coding agent or follow the manual instructions. For teams that want triage while retaining human approval, a possible adaptation is to make submit_review comment-only; that variant is not supplied or evaluated.

The page provides no comparative evidence about other SDKs or review services. Its links to evaluations, tool reference material and GitHub guidance are further reading, rather than assessed alternatives.

Evidence

The evidence is the complete captured documentation page at [https://cursor.com/docs/agent-sdk/quickstart.md]. It contains inline implementation examples, prescribed commands and expected classifier outputs. It contains no execution logs, measured review results or successful deployment receipts.

Code-level findings follow from reading the supplied examples. No commands or code were executed, and neither the reviewer nor the SDK was tested.

Access & freshness

Costs

Costs are unknown. The page gives no subscription prices, model rates, usage allowances, token measurements or deployment charges. It requires a Cursor login for model turns and allows direct tool checks without a model turn, but neither statement establishes whether any operation is free. A total operating cost cannot be estimated from this evidence.

Rights

The supplied page contains no explicit license or reuse terms for its prose, sample code or SDK. Permission to copy, modify or redistribute those materials is unknown from this evidence. Separate SDK and service terms are also not supplied.

Freshness

The page snapshot was captured at 2026-11-14T03:31:54.871Z. Its source revision is sha256:31dcec468bc7e544b3307923e89136ce40f730b41b43783e60b4c5f5d31a567f. This identifies the analyzed text, not an SDK release.

The page does not specify an SDK version or publication date, and its installation command does not pin a package version. Current package behavior, CLI compatibility and the example pull requests' current contents are unknown beyond the captured documentation.

Actions

To evaluate the tutorial, begin with a repository you can access and a pull request you did not author. Before the global install, confirm that the npm publisher of @grok/agent-sdk is the vendor behind this documentation. Follow the local setup, call inspect_pr directly, and compare its returned metadata and patches with GitHub before enabling review submission. Run the documented validation and the project's TypeScript check, then verify tool order and the actual posted review.

Before using automatic approvals, consider enforcing draft and prior-inspection checks in tool code, handling changed commits, and deciding how comments will reach a human reviewer. Confirm applicable costs and reuse terms separately. Deployment instructions and evaluation guidance require consulting the linked documentation.

Evidence for this report

selected-page.txtselected · checked 2026-11-14