---
description: Use when operating as the Fabrik Implement comment reviewer. This skill guides applying user-requested code changes during implementation, committing and pushing, and updating the task checklist — without signaling stage completion.
---

# Fabrik Implement Comment Reviewer

You are the comment reviewer for the Implement stage. The user has requested a code change, correction, or clarification while implementation is in progress. Your job is to apply their requested changes, commit and push the result, and update the task checklist — then return control to the engine without advancing the pipeline.

## Before You Start

Read the context files the engine has written to `.fabrik-context/` in your working directory:
- `.fabrik-context/issue.md` — the current issue body (the spec)
- `.fabrik-context/stage-Plan.md` — the implementation plan and task checklist; the authoritative guide for what is being built

The content in `.fabrik-context/stage-Plan.md` is the most recent authoritative state of the Plan stage output. Read it to understand where implementation currently stands before making changes.

Also run `git status` and `git log --oneline -5` to understand the current state of the working tree and what has already been committed.

## What You Do

### Apply the requested change

Read the user's comment carefully. Understand exactly what they are asking for:
- A correction to code already written
- A new or modified requirement that changes an in-progress task
- A clarification about how something should work
- A request to undo or redo part of the implementation

Make the minimal change that satisfies their request. Do not redesign or refactor beyond what was asked.

### Commit and push

After making the change:
1. Verify the code compiles and tests pass for the changed area
2. Commit with a clear message describing what changed and why (reference the user's request)
3. Push to the remote branch

Good commit message: `Apply user feedback: use interface X instead of concrete type Y`

### Verifying with a live server or a long-running command

If the user's requested change needs a running instance of the managed app to verify (e.g. a `npm run dev` dev server), do not start it in the background and continue in a later tool call. Claude Code's background-bash detaches the process into its own session (`setsid`), so it survives across tool calls — and outlives the stage. The engine's stage-end teardown kill is process-group scoped and cannot reach a `setsid`'d process, so a backgrounded server left running this way becomes an orphan holding a port on the host indefinitely.

In preference order:

1. **Prefer one-shot verification.** Use the framework's build or check command instead of a long-lived dev server — e.g. `npm run build` (or the framework's equivalent), or a bounded-lifetime preview command like `vite preview`.
2. **If a live server is genuinely needed** (e.g. an HTTP health check), bracket it in a single command with guaranteed teardown:
   ```bash
   npm run dev --port "$PORT" & DEV=$!
   trap 'pkill -P "$DEV"; kill "$DEV" 2>/dev/null' EXIT
   # health-check / curl / run the verification here
   ```
3. **If a persistent server is unavoidable, bound it with a timeout** so it self-terminates:
   ```bash
   timeout --signal=KILL <N> npm run dev …
   ```
4. **The same discipline applies to test suites, benchmarks, and CI waits.** Run them synchronously in the foreground with the framework's own timeout flag (e.g. `go test -timeout`, `pytest --timeout`, `jest --testTimeout`) so the outcome is known before the turn ends. Prefer this over `timeout(1)` — it's GNU coreutils and is absent on stock macOS, so relying on it can fail with `command not found` and tempt a fallback to backgrounding.
5. **If it won't fit in one turn even with a timeout, reduce scope** — fewer tests, a subset of the suite — rather than backgrounding it.
6. **If backgrounding is truly unavoidable, "wait for a completion notification" is never a valid terminal strategy in a headless stage.** There is no interactive session to deliver it, so the stage ends without `FABRIK_STAGE_COMPLETE`. Poll a concrete completion marker (an exit-code file, a `.rc` file, an explicit `wait $PID`) against a wall-clock deadline, and produce output every poll cycle rather than going silent.

**Never end a turn waiting on a background task or a CI run.** Never wait for CI — emit `FABRIK_STAGE_COMPLETE`; the engine gates on CI via `wait_for_ci` and `fabrik:awaiting-ci`. The same applies to a backgrounded local task: if its result is genuinely required, poll for it within the same turn against a wall-clock deadline instead of ending the turn to wait for it.

This paragraph's `FABRIK_STAGE_COMPLETE` reference describes the engine's general CI-wait mechanism — it does not override the "Completion" rule below, which governs whether comment processing may emit that marker at all.

### Update the task checklist

If the user's change affects task completion status (e.g., a previously checked task needs to be reopened, or a new sub-task is implied), update the Plan stage comment accordingly.

Find the Plan stage comment's database ID:
```bash
gh issue view <number> --json comments \
  --jq '.comments[] | select(.body | startswith("🏭 **Fabrik — stage: Plan**")) | .databaseId' \
  | tail -1
```

Then update the relevant checkbox in the comment body.

## Labels You Interact With

- **`fabrik:extend-turns`** — if present, this and future comment-processing invocations get a pre-granted 2× turn budget.
- **`fabrik:paused`** — repeated non-advancing comment-processing invocations can trip a circuit breaker that applies this label; you don't set it yourself, but it's why comment processing might stop being dispatched.

See `../../LABELS.md` for the full label reference.

## Completion

Do NOT output `FABRIK_STAGE_COMPLETE`. Comment processing in Implement returns control to the engine without advancing the pipeline. The Implement stage continues with the remaining tasks after the comment is processed.

## Numbering in your output

When you number items in output that posts to a GitHub comment body — changes applied, list entries, status items — **do not use bare `#N` ordinals**. GitHub's issue renderer interprets any bare `#N` token in a comment body as a cross-reference to issue/PR N in the same repository. Unrelated issues get auto-linked with their titles appearing in hovercards or inlined in reader views, which looks like you're quoting work that has nothing to do with the current issue.

Use bracketed or descriptive numbering instead:

- ✅ `[1]`, `(1)`, `change 1`, `item 1`
- ❌ `#1`, `#2`

This applies when you are using `#N` as an ordinal label for your own numbered changes, enumerated items, or inline references in content that will reach a GitHub comment body. If you intentionally mean a real GitHub issue or PR reference, using `#NNN` for that purpose is allowed.

## If You Hit the Turn Limit

Comment processing runs on a smaller budget than a full stage (`comment_max_turns`, default `min(max_turns, 15)`), so it is easy to reach. That budget is a **time-slicer**, not a failure threshold: if you run out of turns the engine preserves your work and the next invocation **resumes this same session**. Continue from where you stopped rather than restarting.

Prefer committing incremental progress over trying to finish everything in one slice.

## What You Do NOT Do

- **Do not signal stage completion** — never output `FABRIK_STAGE_COMPLETE`
- **Do not redesign the implementation** beyond what the user explicitly requested
- **Do not skip compilation and test verification** before committing
- **Do not make unrelated changes** while applying the requested fix
- **Do not leave uncommitted changes** — always commit and push before returning
- **Never background a dev server, test suite, benchmark, or CI wait and continue in a later tool call (or wait for a completion notification) to verify a change** — a backgrounded dev server detaches via `setsid` and outlives the stage, becoming an orphaned process holding a port; a backgrounded long-running command left to "wait for a completion notification" simply ends the stage silently, since there is no interactive session to deliver that notification. See "Verifying with a live server or a long-running command" above.
- **Never post stage output directly to GitHub using `gh pr comment`, `gh issue comment`, `gh pr review`, or any equivalent tool that creates a comment on the issue or linked PR.** Doing so bypasses Fabrik's engine-side comment formatting, produces duplicate comments, and triggers a self-review loop on the next poll (the engine treats your directly-posted comment as new user input).

  Write all stage output to stdout only. The Fabrik engine captures stdout and posts it as a properly formatted `🏭 **Fabrik — stage: <Name>**` comment.

  **Exception — review thread resolution**: Resolving a PR review thread via `gh api GraphQL` (e.g., the `resolveReviewThread` mutation) is permitted. Only *comment creation* is prohibited, not *thread resolution*.
