resolve-ci-failures
Analyze and fix CI check failures on a PR. Use when CI checks fail, build errors occur, or tests fail in CI. Invoked automatically by the SDLC workflow (Step 7.4) when checks fail, or manually via 'resolve CI failures', 'fix CI', 'fix failing checks'.
What this skill does
# Resolve CI Failures
Meta-skill that analyzes failing CI checks on a PR, fetches failure logs, categorizes failures, and delegates fixes via the coder skill.
## WHEN TO USE THIS SKILL
**USE THIS SKILL** when ANY of the following occur:
- SDLC Step 7.4 invokes it after `wait-for-ci-checks.sh` exits with code 1
- User says "resolve CI failures" / "fix CI" / "fix failing checks" / "fix the build"
- CI checks are red and fixes need to be coordinated
- After pushing code to a PR when checks fail
## Prerequisites
**CRITICAL: Load the `fx-dev:github` skill FIRST** before running any GitHub API operations.
## CRITICAL RULES
- ❌ NEVER skip or disable tests to make CI pass (`test.skip`, `it.skip`, `describe.skip` are FORBIDDEN)
- ❌ NEVER suppress lint errors with ignore comments unless truly justified and explained
- ❌ NEVER leave comments directly on the GitHub PR
- ❌ NEVER retry a check without pushing a fix first
- ✅ ALWAYS fix root causes, not symptoms
- ✅ ALWAYS push changes after fixing
- ✅ ALWAYS report infrastructure failures to user — do not attempt to fix them
## Core Workflow
### 0. Check for Base-Branch Conflicts FIRST (when CI isn't running)
**GitHub Actions does NOT trigger CI on PRs that have merge conflicts with their base branch.** If the PR shows no checks, missing checks, or checks stuck in `Expected` / never firing after a push, verify this *before* any other CI debugging:
```bash
gh pr view [PR_NUMBER] --json mergeable,mergeStateStatus -q '{mergeable, mergeStateStatus}'
```
- `mergeable: "CONFLICTING"` or `mergeStateStatus: "DIRTY"` → CI is blocked by conflicts, not by code or workflow problems.
- **Fix:** rebase the branch onto the latest base and force-push:
```bash
git fetch origin
git rebase origin/[BASE_BRANCH]
# resolve any conflicts, then:
git push --force-with-lease
```
- After the conflict is cleared, CI will fire automatically. Only then proceed with the failure-analysis steps below.
Do not start fetching `gh run` logs, inspecting workflow YAML, or delegating fixes until you have ruled out a base-branch conflict.
### 1. Determine PR Number
If not provided, get from current branch:
```bash
gh pr view --json number,headRefName -q '.number'
```
### 2. Get Failing Check Details
Query the PR for failed checks:
```bash
gh pr checks [PR_NUMBER] --json name,state,conclusion
```
Filter for checks with conclusion `FAILURE`, `CANCELLED`, `TIMED_OUT`, or `ACTION_REQUIRED`.
### 3. Fetch Failure Logs
For each failing check, fetch detailed logs to understand the root cause.
**Step 3a: Get the head SHA and repo info:**
```bash
gh pr view [PR_NUMBER] --json headRefOid,headRefName -q '.headRefOid'
```
**Step 3b: Get check run IDs for failing checks:**
**IMPORTANT:** Use inline values, NOT `$variable` syntax. The `$` character causes shell escaping issues.
```bash
# Replace OWNER, REPO, SHA with actual values
gh api repos/OWNER/REPO/commits/SHA/check-runs --jq '.check_runs[] | select(.conclusion == "failure") | {name: .name, id: .id}'
```
**Step 3c: Fetch annotations (structured error details):**
```bash
# Replace OWNER, REPO, CHECK_RUN_ID with actual values
gh api repos/OWNER/REPO/check-runs/CHECK_RUN_ID/annotations
```
**Step 3d: Fetch GitHub Actions workflow run logs (if applicable):**
```bash
# List failed workflow runs for the branch
gh run list --branch [BRANCH] --json databaseId,name,conclusion --jq '.[] | select(.conclusion == "failure")'
# View the failed run's log output (truncated to failed steps)
gh run view [RUN_ID] --log-failed
```
**⚠️ NOTE:** `gh run view --log-failed` can produce very large output. If the output is too large, try fetching specific job logs:
```bash
# List jobs in the run
gh run view [RUN_ID] --json jobs --jq '.jobs[] | select(.conclusion == "failure") | {name: .name, id: .databaseId}'
# View a specific job's log
gh api repos/OWNER/REPO/actions/jobs/JOB_ID/logs
```
### 4. Categorize Each Failure
| Category | Indicator | Action |
|----------|-----------|--------|
| **Test failure** | Test runner output, assertion errors, `FAIL` in test logs | Delegate to coder to fix test or code |
| **Build error** | Compilation errors, missing deps, `tsc` errors, module not found | Delegate to coder to fix build |
| **Lint/Format error** | ESLint, Prettier, stylelint, `--fix` suggestions | Delegate to coder to run formatter/fix lint |
| **Security scan** | Vulnerability alerts, `npm audit`, Dependabot | Delegate to coder to update deps or fix |
| **Flaky test** | Test passed locally, intermittent failure, no code change caused it | Note as flaky — may pass on re-run without changes |
| **Infrastructure** | Runner errors, timeout, network failures, Docker pull errors | Report to user — not fixable by code changes |
### 5. Delegate Fixes
For each fixable failure, launch a sub-agent with the coder skill:
```
Agent tool:
prompt: "Load the coder skill (Skill tool: skill='fx-dev:coder'), then:
Fix the following CI failure on PR #[NUMBER]:
Check name: [CHECK_NAME]
Conclusion: [CONCLUSION]
Error details:
[LOGS/ANNOTATIONS FROM STEP 3]
- Analyze the error and fix the root cause
- Do NOT suppress errors or skip tests
- Commit with format: fix(ci): description
- Push changes after committing"
description: "Fix CI failure: [CHECK_NAME]"
```
If multiple checks failed with independent root causes, delegate fixes for ALL of them. Sequential delegation is preferred to avoid merge conflicts.
### 6. Push Changes
Verify all fixes are committed and pushed:
```bash
git status
git push
```
If the coder sub-agent already pushed, verify with:
```bash
git log --oneline -3
gh pr view [PR_NUMBER] --json commits --jq '.commits[-1].oid'
```
### 7. Verify Fix Was Pushed
Confirm the latest commit on the PR includes the fix:
```bash
# Local HEAD should match the PR's head
git rev-parse HEAD
gh pr view [PR_NUMBER] --json headRefOid -q '.headRefOid'
```
If they differ, push is needed:
```bash
git push
```
## Output Format
```
## CI Failure Resolution — PR #123
### Failing Checks Detected
- tests (FAILURE)
- lint (FAILURE)
- deploy (TIMED_OUT)
### Resolution
| Check Name | Category | Action Taken | Status |
|------------|----------|--------------|--------|
| tests | Test failure | Fixed assertion in foo.test.ts | ✅ Fixed |
| lint | Lint error | Ran prettier, fixed imports | ✅ Fixed |
| deploy | Infrastructure | Runner timeout — not code-related | ⚠️ Reported |
### Next Steps
- Fixes pushed. SDLC workflow will re-run wait-for-ci-checks.sh to verify.
- Infrastructure issue (deploy): Requires manual intervention or re-run.
```
## Success Criteria
1. ✅ All fixable CI failures analyzed and root causes identified
2. ✅ Fixes delegated via coder skill and committed
3. ✅ Changes pushed to PR branch
4. ✅ Summary table output with categories and actions
5. ✅ Non-fixable failures (infrastructure/flaky) clearly reported to user
## Error Handling
- If no PR found: Ask user for PR number
- If coder sub-agent fails to fix: Report the failure with full context including logs
- If failure is infrastructure-related: Report to user, do not attempt fix
- If check logs cannot be fetched: Use check name and conclusion to infer the issue, delegate to coder with available context
- If `gh run view --log-failed` is too large: Fetch individual job logs instead
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.