modu-ai/moai-adk/.claude/skills/hns-workflow-ci-loop/SKILL.md
hns-workflow-ci-loop
Unified CI watch + auto-fix loop skill. Polls gh pr checks after /moai sync PR creation, classifies required vs auxiliary failures, attempts safe automated patches (max 3 iterations), and escalates semantic failures to the user. Use for CI loop workflow — NOT for general loop iteration patterns (see moai-workflow-loop).
- Source repository stars
- 1,186
- Declared platforms
- 1
- Static risk flags
- 1
- Last source update
- 2026-08-25
- Source checked
- 2026-08-25
Decision brief
What it does: where it fits
Unified CI watch + auto-fix loop. The orchestrator invokes this skill after /moai sync Phase 4 (gh pr create) returns a PR number. The skill polls required checks, classifies failures into mechanical vs semantic, attempts safe patches up to 3 iterations, and escalates semantic f…
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Declared | Source record | Install path and trigger |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/modu-ai/moai-adk --skill ".claude/skills/hns-workflow-ci-loop"Inspect the Agent Skill "hns-workflow-ci-loop" from https://github.com/modu-ai/moai-adk/blob/a739d04b40e64f9ca7852b66c8fd6edc927a25aa/.claude/skills/hns-workflow-ci-loop/SKILL.md at commit a739d04b40e64f9ca7852b66c8fd6edc927a25aa. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
Implementation Guide
Polling cadence: 30 seconds minimum (GitHub API rate-limit). Override via CIWATCHPOLLINTERVAL env, never below 30 in production. Test mode uses MOAICIWATCHNOSLEEP=1 (single-tick exit).
iter 1, any mechanical subclass → confirm + apply via AskUserQuestion (1st option =iter 1, semantic/unknown → escalate (no patch attempt) via AskUserQuestion withiter 2-3, mechanical + subclass=trivial → silent apply + log (no AskUserQuestion). - 02
Phase 1 — Watch Loop
Polling cadence: 30 seconds minimum (GitHub API rate-limit). Override via CIWATCHPOLLINTERVAL env, never below 30 in production. Test mode uses MOAICIWATCHNOSLEEP=1 (single-tick exit).
Polling cadence: 30 seconds minimum (GitHub API rate-limit). Override via CIWATCHPOLLINTERVAL env, never below 30 in production. Test mode uses MOAICIWATCHNOSLEEP=1 (single-tick exit).30-minute hard timeout: CIWATCHTIMEOUTSECONDS=1800 default. On timeout, exit 3. Do not auto-restart.Required vs auxiliary: Required checks live in .github/required-checks.yml branches..contexts. Auxiliary checks listed under auxiliary: MUST NOT block ready-to-merge. Hardcoding check names in scripts is prohibited. - 03
Phase 2 — Auto-Fix Loop
Entry condition: ci-watch exit 2 + valid JSON handoff. State file: .moai/state/ci-autofix-.json (PR-scoped, 24-hour staleness threshold).
iter 1, any mechanical subclass → confirm + apply via AskUserQuestion (1st option =iter 1, semantic/unknown → escalate (no patch attempt) via AskUserQuestion withiter 2-3, mechanical + subclass=trivial → silent apply + log (no AskUserQuestion). - 04
Verification
[ ] bash scripts/ci-watch/test/runtest.sh passes all shell tests
[ ] bash scripts/ci-watch/test/runtest.sh passes all shell tests[ ] go test ./internal/ciwatch/... ./internal/cli/pr/... -race passes[ ] internal/ciwatch/ coverage = 85% - 05
Quick Reference
Trigger: /moai sync Phase 4 PR-create returns a PR number, or an existing PR needs CI monitoring.
Watch — Poll gh pr checks every 30s, classify required vs auxiliary viaAuto-fix — On required-fail (exit 2), receive JSON handoff, run up to 3 patch0 — all required passed → ready-to-merge AskUserQuestion
Permission review
Static risk signals and limitations
Runs scripts
The documentation asks the agent to run terminal commands or scripts.
`EmitFailureHandoff`). Shell: `scripts/ci-watch/run.sh` (mainEvidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 92/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 1,186 | Source | Repository attention, not individual Skill quality |
| Compatibility | 1 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- modu-ai/moai-adk
- Skill path
- .claude/skills/hns-workflow-ci-loop/SKILL.md
- Commit
- a739d04b40e64f9ca7852b66c8fd6edc927a25aa
- License
- Apache-2.0
- Collected
- 2026-08-25
- Default branch
- main
View the original SKILL.md
CI Loop (hns-workflow-ci-loop)
Unified CI watch + auto-fix loop. The orchestrator invokes this skill after /moai sync
Phase 4 (gh pr create) returns a PR number. The skill polls required checks, classifies
failures into mechanical vs semantic, attempts safe patches up to 3 iterations, and
escalates semantic failures via AskUserQuestion.
Quick Reference
Trigger: /moai sync Phase 4 PR-create returns a PR number, or an existing PR needs
CI monitoring.
Two phases, one skill:
- Watch — Poll
gh pr checksevery 30s, classify required vs auxiliary via.github/required-checks.ymlSSoT; exit on green/fail/timeout. - Auto-fix — On required-fail (exit 2), receive JSON handoff, run up to 3 patch iterations, escalate semantic failures immediately.
One-liner:
MOAI_CIWATCH_GH=gh sh scripts/ci-watch/run.sh <PR_NUMBER> <BRANCH>
Exit codes:
0— all required passed → ready-to-merge AskUserQuestion1— fatal error → surface remediation2— required failure → JSON handoff → auto-fix phase3— 30-min hard timeout → blocker message, return control
HARD invariants:
- AskUserQuestion is orchestrator-only — CLI, shell scripts, and the
manager-develop(cycle_type=autofix) subagent MUST NOT call it. - Force-push is absolutely prohibited (
--force,-f,--force-with-leaseall banned). - Max 3 auto-fix iterations; iteration 4+ triggers mandatory blocking AskUserQuestion.
- Semantic failures (race, deadlock, panic, assertion) are never auto-patched.
- Protected files:
.env*, credentials,.claude/settings*.json,.github/required-checks.yml,scripts/ci-watch/run.sh.
Implementation Guide
Phase 1 — Watch Loop
Polling cadence: 30 seconds minimum (GitHub API rate-limit). Override via
CIWATCH_POLL_INTERVAL env, never below 30 in production. Test mode uses
MOAI_CIWATCH_NO_SLEEP=1 (single-tick exit).
30-minute hard timeout: CIWATCH_TIMEOUT_SECONDS=1800 default. On timeout, exit 3.
Do not auto-restart.
Required vs auxiliary: Required checks live in .github/required-checks.yml
branches.<pattern>.contexts. Auxiliary checks listed under auxiliary: MUST NOT block
ready-to-merge. Hardcoding check names in scripts is prohibited.
State file: .moai/state/ci-watch-active.flag (YAML). Tracks pr_number, started_at,
heartbeat_at, required_checks, abort_requested. Heartbeat staleness > 90s allows
takeover. Abort: moai pr watch --abort.
Background watch standardization: For long-running PRs (5+ min), use
gh pr checks <PR> --watch invoked via run_in_background: true. Sleep + poll loops are
prohibited — they block the orchestrator's main session.
Status report format (stderr, state-change ticks only, no ANSI):
[ci-watch] PR #<N>: required 4/6 pass, 2 pending; advisory 0 fail
Handoff schema on exit 2 — JSON with stable fields: prNumber, branch,
failedChecks[] (each entry {name, runId, logUrl}), auxiliaryFailCount,
totalRequired. Field stability: name, runId, logUrl are stable contract — do not
rename. Schema source: the CI-watch handoff struct.
Phase 2 — Auto-Fix Loop
Entry condition: ci-watch exit 2 + valid JSON handoff. State file:
.moai/state/ci-autofix-<PR>.json (PR-scoped, 24-hour staleness threshold).
OQ2 cadence matrix (single source of truth for iteration behavior):
- iter 1, any mechanical sub_class → confirm + apply via AskUserQuestion (1st option = "Apply patch (Recommended)").
- iter 1, semantic/unknown → escalate (no patch attempt) via AskUserQuestion with diagnosis report.
- iter 2-3, mechanical + sub_class=trivial → silent apply + log (no AskUserQuestion).
- iter 2-3, mechanical + sub_class=non-trivial → confirm + apply via AskUserQuestion.
- iter 2-3, semantic/unknown → escalate (no patch) via AskUserQuestion.
- iter 4+ → mandatory blocking AskUserQuestion (no timer, options: manual fix / revise SPEC / abandon PR).
"trivial" = whitespace, gofmt/goimports, import-order (matches classify.sh RX_TRIVIAL_*).
Patch commit rule: Every patch = new commit. Format:
fix(ci): auto-fix <classification> failure (iter <N>). After push, re-invoke
scripts/ci-watch/run.sh to restart the watch loop.
Iteration 4+ escalation (mandatory blocking, no silent timeout):
- (Recommended) Manual fix — investigate and fix manually
- Revise SPEC — revise the SPEC and restart implementation
- Abandon PR — close the PR and abandon this approach
manager-develop (cycle_type=autofix) spawn prompt injects: handoff JSON, classification + sub_class,
failed CI log + PR diff, mode directive (mechanical → propose unified-diff patch;
semantic/unknown → return diagnosis only, no patch). HARD: no AskUserQuestion call from
the subagent — return Markdown only.
Audit log: .moai/logs/ci-autofix/<PR-NNN>-<YYYY-MM-DD>.md. Append-only. Each
iteration records classification, sub_class, action, patch_sha, escalation_reason.
Protected Files (never auto-modified)
**/.env,**/.env.***/credentials*,**/*_key.json,**/*secret*.claude/settings.json,.claude/settings.local.json.github/required-checks.yml(Wave 1 SSoT, read-only for Wave 2/3)scripts/ci-watch/run.sh(Wave 2 invariant)
If the manager-develop (cycle_type=autofix) subagent proposes a patch touching any of these, reject and escalate.
Go Helpers and Shell Scripts
Go helpers: the CI-watch classifier (required-vs-auxiliary), the handoff JSON-schema
struct, the watch state file, and the PR-watch report emitters (EmitReadyToMergeReport,
EmitFailureHandoff). Shell: scripts/ci-watch/run.sh (main
loop, mock via MOAI_CIWATCH_GH); scripts/ci-watch/lib/classify.sh (yq + grep
fallback); scripts/ci-autofix/log-fetch.sh (failure log + PR diff);
scripts/ci-autofix/classify.sh (mechanical vs semantic).
gh CLI compat: requires gh >= 2.50 for the workflow JSON field. On older gh,
classify.sh falls back to name-based heuristics from the required: list.
Works Well With
-
manager-develop(cycle_type=autofix) — failure diagnosis + patch proposal subagent -
manager-git— commit/push of auto-fix patches -
.claude/rules/local/ci-watch-protocol.md— HARD watch invocation contract (dev-only; governsscripts/ci-watch/) -
.claude/rules/local/ci-autofix-protocol.md— HARD autofix invocation contract (dev-only; governsscripts/ci-autofix/)Both are the dev-repo twins, not the distributed rules of the same basename. The distributed
.claude/rules/moai/workflow/ci-autofix-protocol.mdis deliberately script-free and governs themanager-developautofix cycle instead; it does not describe the scripts this skill runs.ci-watch-protocol.mdis not distributed at all. -
.github/required-checks.yml— Wave 1 SSoT
Common Rationalizations
- "Skip watch loop for small PRs" — small PRs fail CI too. Loop costs nothing, saves manual polling.
- "Auxiliary failures should block merge" — advisory by SSoT definition. Edit
required-checks.ymlto change classification. - "Try auto-patching even semantic failures" — semantic failures (race, assertion) cannot be auto-patched without context; wrong patch is worse.
- "Clean up history with force-push" — force-push destroys reviewer diff visibility. Always a new commit.
- "Time out after iter 3" — silent timeout prohibited; user must decide explicitly.
- "Apply trivial fixes without confirming" — iter 1 always confirms; iter 2+ trivial may silent apply.
Red Flags
manager-develop(cycle_type=autofix) subagent calls AskUserQuestion (HARD: orchestrator-only)- Iteration 4 auto-continues without blocking AskUser
git push --force/-f/--force-with-leaseanywhere in scripts- Semantic classification produces a patch attempt
- State file missing → iteration counter lost → infinite loop risk
- Watch polling interval < 30s (rate-limit risk)
required-checks.ymlmodified withoutmoai github initre-run
Verification
-
bash scripts/ci-watch/test/run_test.shpasses all shell tests -
go test ./internal/ciwatch/... ./internal/cli/pr/... -racepasses -
internal/ciwatch/coverage >= 85% - No ANSI codes in
FormatStatusUpdate()output -
EmitReadyToMergeReportfirst option carries(Recommended) - CLI does NOT call AskUserQuestion
-
grep -r 'push -f\|push --force' scripts/ci-autofix/ scripts/ci-watch/returns no matches - Audit log
.moai/logs/ci-autofix/<PR>-<DATE>.mdcontains every iteration
Frequently asked questions
What to verify before installation and use
What does the hns-workflow-ci-loop source document cover?
Unified CI watch + auto-fix loop. The orchestrator invokes this skill after /moai sync Phase 4 (gh pr create) returns a PR number. The skill polls required checks, classifies failures into mechanical vs semantic, attempts safe patches up to 3 iterations, and escalates semantic f…
How do I install hns-workflow-ci-loop?
The source record exposes this install command: npx skills add https://github.com/modu-ai/moai-adk --skill ".claude/skills/hns-workflow-ci-loop". Inspect the command and pinned source before running it.
Which Agent platforms does the source record declare?
The pinned source record declares support for: claude code.
Which permission-related actions were detected?
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
Compare before choosing
oaustegard/claude-skills
featuring
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre
vasilyu1983/AI-Agents-public
agents-hooks
Configures Claude Code hooks and Codex hooks.json/notify callbacks. Use when adding guardrails, preflight, audit trails, worktree automation, or budget enforcement.
vasilyu1983/AI-Agents-public
qa-testing-ios
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.
PaulRBerg/agent-skills
skill-writing
Create/scaffold/init a project-local agent skill under `.agents/skills` in an ordinary repository; defer to repository instructions that define a source catalog and lifecycle.