CI Job 失败分析知识库,包含失败类型分类、置信度评估、技术栈识别和常见错误模式
Analyzes CI job failures using a knowledge base of error patterns, failure types, and confidence scoring. Triggers when a CI job fails to classify the failure, identify the root cause, and suggest targeted fixes.
/plugin marketplace add penkzhou/swiss-army-knife-plugin/plugin install swiss-army-knife@swiss-army-knife-pluginThis skill inherits all available tools. When active, it can use any tool Claude has access to.
本知识库提供 GitHub Actions Job 失败分析和修复的专业知识。
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| unit_test | 45% | pytest FAILED, jest FAIL, vitest | 是 |
| integration_test | 30% | integration, api test, mock server | 是 |
| snapshot_test | 15% | snapshot, toMatchSnapshot | 是 |
| other_test | 10% | 其他测试框架 | 部分 |
注意:频率数据基于历史统计,总和为 100%。
常见根因:
修复策略:
1. 定位失败测试和断言
2. 比较期望值 vs 实际值
3. 追踪数据流到源头
4. 更新 mock 或修复断言
5. 验证修复
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| timeout | 35% | Timeout, 30000ms, waiting for | 是 |
| selector | 30% | strict mode, not found, resolved to | 是 |
| assertion | 20% | expect().toHave, toBeVisible | 是 |
| network | 15% | Route handler, net::ERR | 部分 |
常见根因:
修复策略:
1. 分析超时/选择器错误的具体位置
2. 检查 UI 是否变更
3. 添加适当的等待策略
4. 更新选择器或断言
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| typescript | 45% | tsc, error TS, compile | 部分 |
| webpack | 20% | webpack, Module not found | 部分 |
| python | 20% | SyntaxError, ModuleNotFound | 部分 |
| other | 15% | build failed, make error | 否 |
常见根因:
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| eslint | 50% | eslint, @typescript-eslint | 是 |
| ruff | 25% | ruff, E501, W503 | 是 |
| prettier | 20% | prettier, formatting | 是 |
| other | 5% | mypy, pylint | 部分 |
快速修复路径:
# ESLint
npx eslint --fix {files}
# Ruff
ruff check --fix {files}
# Prettier
npx prettier --write {files}
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| typescript | 70% | tsc --noEmit, error TS | 部分 |
| mypy | 30% | mypy, type: ignore | 部分 |
常见错误类型:
| 错误码 | 描述 | 自动修复 |
|---|---|---|
| TS2345 | 参数类型不匹配 | 否 |
| TS2322 | 类型赋值错误 | 否 |
| TS2339 | 属性不存在 | 否 |
| TS7006 | 隐式 any | 是 |
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| npm | 40% | npm install, ERESOLVE | 否 |
| pip | 35% | pip install, requirement | 否 |
| yarn | 15% | yarn, resolution | 否 |
| other | 10% | pnpm, poetry | 否 |
常见问题:
建议:依赖问题通常需要手动处理,因为涉及版本策略决策。
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| env | 50% | env, secret, KEY_ERROR | 否 |
| permission | 30% | permission denied, 403 | 否 |
| config_file | 20% | config, settings | 否 |
不可自动修复原因:涉及敏感信息和权限配置,需要人工处理。
| 子类型 | 频率 | 关键信号 | 可自动修复 |
|---|---|---|---|
| runner | 40% | runner, self-hosted | 否 |
| resource | 35% | OOM, killed, disk | 否 |
| network | 25% | network, timeout | 否 |
不可自动修复原因:涉及 CI 基础设施,需要运维处理。
| 因素 | 权重 | 描述 |
|---|---|---|
| 信号明确性 | 40% | 错误信号是否清晰明确 |
| 文件定位 | 30% | 是否能定位到具体文件和行号 |
| 模式匹配 | 20% | 是否匹配已知错误模式 |
| 上下文完整 | 10% | 是否有完整的堆栈追踪 |
| 分数 | 级别 | 行为 |
|---|---|---|
| >= 80 | 高 | 自动修复 |
| 60-79 | 中 | 询问用户后修复 |
| 40-59 | 低 | 展示分析,建议手动 |
| < 40 | 极低 | 跳过 |
提升条件:
降低条件:
backend:
patterns:
- "**/*.py"
- "tests/backend/**"
- "tests/unit/**"
- "src/api/**"
- "app/**"
signals:
- "pytest"
- "FastAPI"
- "Django"
- "Python"
frontend:
patterns:
- "**/*.tsx"
- "**/*.jsx"
- "**/*.ts"
- "tests/frontend/**"
- "src/components/**"
signals:
- "jest"
- "vitest"
- "React"
- "Vue"
e2e:
patterns:
- "e2e/**"
- "tests/e2e/**"
- "playwright/**"
- "cypress/**"
signals:
- "playwright"
- "cypress"
- "puppeteer"
当检测到多个技术栈时:
secondary_stack# 断言失败
FAILED tests/test_xxx.py::test_name - AssertionError: assert X == Y
# 异常未捕获
FAILED tests/test_xxx.py::test_name - ExceptionType: message
# fixture 错误
ERROR tests/test_xxx.py::test_name - fixture 'xxx' not found
# 导入错误
ERROR tests/test_xxx.py - ModuleNotFoundError: No module named 'xxx'
# 断言失败
FAIL src/xxx.test.ts
✕ test name (123ms)
expect(received).toBe(expected)
# 超时
FAIL src/xxx.test.ts
✕ test name (5001ms)
Timeout - Async callback was not invoked within 5000ms
# 快照失败
FAIL src/xxx.test.ts
✕ test name
expect(received).toMatchSnapshot()
# 超时
Error: locator.click: Timeout 30000ms exceeded.
waiting for locator('selector')
# 选择器问题
Error: locator.click: Error: strict mode violation:
locator('selector') resolved to 2 elements
# 断言失败
Error: expect(locator).toBeVisible()
Locator expected to be visible
# 类型不匹配
error TS2345: Argument of type 'X' is not assignable to parameter of type 'Y'
# 属性不存在
error TS2339: Property 'xxx' does not exist on type 'Y'
# 隐式 any
error TS7006: Parameter 'xxx' implicitly has an 'any' type
| 失败类型 | 修复方式 | 关联工作流 |
|---|---|---|
| test_failure (backend) | bugfix_workflow | /fix-backend |
| test_failure (frontend) | bugfix_workflow | /fix-frontend |
| e2e_failure | bugfix_workflow | /fix-e2e |
| lint_failure | quick_fix | 直接运行 lint --fix |
| type_check_failure | bugfix_workflow | 对应栈工作流 |
| build_failure | bugfix_workflow | 对应栈工作流 |
| dependency_failure | manual | 无 |
| config_failure | manual | 无 |
| infrastructure_failure | manual | 无 |
def calculate_similarity(current, historical):
score = 0
# 错误类型匹配 (30%)
if current.failure_type == historical.failure_type:
score += 30
# 文件路径匹配 (25%)
file_overlap = len(set(current.files) & set(historical.files))
score += min(25, file_overlap * 5)
# 错误消息相似 (25%)
message_similarity = text_similarity(current.error, historical.error)
score += message_similarity * 25
# 修复模式相似 (20%)
if current.suggested_fix_type == historical.fix_type:
score += 20
return score
值得记录为历史案例的修复:
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.