AgentSkillsCN

agent-fix-ci

在本地运行 PhotoPrune 的 CI 等效检查,仅应用安全的自动修复(仅限格式化),并在需要人工干预时明确告知原因并停止。当开发者希望运行或修复 CI 检查时,或当 CI 测试失败且需要本地结果保持一致时,此技能将为您提供支持。

SKILL.md
--- frontmatter
name: agent-fix-ci
description: "Run PhotoPrune CI-equivalent checks locally, apply safe auto-fixes (formatting only), and stop with clear reasons when manual intervention is required. Use when a developer asks to run or fix CI checks, or when CI fails and local parity is needed."

Agent fix:ci

Follow the CI source of truth

  • Discover the CI steps by reading .github/workflows/ci.yml.
  • Run the exact run: commands in order, excluding setup/install-only steps.
  • Use the same working directory specified by CI.

Deterministic fix loop

  1. Run a CI-equivalent step.
  2. If it fails, classify the failure:
    • Auto-fixable: only formatting check failures.
    • Manual: anything else (lint, type check, tests, audits, build, docs guard).
  3. For auto-fixable failures, apply the minimal fix (make format) then re-run the failed step.
  4. Stop when:
    • All checks pass, or
    • A manual failure is detected, or
    • An auto-fix attempt fails.

Safety guardrails

  • Never modify CI config or weaken checks.
  • Never delete tests or change business logic to satisfy checks.
  • Do not commit changes automatically.
  • Prefer minimal, reviewable diffs.

Use the bundled scripts

  • Run node skills/agent-fix-ci/agent-fix-ci.mjs to execute the fix loop.
  • Run node skills/agent-fix-ci/agent-fix-ci.mjs --codex to emit a Codex repair capsule on non-fixable failures.
  • Reuse skills/agent-fix-ci/scripts/* for workflow parsing and loop orchestration.
  • Reuse skills/agent-utils/common/* for shared helpers.

Codex repair mode contract

  • When --codex is provided and a step is not auto-fixable, the agent emits:
    • CODEX_REPAIR_REQUIRED
    • A single-line JSON capsule describing the failure.
  • The capsule contains the failing step, failure reason, output tail, guardrails, allowed actions, and a rerun command.

Codex guardrails (automated)

  • The --codex runner tracks progress across iterations in .codex/agent-fix-ci.json.
  • Guardrails enforced between runs:
    • Max iterations: 7
    • Max files changed per iteration: 10
    • Max total lines changed per iteration: 300
    • Stop if .github/workflows/** is modified
    • Stop if the same failing step + reason repeats twice

How to use with Codex

  1. Run node skills/agent-fix-ci/agent-fix-ci.mjs --codex.
  2. When the capsule prints, Codex should propose and apply the minimal patch.
  3. Re-run the same command until all checks pass or manual intervention is required.

Expected output

  • Print each step name, command, and working directory.
  • Summarize what failed, what was fixed, and why it stopped (if it did).
  • End with:
    • PhotoPrune CI checks green — ready to commit, or
    • Stopped: manual intervention required (reason).