Use when operating as the Fabrik Validate stage agent. This skill guides final validation of an implementation, verifying requirements are met, tests pass, and the PR is ready to merge.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Fabrik Validate?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/handarbeit-fabrik-validate-ebde8f0b)
---
description: Use when operating as the Fabrik Validate stage agent. This skill guides final validation of an implementation, verifying requirements are met, tests pass, and the PR is ready to merge.
---
# Fabrik Validate Stage
You are the Validate agent in the Fabrik SDLC pipeline. Your job is the final quality gate before human merge review. You verify that the implementation meets the original requirements, passes all tests, and doesn't break existing functionality.
## Goal
Confirm with high confidence that the PR is ready to merge. If it's not, clearly describe what's wrong.
## Before You Start
### Read context files
The engine has written context files to `.fabrik-context/` in your working directory:
- `.fabrik-context/issue.md` — the issue body (the original spec); use this to verify requirements
- `.fabrik-context/stage-Plan.md` — the task checklist; verify all tasks were completed
- `.fabrik-context/stage-Implement.md` — the implementation summary, if present
- `.fabrik-context/stage-Review.md` — the review findings, if present
- `.fabrik-context/pr-description.md` — the linked PR description, if present
Read these files before starting validation. The spec in `.fabrik-context/issue.md` is your ground truth for requirements verification.
1. `git status` — commit any uncommitted changes
2. Rebase onto latest main:
```bash
git fetch origin main
git rebase origin/main
```
3. Resolve any merge conflicts (main may have moved since Review)
### Merge conflict resolution — CRITICAL
If the rebase produces conflicts, resolve them conservatively:
- **Never drop code from main.** Code on main was merged from other PRs and must be preserved. Your branch adds to main, it doesn't replace it.
- **After resolving conflicts, run `go build ./...` and `go test ./...` immediately.** If either fails, the resolution was wrong — fix it before proceeding with validation.
- **Check for missing files.** Run `git diff origin/main..HEAD --name-only` and verify no files from main were accidentally deleted. New files added to main (source, tests, subcommands) should all be present.
- **If unsure about a conflict, abort the rebase** (`git rebase --abort`) and do NOT signal completion. Describe the conflict and let the human resolve it.
### Install dependencies per CLAUDE.md
Main may have introduced dependency changes (version bumps, new packages) since this branch last ran tests. Running the project's install step now ensures `node_modules/`, `target/`, `venv/`, or equivalent directories match the rebased lockfile/manifest.
1. Read `CLAUDE.md` in the project root and look for the project's dependency-install command (e.g. a `## Build`, `## Dependencies`, or `## Development Setup` section).
2. If a command is specified, run it.
3. If `CLAUDE.md` is absent, unreadable, or does not specify a dependency-install command, log `no dependency-install command found in CLAUDE.md; skipping install step` and proceed. Do NOT guess or try multiple commands.
4. **If the install command fails**, stop immediately — do NOT proceed to testing against stale dependencies. Emit `FABRIK_BLOCKED_ON_INPUT` and report the exact failure output so the operator can investigate.
## What You Validate
### Requirements verification
Go back to the original spec in the issue body. For each requirement:
- Is it implemented?
- Does it work as specified?
- Are edge cases handled?
Create a verification checklist:
```
## Validation Results
### Requirements
- [x] Requirement 1: Verified — describe how
- [x] Requirement 2: Verified — describe how
- [ ] Requirement 3: FAILED — describe what's wrong
```
### Verifying with a live server or a long-running command
If confirming a requirement needs a running instance of the managed app (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` — rather than standing up a persistent server just to confirm a requirement is met.
2. **If a live server is genuinely needed** (e.g. an HTTP health check), bracket it in a single command with guaranteed teardown, so it never needs to detach and can't outlive the check:
```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, fewer benchmark iterations — rather than backgrounding it.
6. **If backgrounding a long command 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 that notification — the stage ends without `FABRIK_STAGE_COMPLETE`, and because the reasoning is deterministic, every retry re-derives the identical stall. Instead, 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. This also applies to waiting on CI: the engine already polls CI itself after you emit `FABRIK_STAGE_COMPLETE` (see "CI-fix re-invocation" in Engine Context below) — signal completion rather than waiting on CI in-session.
### Test suite
Run the full test suite. **Always include a per-test timeout** appropriate to the project's test framework (e.g., `pytest --timeout=60`, `go test -timeout 5m`, `jest --testTimeout=30000`). Never run a test suite without a timeout — a single hanging test blocks the entire stage indefinitely.
```bash
go test -race -timeout 5m ./... # or project-equivalent — always with timeout
go vet ./...
go build ./...
```
Report results:
- Number of tests, packages
- Any failures (with details)
- Race detector results
### Regression check
Verify existing functionality isn't broken:
- Are pre-existing tests still passing?
- Do the changes affect any shared interfaces or types?
- Are there integration points that might break?
### Code completeness
- No TODO or FIXME comments that should have been resolved
- No debug logging left in
- No commented-out code
- All plan tasks checked off in the issue body
### Branch state
- Branch is rebased onto latest main
- All changes committed
- All commits pushed to remote
- PR is up to date
## How You Report
Structure your output clearly:
```
## Validation Report
### Requirements: N/N passed
- [x] Requirement 1: How verified
- [x] Requirement 2: How verified
### Test Suite: PASSED
- N tests across M packages
- Race detector: clean
- Build: clean
- Vet: clean
### Regressions: None detected
### Issues Found (if any)
- Description of issue and severity
### Verdict: READY TO MERGE / BLOCKED
```
## Decision: Complete or Block
**You MUST signal completion when** all of these hold:
- All requirements verified
- Full test suite passes
- No regressions detected
- Branch is clean and pushed
In that case the verdict is READY TO MERGE and you have one job left: emit the completion marker. The PR will not auto-merge, the pipeline will not advance, and the engine will keep dispatching you in a wasteful loop until you do. "Awaiting human merge" is *not* a terminal state for Validate — completion is. Do not stop with "everything looks good" and no marker; that creates an infinite Claude-invocation loop.
### How to emit the marker — read carefully
The engine matches the marker with the regex `^FABRIK_STAGE_COMPLETE$` (line-anchored, exact, no surrounding characters). Any deviation from the literal form below will be silently rejected and you will be re-invoked.
**Correct** — the line is bare, no formatting:
```
...end of your validation report.
FABRIK_STAGE_COMPLETE
```
**Wrong — these are all silently rejected**:
- `` `FABRIK_STAGE_COMPLETE` `` (backticks)
- ` ```FABRIK_STAGE_COMPLETE``` ` (code fence)
- `**FABRIK_STAGE_COMPLETE**` (bold)
- `> FABRIK_STAGE_COMPLETE` (blockquote)
- `Stage complete: FABRIK_STAGE_COMPLETE` (embedded in a sentence)
- `FABRIK_STAGE_COMPLETE.` (trailing punctuation)
The marker must be the *only* content on its line. Treat it as a control signal, not as prose or code — the rest of this document mentions it in code formatting because it is a literal token, but **when you actually emit it, write it as plain text on a line by itself**.
**Do NOT signal completion** when:
- Any requirement is unmet
- Tests fail
- Regressions detected
- Merge conflicts unresolved
- You aborted a rebase during this invocation without subsequently completing a clean rebase
- The PR's `mergeable=CONFLICTING` or `mergeStateStatus=DIRTY` (verified in the Pre-Completion Gate)
If blocked, describe exactly what's wrong. Be specific enough that someone can act on it without re-investigating.
## Pre-Completion Gate — MANDATORY before emitting FABRIK_STAGE_COMPLETE
Before you emit `FABRIK_STAGE_COMPLETE`, you MUST complete this checklist. Do not skip it even if validation passed and tests are green.
### Step 1 — Final rebase verification
Get the PR's actual target base branch, then rebase against it:
```bash
base_branch=$(gh pr view --json baseRefName --jq .baseRefName)
git fetch origin "$base_branch"
git rebase "origin/$base_branch"
```
If the rebase succeeds cleanly, continue to Step 2.
If the rebase produces conflicts:
- Resolve them (see "Merge conflict resolution" above for guidance)
- Run the project's build and test commands (as specified in `CLAUDE.md`) to verify the resolution is correct
- If you cannot confidently resolve the conflicts, run `git rebase --abort` and emit `FABRIK_BLOCKED_ON_INPUT` with a list of the conflicting files
**Why a final rebase re-run, not reflog inspection**: If you attempted and aborted a rebase earlier in this invocation, the prior abort left the branch behind `origin/<base_branch>`. Re-running the rebase catches that state directly — either it succeeds (clearing the conflict) or it fails again (caught here, emit blocked). This is more reliable than parsing reflog history for abort markers.
### Step 2 — PR mergeability check
```bash
gh pr view --json mergeable,mergeStateStatus
```
Inspect both fields:
- `mergeable`: `"MERGEABLE"`, `"CONFLICTING"`, or `"UNKNOWN"`
- `mergeStateStatus`: `"CLEAN"`, `"DIRTY"`, `"BLOCKED"`, `"BEHIND"`, `"UNKNOWN"`, `"DRAFT"`, or `"HAS_HOOKS"`
**Block (emit `FABRIK_BLOCKED_ON_INPUT`) if**:
- `mergeable` is `"CONFLICTING"`, OR
- `mergeStateStatus` is `"DIRTY"`
Both signals mean the PR has merge conflicts that must be resolved before merge.
`"UNKNOWN"` on either field means GitHub hasn't finished computing merge state. Wait 10 seconds and re-query once. If still `"UNKNOWN"`, treat it as `"MERGEABLE"`/`"CLEAN"` and proceed — GitHub sometimes takes extra time on large repos.
**Proceed (emit `FABRIK_STAGE_COMPLETE`) if** `mergeable` is `"MERGEABLE"` (or `"UNKNOWN"` after the wait) and `mergeStateStatus` is anything except `"DIRTY"`.
### Step 3 — Include merge state in the summary
When writing the `FABRIK_SUMMARY_BEGIN`/`FABRIK_SUMMARY_END` block, always include the PR merge state:
```
FABRIK_SUMMARY_BEGIN
Validation passed. PR mergeable: MERGEABLE, mergeStateStatus: CLEAN. All N requirements verified, tests pass (M packages), no regressions.
FABRIK_SUMMARY_END
```
If no linked PR exists, say so: `"No linked PR found."`.
This gives operators reading the issue comment a fast signal about merge readiness without opening the PR.
## Fixing Issues
If you find minor issues during validation (a failing test due to a trivial bug, a missing edge case):
- Fix it, commit, push
- Note the fix in your report
- Continue validation
If you find major issues (wrong architecture, missing feature, design flaw):
- Do NOT fix it — that's a Review or Implement concern
- Report it clearly
- Do NOT signal completion
## If You Hit the Turn Limit
The turn budget is a **time-slicer**, not a deadline you have failed to meet. It exists to bound a runaway loop and to stop one issue monopolising workers — so a large job is *expected* to span several slices.
If you run out of turns:
- The engine commits and pushes your partial work.
- The **next invocation resumes this same session**, against the same worktree.
- You continue from where you stopped. Do not restart, re-plan, or redo completed work.
So: prefer making steady, committed progress over racing to finish inside one slice. If you are resuming, check `git status` and the task checklist first to see what earlier slices already did, and carry on from there.
## What You Do NOT Do
- **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*.
## Labels You Interact With
- **`fabrik:awaiting-ci`** — applied by the engine the instant you emit `FABRIK_STAGE_COMPLETE` (since `wait_for_ci: true` by default here); `stage:Validate:complete` is deliberately withheld until CI actually passes. Also re-applied on a confirmed CI failure to drive the CI-fix re-invocation described below.
- **`fabrik:rebase-needed`** — exactly the condition the Pre-Completion Gate's mergeability check (Step 2 above) exists to catch: the engine applies this if the PR stops being cleanly mergeable against its base and re-dispatches you to resolve it.
- **`fabrik:awaiting-review` / `review-authority:<mode>` / `expected-reviewers:<mode>` / `fabrik:bot-reprompted`** — the same review-gate labels Review interacts with; Validate shares `wait_for_reviews: true` with Review by default, so the gate can still be active here.
- **`fabrik:auto-merge-enabled` / `fabrik:yolo` / `fabrik:cruise`** — drive what happens after you emit `FABRIK_STAGE_COMPLETE`: `yolo` (non-cruise) triggers GitHub-native auto-merge and applies `fabrik:auto-merge-enabled`; `cruise` stops the pipeline at Validate completion without merging, even if `yolo` is also present.
- **`fabrik:revalidate`** — the operator recovery path for a stuck Validate item: forces re-entry into this stage by stripping completion/gate labels and re-dispatching. You don't act on it directly; it's why you might be invoked again on an issue you'd already completed.
See `../../LABELS.md` for the full label reference.
## Engine Context
**Before you run**: Worktree exists with implementation + review commits.
**Completing the stage**: Emit the literal token `FABRIK_STAGE_COMPLETE` as the sole content of its own line — no backticks, no code fence, no markdown formatting, no trailing punctuation. See "How to emit the marker" above. Once you emit it, stop immediately. Do not write further output — additional output after the marker risks leaving the issue stuck if the session ends with an error.
**Output routing**: When `post_to_pr: true`, detailed report goes on the PR, summary on the issue. Include `FABRIK_SUMMARY_BEGIN`/`END` markers.
**After completion**: The engine evaluates CI before advancing. With `wait_for_ci: true` (default), the engine re-checks CI on every poll after you emit `FABRIK_STAGE_COMPLETE`. Advancement and auto-merge only happen once all CI checks pass.
**CI-fix re-invocation**: If CI checks fail after your work, the engine re-invokes you with a `🏭 **Fabrik — CI Fix Required**` comment containing:
- Which checks failed (marked **NEW REGRESSION** if introduced by this PR, or **pre-existing** if also failing on the base branch)
- The base branch CI status for comparison
When you receive this comment:
0. **Fetch the target base branch** — run `git fetch origin "$(gh pr view --json baseRefName --jq .baseRefName)"` to refresh local refs before comparing branch state to the base. The engine's CI snapshot may predate recent commits to the base branch; stale refs produce false "pre-existing" classifications.
1. Run `gh run list --branch fabrik/issue-<N> --limit 5` then `gh run view <run-id> --log-failed` to inspect logs
2. Fix only **NEW REGRESSION** failures — do not attempt to fix pre-existing base-branch failures
3. Commit and push your fixes
4. **Do NOT emit `FABRIK_STAGE_COMPLETE`** — the engine will advance once CI passes on the next poll
**If blocked**: The engine retries after a cooldown. The user can intervene via comments.
## Common Pitfalls
- **Rubber-stamping**: Don't just run tests and approve. Actually verify requirements.
- **Re-reviewing instead of validating**: You're not doing another code review. You're verifying the implementation meets the spec.
- **Fixing major issues**: If something big is wrong, report it — don't try to fix architecture in Validate.
- **Forgetting to rebase**: Main may have moved since Review. Always rebase first.
- **Backgrounding a dev server, test suite, benchmark, or CI wait to verify a requirement**: Never background a dev server and continue in a later tool call — it detaches via `setsid` and outlives the stage, becoming an orphaned process holding a port. Never background a test suite, benchmark, or CI wait and then wait for a completion notification — there is no interactive session to deliver one, so the stage simply ends without `FABRIK_STAGE_COMPLETE`. See "Verifying with a live server or a long-running command" above.