analyse-issue

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Analyse Issue

分析GitHub Issue

Overview

概述

Fetch the issue details, verify repo alignment, and inspect the local codebase to confirm or refute the reported problem. Provide an evidence-backed analysis with clear next steps.
获取Issue详情,验证仓库是否匹配,并检查本地代码库以确认或反驳报告的问题。提供有证据支持的分析,并给出明确的后续步骤。

Workflow

工作流程

1) Parse the issue input

1) 解析Issue输入

  • If input is a GitHub issue URL, extract owner/repo and issue number.
  • If input is just a number, assume the current repo unless the user specifies another repo.
  • If the provider is not GitHub or is unclear, ask for clarification before proceeding.
  • 如果输入是GitHub Issue URL,提取仓库所有者/仓库名和Issue编号。
  • 如果输入只是一个数字,则默认使用当前仓库,除非用户指定了其他仓库。
  • 如果来源不是GitHub或不明确,请在继续前向用户确认。

2) Verify local repo matches the issue

2) 验证本地仓库与Issue匹配

  • Ensure the current directory is inside a git repo (
    git rev-parse --show-toplevel
    ).
  • Identify the target remote (prefer
    origin
    ); normalize SSH/HTTPS to
    owner/repo
    .
  • If the issue URL repo does not match the local
    owner/repo
    , stop and ask the user to switch directories or confirm the target repo.
  • If no remote or multiple candidates exist, ask the user which repo to use.
  • 确保当前目录在git仓库内(执行
    git rev-parse --show-toplevel
    )。
  • 确定目标远程仓库(优先使用
    origin
    );将SSH/HTTPS格式统一为
    owner/repo
    格式。
  • 如果Issue URL对应的仓库与本地
    owner/repo
    不匹配,请停止操作并要求用户切换目录或确认目标仓库。
  • 如果没有远程仓库或存在多个候选仓库,请询问用户使用哪个仓库。

3) Fetch issue content

3) 获取Issue内容

Prefer
gh
when available:
  • gh issue view <num> --json title,body,labels,comments,author,createdAt,updatedAt
  • If URL provided, run against that repo:
    gh issue view <num> -R owner/repo --json ...
Fallbacks:
  • gh api repos/{owner}/{repo}/issues/{num}
    and
    .../comments
    if you need more fields.
  • If
    gh
    is unavailable but
    GITHUB_TOKEN
    exists, use
    curl
    with the GitHub API.
  • If neither works, ask the user to paste the issue content.
Capture at least: title, body, labels, environment details, repro steps, expected/actual behavior, and key comment insights.
优先使用
gh
命令(如果可用):
  • gh issue view <num> --json title,body,labels,comments,author,createdAt,updatedAt
  • 如果提供了URL,则针对该仓库执行:
    gh issue view <num> -R owner/repo --json ...
备选方案:
  • 若需要更多字段,使用
    gh api repos/{owner}/{repo}/issues/{num}
    .../comments
  • 如果
    gh
    不可用但存在
    GITHUB_TOKEN
    ,使用
    curl
    调用GitHub API。
  • 如果以上都不可行,请让用户粘贴Issue内容。
至少捕获以下信息:标题、正文、标签、环境细节、复现步骤、预期/实际行为,以及关键评论要点。

4) Analyze the codebase

4) 分析代码库

  • Translate the issue into concrete signals (keywords, error messages, stack traces, config names).
  • Use
    rg
    to locate relevant code, tests, and configs.
  • Trace the execution path: entry points -> core logic -> dependencies.
  • Identify likely failure points: missing checks, edge cases, incorrect assumptions, data shape mismatches, concurrency/timing issues.
  • If appropriate and safe, run focused tests; otherwise propose targeted tests to validate the hypothesis.
  • 将Issue内容转化为具体的信号(关键词、错误信息、堆栈跟踪、配置名称)。
  • 使用
    rg
    定位相关代码、测试和配置文件。
  • 追踪执行路径:入口点 -> 核心逻辑 -> 依赖项。
  • 识别可能的故障点:缺失的检查、边缘情况、错误的假设、数据结构不匹配、并发/时序问题。
  • 如果合适且安全,运行针对性测试;否则建议通过针对性测试来验证假设。

5) Confirm or qualify the issue

5) 确认或限定Issue

  • Provide evidence with file references and reasoning.
  • If you can only reason without running tests, state assumptions and confidence.
  • If evidence is insufficient, list the exact missing info needed.
  • 提供带有文件引用和推理过程的证据。
  • 如果只能通过推理无法运行测试,请说明假设和置信度。
  • 如果证据不足,列出确切需要补充的信息。

6) Respond with a structured analysis

6) 返回结构化分析结果

Include:
  • Issue summary (expected vs actual)
  • Repo match verification
  • Evidence (files/functions)
  • Root-cause hypothesis or confirmed cause
  • Suggested fix approach
  • Questions or missing data
  • Next steps (tests, logs, repro)
包含:
  • Issue摘要(预期 vs 实际情况)
  • 仓库匹配验证结果
  • 证据(文件/函数)
  • 根因假设或已确认的原因
  • 建议的修复方案
  • 问题或缺失的数据
  • 后续步骤(测试、日志、复现)

Output conventions

输出规范

  • Respond in the user's language when clear; default to Chinese for Chinese prompts.
  • Keep analysis concise but include concrete file pointers and evidence.
  • Do not claim confirmation without code-based evidence or reproduction.
  • 若明确用户使用的语言,则用该语言回复;对于中文提示,默认使用中文回复。
  • 分析内容保持简洁,但需包含具体的文件指向和证据。
  • 没有基于代码的证据或复现结果时,不要声称已确认问题。