review_directory
Analyze all files in a directory using Codex and Gemini code review tools to identify quality, security, and performance issues while providing actionable feedback for improvement.
Instructions
Request a code review of all files in a directory from Codex and Gemini CLIs. Returns feedback from both reviewers for Claude to consider.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | Additional context about the code (optional) | |
| directory | Yes | Path to the directory to review | |
| reviewers | No | Which reviewers to use (default: both) |
Implementation Reference
- src/index.ts:314-342 (handler)Main handler function for the 'review_directory' tool. Reads all code files recursively from the directory, performs reviews using available CLIs (Codex/Gemini), and formats the results.private async handleReviewDirectory(args: CodeReviewRequest) { const { directory, context, reviewers = ["both"] } = args; if (!directory) { throw new Error("Directory path is required"); } const files = await this.getCodeFiles(directory); const allReviews: Array<{ file: string; reviews: Record<string, string> }> = []; for (const file of files) { const code = await fs.readFile(file, "utf-8"); const reviews = await this.performReview( code, `File: ${file}\n${context || ""}`, reviewers ); allReviews.push({ file, reviews }); } return { content: [ { type: "text", text: this.formatDirectoryReviews(allReviews), }, ], }; }
- src/index.ts:17-23 (schema)TypeScript interface defining the input parameters for code review tools, including 'directory' for review_directory.interface CodeReviewRequest { filePath?: string; directory?: string; code?: string; reviewers?: string[]; context?: string; }
- src/index.ts:241-267 (registration)Tool registration in getTools(): defines name, description, and JSON inputSchema for 'review_directory'.{ name: "review_directory", description: "Request a code review of all files in a directory from Codex and Gemini CLIs. Returns feedback from both reviewers for Claude to consider.", inputSchema: { type: "object", properties: { directory: { type: "string", description: "Path to the directory to review", }, context: { type: "string", description: "Additional context about the code (optional)", }, reviewers: { type: "array", items: { type: "string", enum: ["codex", "gemini", "both"], }, description: "Which reviewers to use (default: both)", }, }, required: ["directory"], }, },
- src/index.ts:111-112 (handler)Dispatch handler in CallToolRequestSchema that routes 'review_directory' calls to the main handler.case "review_directory": return await this.handleReviewDirectory(args as CodeReviewRequest);
- src/index.ts:344-360 (helper)Helper function to recursively traverse directory and collect paths of code files (excluding dotfiles and node_modules).private async getCodeFiles(directory: string): Promise<string[]> { const files: string[] = []; const entries = await fs.readdir(directory, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(directory, entry.name); if (entry.isDirectory()) { if (!entry.name.startsWith(".") && entry.name !== "node_modules") { files.push(...(await this.getCodeFiles(fullPath))); } } else if (this.isCodeFile(entry.name)) { files.push(fullPath); } } return files; }