Hns Workflow Ci Loop logo

Hns Workflow Ci Loop

OrganizationPopular
modu-ai
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).

Overview

Publishermodu-ai
Repositorymoai-adk
Skill namehns-workflow-ci-loop
Stars
1.2K
Forks
226
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by modu-ai on GitHub. Read the source before you install it.

Installation

Install the Hns Workflow Ci Loop AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/hns-workflow-ci-loop
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/modu-ai/moai-adk.git /tmp/moai-adk
mkdir -p .claude/skills
cp -r /tmp/moai-adk/.claude/skills/hns-workflow-ci-loop .claude/skills/hns-workflow-ci-loop
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Hns Workflow Ci Loop in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Hns Workflow Ci Loop on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Hns Workflow Ci Loop is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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:

  1. Watch — Poll gh pr checks every 30s, classify required vs auxiliary via .github/required-checks.yml SSoT; exit on green/fail/timeout.
  2. Auto-fix — On required-fail (exit 2), receive JSON handoff, run up to 3 patch iterations, escalate semantic failures immediately.

One-liner:

bash
MOAI_CIWATCH_GH=gh sh scripts/ci-watch/run.sh <PR_NUMBER> <BRANCH>

Exit codes:

  • 0 — all required passed → ready-to-merge AskUserQuestion
  • 1 — fatal error → surface remediation
  • 2 — required failure → JSON handoff → auto-fix phase
  • 3 — 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-lease all 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):

  1. (Recommended) Manual fix — investigate and fix manually
  2. Revise SPEC — revise the SPEC and restart implementation
  3. 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; governs scripts/ci-watch/)

  • .claude/rules/local/ci-autofix-protocol.md — HARD autofix invocation contract (dev-only; governs scripts/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.md is deliberately script-free and governs the manager-develop autofix cycle instead; it does not describe the scripts this skill runs. ci-watch-protocol.md is 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.yml to 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-lease anywhere 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.yml modified without moai github init re-run

Verification

  • bash scripts/ci-watch/test/run_test.sh passes all shell tests
  • go test ./internal/ciwatch/... ./internal/cli/pr/... -race passes
  • internal/ciwatch/ coverage >= 85%
  • No ANSI codes in FormatStatusUpdate() output
  • EmitReadyToMergeReport first 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>.md contains every iteration

Frequently asked questions

What does the Hns Workflow Ci Loop AI skill do?

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).

Why use Hns Workflow Ci Loop on TypingMind?

Because you install it once and use it with any model. Hns Workflow Ci Loop is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Hns Workflow Ci Loop in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/hns-workflow-ci-loop. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Hns Workflow Ci Loop?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Hns Workflow Ci Loop?

As many as you like. As long as a model supports skills, you can use Hns Workflow Ci Loop with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Hns Workflow Ci Loop AI skill free?

Yes. It is published on GitHub by modu-ai under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇