Monitor CI Command
You are the orchestrator for monitoring Nx Cloud CI pipeline executions and handling self-healing fixes. You spawn subagents to interact with Nx Cloud, run deterministic decision scripts, and take action based on the results.
Context
- Current Branch: !
git branch --show-current - Current Commit: !
git rev-parse --short HEAD - Remote Status: !
git status -sb | head -1
User Instructions
$ARGUMENTS
Important: If user provides specific instructions, respect them over default behaviors described below.
Configuration Defaults
Parse any overrides from $ARGUMENTS and merge with defaults.
Nx Cloud Connection Check
Before starting the monitoring loop, verify the workspace is connected to Nx Cloud. Without this connection, no CI data is available and the entire skill is inoperable.
Step 0: Verify Nx Cloud Connection
-
Check
nx.jsonat workspace root fornxCloudIdornxCloudAccessToken -
If
nx.jsonmissing OR neither property exists → exit with: -
If connected → continue to main loop
Architecture Overview
- This skill (orchestrator): spawns subagents, runs scripts, prints status, does local coding work
- ci-monitor-subagent (haiku): calls one MCP tool (ci_information or update_self_healing_fix), returns structured result, exits
- ci-poll-decide.mjs (deterministic script): takes ci_information result + state, returns action + status message
- ci-state-update.mjs (deterministic script): manages budget gates, post-action state transitions, and cycle classification
Status Reporting
The decision script handles message formatting based on verbosity. When printing messages to the user:
- Prepend
[monitor-ci]to every message from the script'smessagefield - For your own action messages (e.g. "Applying fix via MCP..."), also prepend
[monitor-ci]
Anti-Patterns
These behaviors cause real problems — racing with self-healing, losing CI progress, or wasting context:
If this skill fails to activate, the fallback is:
- Use CI provider CLI for a one-time, read-only status check (single call, no watch/polling flags)
- Immediately delegate to this skill with gathered context
- Do not continue polling on main agent — it wastes context tokens and bypasses self-healing
Session Context Behavior
If the user previously ran /monitor-ci in this session, you may have prior state (poll counts, last CI Attempt URL, etc.). Resume from that state unless --fresh is set, in which case discard it and start from Step 1.
MCP Tool Reference
Three field sets control polling efficiency — use the lightest set that gives you what you need:
The ci_information tool accepts branch (optional, defaults to current git branch), select (comma-separated field names), and pageToken (0-based pagination for long strings).
The update_self_healing_fix tool accepts a shortLink and an action: APPLY, REJECT, or RERUN_ENVIRONMENT_STATE.
Default Behaviors by Status
The decision script returns one of the following statuses. This table defines the default behavior for each. User instructions can override any of these.
Simple exits — just report and exit:
Statuses requiring action — when handling these in Step 3, read references/fix-flows.md for the detailed flow:
Key rules (always apply):
- Git safety: Stage specific files by name —
git add -Aorgit add .risks committing the user's unrelated work-in-progress or secrets - Environment failures (OOM, command not found, permission denied): bail immediately. These aren't code bugs, so spending local-fix budget on them is wasteful
- Gate check: Run
ci-state-update.mjs gatebefore local fix attempts — if budget exhausted, print message and exit
Main Loop
Step 1: Initialize Tracking
Step 2: Polling Loop
Repeat until done:
2a. Spawn subagent (FETCH_STATUS)
Determine select fields based on mode:
- Wait mode: use WAIT_FIELDS (
cipeUrl,commitSha,cipeStatus) - Normal mode (first poll or after newCipeDetected): use LIGHT_FIELDS
Call the ci_information tool with the determined select fields for the current branch. Wait for the result before proceeding.
2b. Run decision script
Pass --timeout and --new-cipe-timeout in minutes (the values from Configuration Defaults) — the script converts to seconds internally. Pass --elapsed-seconds as the whole seconds elapsed since start_time (now() - start_time); this is what enforces --timeout as a total monitor budget across every poll and attempt, so it must be supplied on every call once monitoring has started.
The script outputs a single JSON line: { action, code, message, delay?, noProgressCount, envRerunCount, fields?, newCipeDetected?, verifiableTaskIds? }
2c. Process script output
Parse the JSON output and update tracking state:
no_progress_count = output.noProgressCountenv_rerun_count = output.envRerunCountprev_cipe_status = subagent_result.cipeStatusprev_sh_status = subagent_result.selfHealingStatusprev_verification_status = subagent_result.verificationStatusprev_failure_classification = subagent_result.failureClassificationprev_status = output.action + ":" + (output.code || subagent_result.cipeStatus)poll_count++
Based on action:
action == "poll": Printoutput.message, sleepoutput.delayseconds, go to 2a- If
output.newCipeDetected: clear wait mode, resetwait_mode = false
- If
action == "wait": Printoutput.message, sleepoutput.delayseconds, go to 2aaction == "done": Proceed to Step 3 withoutput.code
Step 3: Handle Actionable Status
When decision script returns action == "done":
- Run cycle-check (Step 4) before handling the code
- Check the returned
code - Look up default behavior in the table above
- Check if user instructions override the default
- Execute the appropriate action
- If action expects new CI Attempt, update tracking (see Step 3a)
- If action results in looping, go to Step 2
Tool calls for actions
Several statuses require fetching additional data or calling tools:
- fix_apply_ready: Call
update_self_healing_fixwith actionAPPLY - fix_needs_local_verify: Call
ci_informationwith HEAVY_FIELDS for fix details before local verification - fix_needs_review: Call
ci_informationwith HEAVY_FIELDS → getsuggestedFixDescription,suggestedFixSummary,taskFailureSummaries - fix_failed / no_fix: Call
ci_informationwith HEAVY_FIELDS → gettaskFailureSummariesfor local fix context - environment_issue: Call
update_self_healing_fixwith actionRERUN_ENVIRONMENT_STATE - self_healing_throttled: Call
ci_informationwith HEAVY_FIELDS → getselfHealingSkipMessage; then callupdate_self_healing_fixfor each old fix
Step 3a: Track State for New-CI-Attempt Detection
After actions that should trigger a new CI Attempt, run:
Action types: fix-auto-applying, apply-mcp, apply-local-push, reject-fix-push, local-fix-push, env-rerun, auto-fix-push, empty-commit-push
The script returns { waitMode, pollCount, lastCipeUrl, expectedCommitSha, agentTriggered }. Update all tracking state from the output, then go to Step 2.
Step 4: Cycle Classification and Progress Tracking
When the decision script returns action == "done", run cycle-check before handling the code:
The script returns { cycleCount, agentTriggered, envRerunCount, approachingLimit, limitReached, message }. Update tracking state from the output.
- If
limitReached→ the--max-cyclesbudget is exhausted. Printmessageand stop monitoring (do not handle the code or start another cycle). This is a hard stop, not advisory. - Else if
approachingLimit→ ask user whether to continue (with 5 or 10 more cycles) or stop monitoring - If previous cycle was NOT agent-triggered (human pushed), log that human-initiated push was detected
Progress Tracking
no_progress_count, circuit breaker (5 polls), and backoff reset are handled by ci-poll-decide.mjs (progress = any change in cipeStatus, selfHealingStatus, verificationStatus, or failureClassification)env_rerun_countreset on non-environment status is handled by ci-state-update.mjs cycle-check- On new CI Attempt detected (poll script returns
newCipeDetected) → resetlocal_verify_count = 0,env_rerun_count = 0
Error Handling
User Instruction Examples
Users can override default behaviors:


