ci-analyze

分析 CI 失败原因并给出修复建议。在用户提到 CI 失败、pipeline 失败、构建失败、测试失败时使用。典型场景:PR 合前 CI 红、需要根因与修复建议时。

151 stars

Best use case

ci-analyze is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

分析 CI 失败原因并给出修复建议。在用户提到 CI 失败、pipeline 失败、构建失败、测试失败时使用。典型场景:PR 合前 CI 红、需要根因与修复建议时。

Teams using ci-analyze should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ci-analyze/SKILL.md --create-dirs "https://raw.githubusercontent.com/qiniu/go-sdk/main/.agents/skills/ci-analyze/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ci-analyze/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ci-analyze Compares

Feature / Agentci-analyzeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

分析 CI 失败原因并给出修复建议。在用户提到 CI 失败、pipeline 失败、构建失败、测试失败时使用。典型场景:PR 合前 CI 红、需要根因与修复建议时。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# CI 失败分析

开始时声明:"我正在使用 ci-analyze skill 分析 CI 失败原因。"

## 项目 CI 概览

本项目使用 GitHub Actions(`.github/workflows/ci-test.yml`),CI 流程:

1. **gofmt 检查**(仅 stable):`gofmt -s -l .` 检查未格式化文件
2. **staticcheck**(仅 stable):`make staticcheck`
3. **编译 examples**(仅 stable):`go build ./examples/...`
4. **单元测试**(Go 1.22 + stable):`make unittest`
5. **Windows 单元测试**:Linux 通过后运行
6. **macOS 单元测试**:Windows 通过后运行

## 何时不要使用(Do NOT use)

- 用户仅请求"实现功能/改代码",且未提供任何 CI 失败上下文。
- CI 状态为全部通过,仅需常规代码审查或功能验证。

## 触发样例与非样例

- 应触发:
- "这个 PR 的 CI 红了,帮我定位根因并给修复建议。"
- "pipeline failed,给我一份失败分析报告。"
- 不应触发:
- "帮我实现这个接口并补测试。"
- "帮我 review 这个 PR。"

## 使用示例

```bash
# 按 PR 编号分析
ci-analyze 123

# 按 run URL 分析
ci-analyze https://github.com/qiniu/go-sdk/actions/runs/999999
```

## 核心原则

1. 每个失败都视为潜在真实 bug,不要轻易归因为 infra flakiness
2. 必须给出根因和修复建议,不能只收集日志不给结论
3. 分析所有失败,不只是第一个

## 执行流程

### 步骤 1:获取失败列表

```bash
# 获取 PR 的 CI checks
gh pr checks <PR编号> --repo qiniu/go-sdk

# 或获取最近一次 workflow run 的失败
gh run list --repo qiniu/go-sdk --branch <branch> --limit 5
gh run view <run-id> --repo qiniu/go-sdk --log-failed
```

获取 CI 状态概览:

```bash
gh pr view <PR编号> --repo qiniu/go-sdk \
  --json statusCheckRollup \
  --jq '.statusCheckRollup[]? | {name: .context, state: .state, url: .targetUrl}'
```

### 步骤 2:获取失败日志

```bash
# GitHub Actions 失败日志
gh run view <run-id> --repo qiniu/go-sdk --log-failed
```

### 步骤 3:分析每个失败

对每个失败的 check/job:

1. 获取完整错误日志
2. 定位失败的测试或步骤
3. 在代码中找到对应位置
4. 检查 git blame 看最近改动
5. 判断根因类别:
   - regression:我们的代码改动导致
   - flaky:间歇性基础设施问题(需要证据:同一测试在 3+ 次其他运行中通过)
   - environment:配置或依赖问题
   - format:gofmt 或 staticcheck 不通过

### 步骤 4:输出分析报告

- 失败汇总表:最多列出 20 条,超出用「其余见日志」概括。
- 详细分析:每项「根因分析 + 修复建议」合计不超过 300 字;只保留值得写的项。

```plaintext
## CI 失败分析报告

### 失败汇总

| 序号 | 测试/Job | 错误类型 | 根因 | 置信度 |
|------|----------|----------|------|--------|
| 1    | ...      | ...      | ...  | 高/中/低 |

### 详细分析

#### 失败 1: <测试名>

错误信息:
<具体错误日志>

日志来源:
<GitHub Actions URL 或 API 端点>

根因分析:
<分析过程>

修复建议:
<具体修复方案>

相关代码:
<文件路径:行号>
```

### 步骤 5:提出修复方案

- 对于 regression 类型:给出具体代码修复
- 对于 flaky 类型:说明判断依据,建议重跑或标记 flaky
- 对于 environment 类型:说明配置修复方案
- 对于 format 类型:运行 `gofmt -s -w .` 或修复 staticcheck 报告的问题

## 常见失败模式(本项目特有)

| 失败类型 | 典型表现 | 修复方式 |
|----------|----------|----------|
| gofmt | "Files not formatted" | `gofmt -s -w .` |
| staticcheck | SA/S/ST 开头的错误码 | 按 staticcheck 建议修复 |
| examples 编译 | `go build ./examples/...` 失败 | 检查 examples 依赖的包是否有 breaking change |
| 单元测试 | `FAIL` + 具体测试函数名 | 定位测试代码和被测代码 |
| Windows/macOS | 平台相关路径、换行符问题 | 使用 `filepath.Join` 等跨平台写法 |

## 判断 flaky 的证据要求

只有满足以下条件才能判定为 flaky:

1. 同一测试在同一分支的最近 3+ 次运行中至少有 1 次通过
2. 错误信息显示明确的基础设施问题(网络超时、资源不足等)
3. 代码路径没有最近改动

```bash
# 检查历史运行
gh run list --repo qiniu/go-sdk --branch <branch> --workflow "Run Test Cases" --limit 10
```

## 禁止事项

- 不要在没有证据的情况下说"可能是 flaky"
- 不要只列出失败不给结论
- 不要忽略任何一个失败

## 验收标准(统一)

- 输入前提:参数与上下文可解析;缺省参数按 skill 默认值执行,并在输出中注明。
- 产出要求:按 skill 约定的输出模板给出结果,并包含关键证据(命令、路径、链接或日志摘要)。
- 通过判定:主流程步骤已完成且无阻塞;若有未完成项,必须明确标注影响范围与下一步。
- 默认策略(非交互):需要确认但用户未及时响应时,采用"推荐默认值/最小风险项"继续;需要交互选择时优先推荐项。
- 阻塞升级:遇到权限、凭证、外部依赖缺失时立即停止该步骤,输出"阻塞点 + 已尝试 + 需要用户提供的信息"。

## 系统规范(AGENTS.md)

执行本 skill 时同时遵守 `AGENTS.md` 中的系统规范;与本 skill 冲突时以本 skill 为准。

Related Skills

release-check

151
from qiniu/go-sdk

检查发布版本号是否在三处保持一致(conf/conf.go、CHANGELOG.md、README.md)。在准备发布新版本时使用。

git-commit

151
from qiniu/go-sdk

遵循 Angular 规范生成 git commit 消息。在用户请求创建 commit、写 commit message 或暂存并提交时使用。典型场景:改完代码要提交前、或要求按 Angular 规范写 message 时。

gh-view

151
from qiniu/go-sdk

分析 GitHub issues、PRs 与 discussions,提供见解或实施指导。在用户提供 GitHub URL、issue/PR 编号或询问仓库内容时使用。典型场景:看 issue/PR 状态、拉 diff 与 checks、要结论与建议下一步时。

gen

151
from qiniu/go-sdk

运行代码生成并检查变更。在修改 API 规范(api-specs/ YAML)或 sandbox OpenAPI/protobuf 后使用。

check

151
from qiniu/go-sdk

运行提交前检查:代码格式化验证、静态检查和单元测试。在准备提交代码、检查代码质量或验证修改是否通过时使用。

mental-health-analyzer

31392
from sickn33/antigravity-awesome-skills

分析心理健康数据、识别心理模式、评估心理健康状况、提供个性化心理健康建议。支持与睡眠、运动、营养等其他健康数据的关联分析。

Wellness & HealthClaude

health-trend-analyzer

31392
from sickn33/antigravity-awesome-skills

分析一段时间内健康数据的趋势和模式。关联药物、症状、生命体征、化验结果和其他健康指标的变化。识别令人担忧的趋势、改善情况,并提供数据驱动的洞察。当用户询问健康趋势、模式、随时间的变化或"我的健康状况有什么变化?"时使用。支持多维度分析(体重/BMI、症状、药物依从性、化验结果、情绪睡眠),相关性分析,变化检测,以及交互式HTML可视化报告(ECharts图表)。

Health & WellnessClaude

fitness-analyzer

31392
from sickn33/antigravity-awesome-skills

分析运动数据、识别运动模式、评估健身进展,并提供个性化训练建议。支持与慢性病数据的关联分析。

Fitness & HealthClaude

family-health-analyzer

31392
from sickn33/antigravity-awesome-skills

分析家族病史、评估遗传风险、识别家庭健康模式、提供个性化预防建议

Health & FitnessClaude

Profit Margin Analyzer

3891
from openclaw/skills

Analyze and optimize profit margins across your business. Identifies margin compression, pricing opportunities, and cost levers.

Pricing Strategy Analyzer

3891
from openclaw/skills

Analyze and optimize pricing for any product or service. Covers value-based, cost-plus, competitive, and tiered pricing models.

Business Strategy & Growth

Portfolio Risk Analyzer

3891
from openclaw/skills

Complete investment portfolio risk management system. Analyze positions, calculate risk metrics, stress test scenarios, optimize allocations, and generate institutional-grade risk reports — all without external APIs.

Finance & Investing