skills/ci-dance/SKILL.md
This skill should be used when the user says 'ci-dance', 'make the PR green', 'ship this and fix CI', 'push and handle reviews', or wants end-to-end PR pipeline automation.
npx skillsauth add lklimek/claudius ci-danceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fully autonomous loop: push, run three parallel streams (CI, grumpy-review, copilot review) where each stream independently fixes its own findings, merge code fixes, repeat. No confirmations, no user interaction until done or stuck.
claudius:git-and-github skill first/push, /grumpy-review, or /check-pr-comments, skip their "ask user" steps. This skill's invocation is the confirmationParse $ARGUMENTS for timeout=N (minutes). Default: 300 minutes. Record start_time at invocation. Before each loop iteration, check elapsed time — hard stop on timeout.
Before entering the loop, initialize:
iteration = 0
start_time = now()
ci_iterations = 0, review_iterations = 0, findings_fixed = 0, findings_skipped = 0
REPEAT UNCONDITIONALLY until an exit condition in Step 5 explicitly triggers EXIT:
iteration += 1
Log: "=== CI Dance: Iteration {iteration} starting ==="
1. PUSH — /push: commit, push, create/update PR
2. THREE STREAMS — run in parallel, each is COMPLETE: trigger → wait → collect & classify → FIX
├── CI Stream — watch NEW runs from LATEST push → diagnose → fix
├── Grumpy Stream — FRESH /grumpy-review on current code → fix
└── Review Stream — request copilot + check for NEW reviews → fix
↕ Streams communicate to CLAIM findings and avoid duplicate fixes
3. MERGE — combine code fixes from all streams into working tree
4. RESOLVE — resolve addressed bot review threads
5. EXIT CHECK — three outcomes:
→ EXIT SUCCESS: no fixes applied AND CI green AND no MEDIUM+ findings
→ EXIT TIMEOUT/STUCK: time limit or repeated failure
→ CONTINUE: fixes were applied — MUST return to Step 1
MANDATORY CONTINUATION: If Step 5 does not trigger EXIT SUCCESS or EXIT TIMEOUT/STUCK, you MUST execute Step 1 again. Stopping after one iteration is a bug. The loop continues until an explicit exit.
Log: "--- Iteration {iteration}: Step 1 — Push ---"
Invoke /push to commit staged/unstaged changes, push, and create or update the PR. Skip user confirmation per unattended mode.
If nothing to commit or push, proceed to Step 2.
Fresh results required: On iteration 2+, every stream must operate on the LATEST state. CI Stream watches runs from the most recent push (not cached results). Grumpy Stream runs a new /grumpy-review against current code. Review Stream checks for new reviews since the last iteration.
Before launching streams, create a team for coordination:
TeamCreate(team_name="ci-dance")
Then spawn each stream as a named agent with team_name: "ci-dance" and isolation: "worktree":
ci-streamgrumpy-streamreview-streamSee grand-admiral § Worktree Isolation for the canonical write-up. Summary for ci-dance:
isolation="worktree" silently dropped for team-spawned agents. Agent(team_name=..., isolation="worktree") lands the agent in the lead's CWD, not a dedicated worktree. pwd returns the lead's path instead of .claude/worktrees/agent-.... A stream that proceeds anyway will edit the main repo directly.Agent() calls issued from within a team-lead session that OMIT team_name are auto-joined to the lead's team and lose isolation the same way. Omitting team_name does not escape the team context, which is why the lead cannot rely on an in-session "spawn solo" trick — the worktree must be pre-created externally.Workaround (single canonical path): the lead pre-creates one worktree per stream via git worktree add .claude/worktrees/agent-<stream-name> -b <branch-name> <SHA> BEFORE spawning, and includes the assigned absolute path in each stream's spawn prompt. Each stream cds into its assigned path on its first turn and works there. This is the stable path; do not attempt other workarounds.
All three streams run concurrently. Each stream is a complete unit that finds AND fixes its own issues. Every stream follows the same lifecycle: trigger → wait → collect & classify → fix.
Isolation: Each stream runs in its own git worktree (isolation: "worktree"). This lets streams edit and commit independently without conflicting. Step 3 (Merge) cherry-picks commits from each worktree back into the main branch.
Before fixing any finding, a stream must claim it via task ownership (see Inter-Stream Communication below). If another stream already owns a task at the same location, skip it.
TaskCreate, claim ownership via TaskUpdate. If another stream already owns a task at that location, skip. Apply fix, commit, mark task completed./grumpy-review locally (forked context, produces severity-ranked JSON report).completed.gh pr edit --add-reviewer @copilot || truegh-fetch-reviews.sh. Compare review IDs to detect new ones.
/check-pr-comments (skip confirmations). Classify each: verify issue exists in current code, rate severity, check for false positives. Filter to MEDIUM+.completed.Streams coordinate via the Teams infrastructure to prevent duplicate fixes.
Finding Discovery: When a stream finds something worth fixing, create a task:
TaskCreate(subject="Fix: unused import in src/main.rs:42", description="CI failure: ...", metadata={stream: "ci", file: "src/main.rs", line: 42, severity: 3})
Claiming: Before fixing, check TaskList for existing tasks at the same file/line range. If none, create the task and set owner to self via TaskUpdate. If another stream already owns a task at that location, skip it. TaskUpdate ownership is atomic — no race conditions.
Completion: After fixing, mark the task completed via TaskUpdate(status="completed").
Direct Coordination: Use SendMessage for real-time alerts between streams:
SendMessage(to="grumpy-stream", message="I'm fixing src/auth.rs:17-25, skip this area")
Use for: overlapping finding alerts, completion summaries, conflict flags.
After all three streams complete:
TaskList — review all tasks, their status and outcomesTeamDeletegit worktree remove + prune)Resolve addressed bot review threads using gh-resolve-review-threads.sh. Bot threads only, per existing convention. Do not ask — unattended mode.
Log: "--- Iteration {iteration}: Step 5 — Exit Check ---"
Evaluate exactly one outcome:
"=== CI Dance: EXIT SUCCESS after {iteration} iterations ===". Proceed to Final Report."=== CI Dance: EXIT TIMEOUT after {iteration} iterations ===". Proceed to Final Report."=== CI Dance: EXIT STUCK after {iteration} iterations ===". Proceed to Final Report."=== CI Dance: Iteration {iteration} complete, continuing to iteration {iteration+1} ===". You MUST return to Step 1 now. Do NOT stop, do NOT generate the Final Report, do NOT consider the task complete.Sub-procedure for CI Stream steps 2-3 (Wait and Collect). Watch GitHub Actions runs and collect failures as findings. Fixing happens in CI Stream step 4, not here.
Do not start watching until all local fixes are pushed. Watching a superseded run wastes time.
When a push triggers multiple workflow runs, watch sequentially starting with the fastest. Check historical durations:
gh run list --workflow <workflow>.yml --status success --limit 50
List runs for the current branch:
gh run list --branch "$(git branch --show-current)" --limit 10
Identify runs triggered by the latest push. Order by expected duration (shortest first).
Watch each run sequentially:
gh run watch {run_id} --exit-status
Diagnose failures and record as findings:
gh run view {run_id} --log-failed
Identify root cause: test failures, lint/format errors, dependency issues, environment problems. Record each as a finding (severity, file/location, description).
Return all CI findings to the CI Stream.
| Condition | Action | |-----------|--------| | Success | CI green, no MEDIUM+ findings. Report stats, remind user to merge. | | Timeout | Time limit elapsed. Stop, report current state and what remains. | | Stuck | Same failure or finding persists after 2-3 fix attempts. Stop, report what was tried. | | No review | 20 min wait with no bot review. If CI is green, report success noting review was skipped. |
On exit (any condition), report:
/push, /grumpy-review, /check-pr-commentsTeamDelete after merging stream resultstesting
Coordinator-only LLM validation pass. Adds ai_assessment / ai_verdict / ai_verdict_confidence and, in the rare partial-producer case, re-estimates absent risk/impact/scope on a consolidated v3 report.
testing
Use for typos or single-line fixes (≤20 lines). Same mandatory phase order (Planning→Impl→QA→LL), minimal ceremony. Auto-retry on failure.
testing
Use for bug fixes or small changes (≤200 lines). Same phase order as workflow-feature (Planning→Impl→QA→LL) with lighter ceremony. Auto-retry on failure, unattended.
development
Use for new projects, features, or major refactoring. Phases: Planning (Req→UX→Test Spec→Dev Plan) → Implementation → QA → Lessons Learned. Auto-retry on failure, unattended.