Skip to main content
Glama

review_code

Analyze code changes, provide feedback, and improve quality by reviewing security, performance, style, or logic. Supports Git diffs and custom context for targeted insights.

Instructions

Review code changes and provide feedback

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoContext about the changes
diffYesGit diff or code changes to review
reviewTypeNoType of review to performall

Implementation Reference

  • ReviewCodeTool class: core handler logic for the review_code tool, generates AI prompts for code review based on options.
    class ReviewCodeTool extends BaseAITool<CodeReviewOptions> { private readonly reviewFocus = { security: 'Security vulnerabilities, input validation, authentication/authorization issues, data exposure risks', performance: 'Performance bottlenecks, inefficient algorithms, memory leaks, unnecessary computations', style: 'Code style consistency, naming conventions, code organization, readability', logic: 'Business logic errors, edge cases, error handling, correctness of implementation', all: 'All aspects including security, performance, code style, and logic', }; protected getActionName(): string { return 'reviewing code'; } protected getSystemPrompt(args: CodeReviewOptions): string { const { reviewType = 'all' } = args; return `You are an expert code reviewer. Review the provided code changes critically and provide actionable feedback. Focus on: ${this.reviewFocus[reviewType]} Provide: - Specific line-by-line feedback where issues are found - Severity level for each issue (critical, major, minor) - Concrete suggestions for improvement - Recognition of good practices when present Be constructive but thorough in identifying potential issues.`; } protected getUserPrompt(args: CodeReviewOptions): string { const { diff, context } = args; return `Review these code changes:\n\n${diff}${context ? `\n\nContext: ${context}` : ''}`; } }
  • Exported reviewCode function: entrypoint handler that executes the ReviewCodeTool instance.
    export async function reviewCode(args: CodeReviewOptions): Promise<CallToolResult> { return tool.execute(args); }
  • CodeReviewOptions interface: input schema defining parameters for code review tool (diff, context, reviewType).
    export interface CodeReviewOptions { diff: string; context?: string; reviewType?: 'security' | 'performance' | 'style' | 'logic' | 'all'; }
  • reviewFocus object: helper mapping review types to specific focus descriptions used in system prompt.
    private readonly reviewFocus = { security: 'Security vulnerabilities, input validation, authentication/authorization issues, data exposure risks', performance: 'Performance bottlenecks, inefficient algorithms, memory leaks, unnecessary computations', style: 'Code style consistency, naming conventions, code organization, readability', logic: 'Business logic errors, edge cases, error handling, correctness of implementation', all: 'All aspects including security, performance, code style, and logic', };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jaggederest/mcp_reviewer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server