About execute-gitlab-issue
A skill for managing a GitLab issue through status changes, isolated worktree execution, merge request delivery, and a review gate. It delegates implementation to the `code-autonomous` engine while coordinating the surrounding issue lifecycle.
Key features
- 01Updates issue status through delivery
- 02Creates or reuses issue worktrees and branches
- 03Delegates coding to `code-autonomous`
- 04Pushes a single-commit delivery branch
- 05Runs a bounded review and fix loop
Use cases
- 01Implementing a GitLab issue from its URL
- 02Resuming work when an issue branch or MR exists
- 03Pausing for clarification or review blockers
MCP support
Uses MCP to read and update GitLab issues, manage estimates and spent time, and interact with merge requests. It requires reading `mcp-gitlab-usage` before MCP calls.
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ nextstage-brasil/ skills --skill execute-gitlab-issueAfter installing, type/execute-gitlab-issuein Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
evals/evals.jsonreferences/delivery-report.template.mdmr-conventions.mdsource-branch-resolution.mdworktree-setup.mdDetails
From the project READMEExecute GitLab Issue
Owns GitLab issue state end to end — status, branch/worktree lifecycle, MR, comments, delivery, review gate. Delegates actual coding to the code-autonomous engine (Phase 2).
Harness discovery
See ../nextstage-harness/references/harness-discovery.md. Read mcp-gitlab-usage before MCP calls.
Inputs
| Variable | Required |
|---|---|
ISSUE_URL | Yes |
SOURCE_BRANCH | No — resolved by Gate 1 if omitted |
{product_root} | When multiple products in workspace |
Single worktree, single branch, single MR, single commit per issue (monorepo model — no per-repo looping):
WORKTREE_ROOT = {product_root}/.worktrees/{ISSUE_ID}WORK_BRANCH = work/{ISSUE_ID}-{ISSUE_SLUG}
Phase 0 — Context
- Resolve
{product_root}(factory:apps/{slug}/; standalone: repo root). - Load product context: follow Implementation boot rule in
../nextstage-harness/references/artifact-layout.md. - Ensure
.worktrees/is gitignored (seereferences/worktree-setup.md).
Phase 1 — Prepare
First act (mandatory, before any gate)
Apply status_in_progress (Em andamento) to the issue via MCP. If this call fails, abort immediately and wait for human intervention — nothing below runs on an issue that isn't marked in progress.
Gate 0 — Existing branch/MR reuse
An issue may already have a work branch (e.g. returned by a human reviewer). Detect it before Gate 1 so you never open a duplicate branch/MR:
list_issue_merge_requests— look for an open MR whosesource_branchmatcheswork/{ISSUE_ID}-*; record itssource_branchandtarget_branch.git ls-remote --heads origin "work/{ISSUE_ID}-*"as a second signal.- Found →
REUSE_MODE = true,WORK_BRANCH = {existing branch},SOURCE_BRANCH = {existing MR target}. SkipWORK_BRANCHderivation below and skip Gate 1 (only re-validate the branch still exists on the remote). - Not found →
REUSE_MODE = false, proceed to Gate 1.
Gate 1 — SOURCE_BRANCH (mandatory, blocking; skipped when REUSE_MODE = true)
Resolve SOURCE_BRANCH only via references/source-branch-resolution.md (priority order: human → issue text → product rule → milestone/version discovery → mandatory develop fallback).
- Never infer from the current checkout or ad hoc heuristics.
- Never auto-use any branch except a discovered version-relative
develop_*/develop-*or thedevelopfallback — other bases (homolog,release/*, etc.) require explicit human confirmation this run. main/masterare always invalid asSOURCE_BRANCH, even if named in the issue.
After resolution, validate on the remote (fetch, ls-remote, _ ↔ - alternates) per the same reference. When the mandatory develop fallback is missing on the remote → abort with the exact error; ask the operator once.
Gate 1.5 — Single worktree (monorepo)
Create WORKTREE_ROOT per references/worktree-setup.md — always {product_root}/.worktrees/{ISSUE_ID}, never under .cursor/. Abort if a worktree already exists for this ISSUE_ID and is in use by another run, unless this is an explicit resume. Never implement in the main checkout or on main/master/SOURCE_BRANCH. If git worktree add fails → abort with the exact error (do not fall back to the main checkout "to keep going"). Isolation is a hard gate before Phase 2.
MCP setup
due_dateif empty: current date + 5 business days.START_TIME= ISO 8601 UTC timestamp.set_issue_estimateonce thecode-autonomousengine returns a plan-based estimate (Phase 2, step 2).
Phase 2 — Execution (delegated)
- Read the full issue payload via MCP (title, description, comments, attachments).
- Invoke the
code-autonomousskill in Engine mode, passing: issue payload,{product_root},WORKTREE_ROOT,WORK_BRANCH,SOURCE_BRANCH. The engine self-decides planning depth, runs its doubt protocol, and dispatches implementation (single- or multi-agent) insideWORKTREE_ROOT— seecode-autonomous'sreferences/routing.mdfor what "Engine mode" means and what it returns. - Call
set_issue_estimatewith the estimate the engine returns on its first invocation. - Doubt escalation contract — the engine never mutates GitLab state itself. When it returns a destructive-doubt event instead of (or alongside) unit results:
- Apply
status_blocked(Em Impedimento). - Post a comment mentioning the issue author (
@{author.username}fromread_issue) with the questions, options, and recommended default. - Mirror the same question in the interactive chat and wait.
- On answer (chat and/or issue comment): record it, set status back to
status_in_progress(Em andamento), and re-invoke the engine with the resolved doubt appended to its context.
- Apply
- No intermediate confirmations otherwise — this loop is the only pause point until Phase 4's review gate.
Phase 3 — Delivery
- Squash to one Conventional Commit before push (
<type>(#{ISSUE_ID}): <imperative description in English>, types: feat/fix/refactor/test/docs/chore). The engine may leave internal checkpoint commits per work unit in the worktree during Phase 2 — squash them here to preserve one-commit-per-delivery atomicity. See../nextstage-harness/references/agent-git-identity.mdfor attribution. - Push
WORK_BRANCH. add_issue_spent_time(ELAPSED_SECONDS = max(1, ceil(END_TIME - START_TIME))).- Status →
status_done(Dev 100%) only after Phase 4 returnsApproved— never before. - Internal delivery comment (
internal: true) usingreferences/delivery-report.template.md.
Phase 4 — Review gate (blocking, bounded fix loop)
- Invoke
code-reviewerin Issue review mode (ISSUE_URL) — read-only, official gate, posts the internal GitLab comment. - Loop, max 3 rounds:
Approved→ proceed to Phase 3's status/comment closure (Dev 100%).Rejectedwith rounds remaining → re-invokecode-autonomous(same worktree/branch) with the findings as a fix work unit, then re-review.Blocked, or rounds exhausted →status_blocked(Em Impedimento), post the findings, stop. Do not reach Dev 100%.
- Final output:
Fatto!+MR_URLS+Code Review: {verdict}— exactly the verdict stringcode-reviewerreturned.
Stop and ask the human
| Condition | Action |
|---|---|
Gate 1: develop fallback missing on remote | Stop — ask once |
| Gate 1: non-allowed base branch without human confirmation | Stop — ask once |
| Worktree conflict (same issue, another run) | Stop unless explicit resume |
| Ambiguous or conflicting acceptance criteria | Stop — ask once |
| MCP unavailable or auth failure | Stop — state blocker |
project_id trio not confirmed | Stop per mcp-gitlab-usage |
Work on protected/base branch per gitlab-sync-config.md | Stop |
| Destructive ops (issue delete, force-push main/master) | Stop — require explicit human |
| Product decision not stated in the issue | Stop — ask once |
| Engine reports a destructive doubt | Pause/resume per Phase 2 step 4 — not a hard stop |
See mcp-gitlab-usage for MCP tool contracts and confirmation gates.
Related skills
| Skill | Role |
|---|---|
mcp-gitlab-usage | All GitLab tools |
gitlab-board-sync | Status label semantics |
code-reviewer | Phase 4 gate |
code-autonomous | Phase 2 execution engine |
code-coder | Non-GitLab ad-hoc implementation |
References
| File | When |
|---|---|
references/source-branch-resolution.md | Gate 1 — milestone/version discovery, develop fallback, remote validation |
references/worktree-setup.md | ISSUE_ID → run_id override (canonical mechanics in nextstage-harness) |
references/mr-conventions.md | MR title, draft, linking, reuse note |
references/delivery-report.template.md | Phase 3 internal delivery comment |