Skip to main content
Glama

genpr

Analyzes code changes and generates structured Pull Request descriptions to document modifications and facilitate code review processes.

Instructions

【生成 PR】分析变更并生成规范的 Pull Request 描述

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNo分支名称
commitsNoCommit 历史

Implementation Reference

  • The core handler function for the 'genpr' tool. It constructs a detailed prompt template for generating standardized Pull Request descriptions based on branch name and commit history, and returns it as a text content block.
    export async function genpr(args: any) {
      try {
        const branch = args?.branch || "";
        const commits = args?.commits || "";
    
        const message = `请生成规范的 Pull Request 描述:
    
    📝 **分支信息**:
    ${branch || "请提供分支名称"}
    
    📋 **Commit 历史**:
    ${commits || "请先执行 git log 查看 commit 历史"}
    
    ---
    
    ## PR 描述生成指南
    
    ### 第一步:分析变更内容
    
    执行以下命令获取详细信息:
    \`\`\`bash
    # 查看 commit 历史
    git log origin/main..HEAD --oneline
    
    # 查看具体变更
    git diff origin/main..HEAD --stat
    
    # 查看修改的文件
    git diff origin/main..HEAD --name-only
    \`\`\`
    
    ### 第二步:生成 PR 描述
    
    **标准 PR 模板**:
    
    \`\`\`markdown
    ## 📝 变更说明
    
    ### 概述
    简要说明这个 PR 的目的和背景(2-3 句话)
    
    ### 变更内容
    - 🎨 UI/UX 改进:...
    - ✨ 新功能:...
    - 🐛 Bug 修复:...
    - ♻️ 重构:...
    - 📝 文档更新:...
    - 🚀 性能优化:...
    
    ## 🎯 解决的问题
    
    Closes #123
    Fixes #456
    Relates to #789
    
    ## 🔧 技术细节
    
    ### 主要修改
    1. **模块 A**:修改内容和原因
    2. **模块 B**:修改内容和原因
    
    ### 架构变更(如有)
    - 数据库 Schema 变更
    - API 接口变更
    - 配置文件变更
    
    ### 依赖变更(如有)
    - 新增依赖:\`package-name@version\`
    - 移除依赖:\`old-package\`
    - 升级依赖:\`package@old → package@new\`
    
    ## ✅ 测试计划
    
    ### 单元测试
    - [x] 新增测试用例覆盖新功能
    - [x] 所有测试通过
    - [x] 测试覆盖率 > 80%
    
    ### 集成测试
    - [x] API 接口测试通过
    - [x] 端到端测试通过
    
    ### 手动测试
    - [x] 功能 A 正常工作
    - [x] 功能 B 正常工作
    - [x] 边界情况验证
    
    ## 📸 截图/录屏(UI 变更时)
    
    ### Before
    ![Before Screenshot](url)
    
    ### After
    ![After Screenshot](url)
    
    ## ⚠️ 注意事项
    
    ### Breaking Changes(破坏性变更)
    - ⚠️ API 路径从 \`/old\` 改为 \`/new\`
    - ⚠️ 配置文件格式变更
    
    ### 部署注意
    - 需要执行数据库迁移:\`npm run migrate\`
    - 需要更新环境变量:\`NEW_VAR=value\`
    - 需要重启服务
    
    ### 向后兼容性
    - ✅ 完全兼容
    - ⚠️ 部分兼容(说明不兼容的部分)
    - ❌ 不兼容(需要特殊处理)
    
    ## 📋 Checklist
    
    - [ ] 代码通过 lint 检查
    - [ ] 所有测试通过
    - [ ] 文档已更新
    - [ ] Changelog 已更新
    - [ ] 性能影响已评估
    - [ ] 安全影响已评估
    - [ ] 代码已自我审查
    - [ ] 已添加必要的注释
    
    ## 🔗 相关链接
    
    - 设计文档:[链接]
    - 技术方案:[链接]
    - 相关 PR:#xxx
    
    ## 👥 审查者
    
    @reviewer1 @reviewer2
    
    ## 🙏 致谢
    
    感谢 @contributor1 的建议
    \`\`\`
    
    ---
    
    ## PR 标题规范
    
    格式:\`<type>(<scope>): <subject>\`
    
    **示例**:
    - \`feat(auth): 添加 OAuth2 登录支持\`
    - \`fix(api): 修复用户查询接口分页错误\`
    - \`refactor(ui): 重构组件层级结构\`
    
    ---
    
    现在请根据变更内容生成完整的 PR 描述,并建议合适的审查者。`;
    
        return {
          content: [
            {
              type: "text",
              text: message,
            },
          ],
        };
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `❌ 生成 PR 描述失败: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the 'genpr' tool, specifying optional parameters for branch and commits.
    {
      name: "genpr",
      description: "【生成 PR】分析变更并生成规范的 Pull Request 描述",
      inputSchema: {
        type: "object",
        properties: {
          branch: {
            type: "string",
            description: "分支名称",
          },
          commits: {
            type: "string",
            description: "Commit 历史",
          },
        },
        required: [],
      },
    },
  • src/index.ts:483-484 (registration)
    Dispatch/registration in the main tool call switch statement, invoking the genpr handler.
    case "genpr":
      return await genpr(args);
  • src/tools/index.ts:9-9 (registration)
    Re-export of the genpr function from its module for use in the main index.
    export { genpr } from "./genpr.js";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool analyzes changes and generates PR descriptions, but doesn't explain how it works (e.g., AI-based analysis, template-based generation), what permissions are needed, whether it modifies code or just outputs text, or what the output format looks like. For a tool with no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that clearly states the core function. It's appropriately sized for a simple tool and front-loaded with the main purpose. There's no wasted verbiage, though it could be slightly more structured with usage context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (analyzing changes and generating documentation), no annotations, no output schema, and 100% schema coverage, the description is minimally adequate. It states what the tool does but lacks details on behavior, output format, and usage context. It meets the bare minimum but has clear gaps for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't mention parameters at all, but schema description coverage is 100% (both 'branch' and 'commits' have descriptions in Chinese). Since the schema already documents parameters adequately, the baseline is 3. The description adds no additional parameter context beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '分析变更并生成规范的 Pull Request 描述' (analyze changes and generate a standardized Pull Request description). It specifies the verb '生成' (generate) and resource 'Pull Request 描述', making it clear this creates PR documentation. However, it doesn't explicitly differentiate from sibling tools like 'gencommit' or 'genchangelog' that might also generate documentation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing commit history), when it's appropriate (e.g., after code changes), or when to choose other tools like 'gencommit' for commit messages or 'code_review' for PR feedback. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/mybolide/mcp-probe-kit'

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