Implement exactly one already-claimed Linear ticket in the current worktree. Invoke only when the user explicitly asks to run /factory-ticket or the factory-ticket workflow.
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 Factory Ticket?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/watt-mind-factory-ticket)
---
name: factory-ticket
description: "Implement exactly one already-claimed Linear ticket in the current worktree. Invoke only when the user explicitly asks to run /factory-ticket or the factory-ticket workflow."
---
# factory-ticket
The user's accompanying request is this workflow's argument string. Wherever these instructions refer to `$ARGUMENTS`, interpret it as that request.
Implement **one** ticket: $ARGUMENTS. You are already in its worktree, and the ticket is already claimed for you.
The dispatcher (`orchestrator/tick.mjs`) has done the setup: the ticket is `In Progress`, assigned, labelled `ai:in-progress` + `agent:claude-code`, and this worktree was created by the repo's own `worktree-up.sh` with its own branch, ports and database. **Do not create another worktree, do not claim another ticket, and do not work anything except this one.** This is the dispatched path, so it is always exactly one ticket — the protocol's human-requested ticket bundles (`docs/protocol.md` §6) never arrive here.
## Do
1. **Read the ticket** and restate your approach (plus boundary types or state invariants on `tier:strong` or cross-module work) as a comment on it. Assume the operator is AFK — never pause for confirmation; resolve open implementation details (module structure, naming, internal data/error shape, edge-case defaults consistent with acceptance criteria) from `origin/<base>` conventions, sibling modules, tests, git history, and `docs/product-decisions.md`, stating any non-obvious reversible assumption in your approach comment.
2. **Implement**, touching only files matching its `Owned Paths`. Work discovered outside that set becomes a new `Triage` issue — never a widening of this one.
- **Fix root causes, not symptoms:** Before editing, trace why the defect or invalid state enters the system. When the ticket's `Verification Command` runs a fast local check for a bug, run or add the regression test _before_ the fix and observe it fail for the expected reason. A guard is a fix only when the state it handles is legitimate domain state — never paper over ordering, lifecycle, or state bugs with `setTimeout` / `requestAnimationFrame` delays, blind retries, clamped values, or catch-and-swallow blocks.
- **Do not copy adjacent weeds:** If nearby code uses a deprecated helper, `any`, or an ad-hoc workaround, follow `AGENTS.md` and clean module boundaries rather than replicating local tech debt, while still matching the repo's established architecture and naming conventions.
- **No silent suppressions or workaround-alibi comments:** Do not add `eslint-disable`, `biome-ignore`, `@ts-expect-error`, `@ts-ignore`, `as any` / `as unknown as` type escapes, or multi-line comments excusing why a quick patch was used instead of fixing the root cause. **Boundary escape valve:** when a third-party type definition, generated file, or documented platform/runtime quirk genuinely leaves no clean in-scope alternative, an escape hatch is allowed _only_ if narrowed to the single line or expression and paired with a concrete citation (upstream bug/spec URL, external `file:line`, or a newly filed `Triage` issue ID) — never as a convenience shortcut.
- **Explore 2–3 options on net-new UI or layout redesigns (`principle-exhaust-the-design-space`):** On net-new UI surfaces, material layout/flow redesigns, or explicit exploration requests (never routine bugfixes), articulate 2–3 distinct layout/interaction directions inside `Owned Paths`, prototype/render boundedly if helpful (`$TMPDIR/<ISSUE-ID>-*.patch`, never `git stash`), autonomously select and commit only the winner without stalling on an AFK operator, and record the explored options + winner rationale in your ticket comment and `## Handoff` (`Risks`).
- **Render, visually self-polish (≥1 pass), and retain screenshots on any UI-affecting change (`principle-experience-first`):** Even when Step 4's multi-journey `factory-ux-critic` is skipped (isolated styling, copy-in-layout, admin views), render the live UI, capture a bounded screenshot (not just accessibility snapshots; never `Read` the image back), critique hierarchy, spacing rhythm, alignment, contrast, truncation, and states coldly, and iterate **at least once** to polish rough first-draft UI before Step 3. Retain 1–4 final post-polish screenshots outside the repo (`≤ 1 MB` each) for Step 6 / interactive output.
- **Cold self-diff check before verification:** Read `git diff` against `origin/<base>` cold before running Step 3. Confirm every touched file matches `Owned Paths`, every new test would fail without your behavioral fix (not mock-tautological), and every added comment, timer, or suppression satisfies the rules above.
3. **Verify** on the final tree with targeted tests + fast static gates only: run the ticket's exact `Verification Command` (plus targeted test files covering the change — never `bun test`, full repo test suites, or whole-project coverage thresholds unless cross-cutting blast radius genuinely requires it, as CI covers full suites and concurrent dispatched worktrees make full runs a load-induced flake source) and the repo's fast pre-push static gates (configured `verify` command, or fast lint/format/typecheck on touched scope when `verify` is unset) so trivial static failures never burn a CI cycle. Attribute full-suite runs and project-wide coverage thresholds to CI, and name any deferred full suite or coverage check explicitly as residual risk under `Risks` in `## Handoff`. Never proceed past failing output; never weaken a test to get green. Never background, Monitor-wait, or `sleep`-wait a ticket's own verify step — but that is not a license to trust a framing exit code: for a verify command expected to exceed ~10 minutes, use the floor's status-file idiom (`shared/floor.md` §Waiting — command writes its own exit code to a status file with output to a log file, then poll for the status file with repeated short calls), because the Bash tool auto-backgrounds any foreground command that outlives its timeout and the framing exit code is not the command's.
4. **UX critique** after verification and before opening the PR when this introduces or materially changes a user-completable flow, interaction, state transition, error/recovery path, responsive layout, authentication, payment, onboarding, or destructive action. Spawn `factory-ux-critic`, fix in-scope `FIX-FIRST` findings, maximum 2 rounds, and file the rest to `Triage`. Skip it for isolated styling, copy-only edits, static content, icons/assets, and internal/admin-only surfaces unless the ticket identifies UX risk — skipping `factory-ux-critic` never skips Step 2's own rendered visual self-polish pass and screenshot capture when UI rendering is affected. State `UX critique: required` or `UX critique: skipped — <reason>` in the PR.
**The spawn prompt must carry the environment, spelled out** — the subagent does not inherit your working directory, and sibling worktrees for other tickets exist right now:
- `worktree: <absolute path>` — this worktree's root, written out in full. Never "the current directory".
- **How to launch and reach the app**: dev server command and **this worktree's** port (not the repo default — `worktree-up.sh` assigned it a non-colliding one), or simulator target / `electronAppPath`, plus `bin/dev-login.sh [role]` where the repo has it.
- `artifactDir: <absolute path>` — a pre-created, writable directory outside the worktree (for example `ux-screenshots/` in this run's Factory workspace, or a session scratch directory interactively) where `factory-ux-critic` saves bounded `.png` captures.
A returned `VERDICT: BLOCKED - environment mismatch or unresponsive shell` is a defect in _your_ spawn prompt, not a UX finding: fix the missing or wrong path/launch details and re-spawn once. That re-spawn doesn't count against the 2-round limit — no review happened. If it blocks a second time, record `UX critique: blocked — <what the environment did>` and continue; do not keep re-spawning.
**Comment critique (`factory-comment-sicko`)** runs in the same pre-PR gate whenever `git diff origin/<base>` adds any lint/type suppression (`eslint-disable`, `biome-ignore`, `@ts-ignore`, `@ts-expect-error`, `# noqa`, `# type: ignore`) or `>= 5` new comment lines (or any ticket-ID narration like `CLNT-`/`WM-`/`GH-` prose on routine code). Skip it silently when the diff adds neither. When triggered, follow `shared/skills/factory-no-comments/SKILL.md`: spawn `factory-comment-sicko` with `worktree: <absolute path>` and the current diff against `origin/<base>`, audit its report (at most 1 rerun on a defective report), delete accepted noise, fix in-scope `MUST KILL` workarounds/suppressions inside `Owned Paths`, and re-run Step 3's targeted verification on any touched files. Because `/factory-ticket` runs AFK by default, never pause for interactive approval on constraint comments — encode cheap in-scope checks directly or record unenforced constraints under `Risks` in `## Handoff` (and file out-of-scope root causes to `Triage`).
5. **Never `sleep` to wait for CI.** Use `factory wait-ci --pr <N>` (or `factory wait-ci <sha>` before a PR exists, and `factory wait-ci --pr <N> --no-wait` for a one-shot REST snapshot instead of `gh pr checks`). It uses GitHub's REST API exclusively at a 60s poll interval, retries initial run registration boundedly, follows superseded head pushes on PRs, and enforces the F-15 all-check-runs gate (`repos/<owner>/<repo>/commits/<sha>/check-runs`). Sleep-polling is blocked by the harness, and a blocked tool call **kills the run**. The same rule applies to any wait — poll a condition with a real command, never a fixed sleep.
6. **Push and open a PR** against the configured `base` for this repo in `config/repos.yaml`, never GitHub's default branch: `gh pr create --base <configured-base> --title "type(scope): plain summary (<ISSUE-ID>)" --body ...`. Read the opened PR's `baseRefName` back and stop if it differs from the configured base. Structure the PR body concisely: Problem/Context (1–2 sentences) → What changed (behavior bullets, not a symbol catalog) → `## UX Evidence` (when UI-affecting) → Verification (exact command + pass summary) → footer `Fixes <ISSUE-ID>` + concrete `run:<run-id>` via `printf 'run:%s\n' "$FACTORY_RUN_ID"` (never a literal variable reference; in interactive sessions when `$FACTORY_RUN_ID` is unset, end with the model and harness instead). Post the mandatory structured **`## Handoff` comment** on the ticket before transitioning state:
```
## Handoff
- PR: <url>
- Verification: `<the ticket's exact command>` — pass, <one-line result summary>
- UX critique: required — SHIP | required — FIX-FIRST resolved in <n> round(s) | required — NOT-ASSESSED, <what could not be driven> | blocked — <what the environment did> | skipped — <reason>
- Files: <n> changed, all within Owned Paths (or: exceptions listed with why)
- Risks: <what the reviewer should look at first, including any reversible engineering assumptions made without blocking, or "none known">
```
Then move the ticket to `In Review` + `ai:needs-review`, remove `ai:in-progress`. Posting this comment is a mandatory prerequisite before transitioning to `In Review` — the merge stage reviews directly from this comment, so a vague Handoff costs a slower review; a missing one is a protocol violation. Any UI-affecting handoff must deliver reviewable visual evidence (or state a concrete, justified exception — a workspace path, bare hash, or claim that a screenshot was taken is not reviewable; prefer bounded mobile or element-scoped captures, do not `Read` captures back, and never commit screenshots, videos, or plans to the repo):
- **PR media upload (`factory artifact pr-media` / `factory pr-media`):** Upload before/after screenshots (`--before <f> --after <f>`) for UI changes and a short video (`.mp4`/`.webm`) for motion, drag-and-drop, modals, or timing-sensitive interactions to `artifacts.watt-mind.com`, attaching inline Markdown to the PR (`--pr <num> --update-body` or `--comment`) and applying `has-screenshots` + `type:ui-ux`.
- **Dispatched runs (`$FACTORY_RUN_ID` set):** Also retain 1–4 post-polish PNGs (`≤ 1 MB` each) in `ux-screenshots/` alongside the worktree and declare each in `result.json` as `{"kind":"ux-screenshot","path":"ux-screenshots/<filename>.png"}` (if `FACTORY_ARTIFACT_TOKEN` is unavailable, fall back to plain-text `$FACTORY_WEB_URL/api/artifacts/<sha256>` links or state the concrete artifact-transport exception in the PR/Handoff).
- **Interactive sessions (`$FACTORY_RUN_ID` unset):** Upload to the PR via `factory artifact pr-media` (and optionally embed/link in your chat reply or walkthrough artifact).
Always report your explicit terminal state (`STATE: PR_OPEN`).
7. **Heartbeat** the ticket at each phase change and at least every 20 minutes, saying what changed. Silence for 45 minutes and the reaper takes the ticket back.
## Don't
**Never merge.** The merge stage reviews and lands PRs; a ticket agent that merges its own work bypasses the review gate entirely.
**Never touch another ticket's worktree.** Other agents are working concurrently in sibling directories with their own databases. Staying inside this one is what makes that safe.
## Security-sensitive work (`Never auto-merge`)
If the diff changes security-relevant behavior in auth/authz, payments, credential or secret handling, destructive migrations, production infra, `CLNT` security behavior, or paths matching `escalate_paths` in `config/repos.yaml`, implement and verify the in-scope change and open a PR for human review. Apply `ai:escalated` on the ticket and `escalated` on the GitHub PR (`gh pr edit <PR> --add-label escalated`, creating the label if missing), document the security-relevant behavior and risks in the PR and `## Handoff`, and notify with `factory notify "ESCALATED <TICKET/PR>: <one answerable sentence>"` (unless spawned inside `/factory-work`, which notifies centrally). Never merge it automatically, and escalate ambiguous cases too. Missing product intent or missing credentials still follow `STATE: BLOCKED` below; never expose secrets in the diff or review artifacts.
## When it goes wrong
Do not open a PR when blocked or failing. Distinguish genuine human blockers from execution failures — the operator is AFK by default:
- **Genuine human blocker (`STATE: BLOCKED`):** Strictly for unrecorded user-visible product-intent forks (after checking `docs/product-decisions.md`, `docs/`, and the tracker project overview), missing credentials or external access, or inseparable edits outside `Owned Paths`. Comment the ticket with the specific question or missing piece — phrased so one reply unblocks it — move it to `Blocked` + `ai:blocked` (removing `ai:in-progress`), run `factory notify "BLOCKED <ISSUE-ID>: <one answerable sentence>"` (unless spawned inside `/factory-work`, which notifies centrally), report terminal state `STATE: BLOCKED`, and stop. A blocked ticket with one clear question is a good outcome; a PR built on a product guess is not.
- **Implementation or verification failure with no human question (`STATE: FAILED`):** When verification stays red, the environment is broken, or you cannot converge cleanly within scope without needing a human decision, unclaim the ticket back to `Todo` (`factory ticket unclaim <ISSUE-ID>`) with a concise diagnostic comment naming what failed, report terminal state `STATE: FAILED`, and stop. Never park an execution failure in `Blocked` + `ai:blocked`.
## Capture session friction (interactive runs only)
**Skip when `FACTORY_RUN_ID` is set** — orchestrator runs already write transcripts to `~/.factory/logs/` for `/factory-retro` to measure.
When unset, scan the session for harness friction per `/factory-friction` before finishing. Report friction items filed (IDs) or **none observed** in the handoff comment or final message.