Routing entry point for the Claude Code workflow. Inspects #N and the intent:clarified label: Path A (skip interview), Path B (pre-fill interview), Path C (full interview + auto-create).
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 Workflow Init?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nirecom-workflow-init)
---
name: workflow-init
description: Routing entry point for the Claude Code workflow. Inspects #N and the intent:clarified label: Path A (skip interview), Path B (pre-fill interview), Path C (full interview + auto-create).
model: sonnet
---
IMPORTANT: Interactive session required. Hard-fail in non-interactive contexts (`claude -p`, `/loop`, subagents).
## Purpose
First step of every workflow session. Routes on GH issue context: Path A (`#N` + `intent:clarified`) skips interview; Path B (`#N`, no label) pre-fills interview; Path C (no `#N`) runs full interview and auto-creates a tracking issue.
## Procedure
Read `rules/github-issues.md` before WI-2 — on-demand-only, never auto-injected; the `meta` label, `intent:clarified`, `closes_issues` insertion order, and the sub-issue open-state gate all come from it.
### WI-1 — Resolve <PLANS_DIR>
Canonical: `skills/_shared/resolve-plans-dir.md`. Substitute the resolved absolute path for every `<PLANS_DIR>` placeholder below. Subagent prompts must receive literals — they cannot expand `$VAR`.
### WI-1a — Repo migration
Invoke `/migrate` via the Skill tool on every run with `ROOT` = `git rev-parse --show-toplevel` of the CWD; it owns the judgment. `MIGRATE_RESULT=ok` or `MIGRATE_RESULT=skipped` → WI-2; `MIGRATE_RESULT=failed` → show the `/migrate` output and stop.
### WI-2 — Driver loop
The driver (`bin/workflow/workflow-init-driver`) handles WI-3..WI-9: token detection, `gh issue view` fetch for each N in `ISSUES`, CLOSED detection, label extraction, meta classification (meta strip / open sub-issue guard), Aggregate WIP check (all N: all_same / all_none / any_other), route decision, and context.md write. The driver writes the checkpoint and `<SID>-context.md` directly under PLANS_DIR (outside git repos → ENFORCE_WORKTREE does not apply).
Invocation: `node "$AGENTS_MAIN_ROOT/bin/workflow/workflow-init-driver" <raw-tokens> 2>/dev/null`
(`<raw-tokens>` = issue number tokens like `#15` or `#15 #22` — not the full user prompt)
On resume (after `ask_user`): `node "$AGENTS_MAIN_ROOT/bin/workflow/workflow-init-driver" --resume <CHECKPOINT> --answer '<token>'`
Read all `KEY=VALUE` output lines. Dispatch on `ACTION=`:
| ACTION | Meaning | What to do |
|---|---|---|
| `invoke` | Next skill ready | Run `NEXT_SKILL` via Skill tool |
| `done` | Driver complete | Send the recorded PM notifications per `skills/_shared/pm-notify.md`, run WI-2a, then WI-10; follow `PATH_DECISION=` at WI-12 (Path C still runs WI-10 onward — no jump) |
| `blocked` | Unrecoverable | Show `REASON=` + `NEXT_HINT=` and stop; on `REASON=multi-pm`, first send per `skills/_shared/pm-notify.md` |
| `ask_user` | User decision needed | Percent-decode `OPTIONS_DISPLAY=` (encoded like `QUESTION=`), present via `AskUserQuestion` with `metadata.source=workflow-init.<ASK_ID>` (`ASK_ID=` without a trailing `_<N>`); re-invoke with `--resume <CHECKPOINT> --answer '<token>'` |
| `emit_sentinel` | Driver requests sentinel | Emit `SENTINEL=` via separate Bash call |
`ask_user` interruptions and their options:
- `ASK_ID=wip_conflict`: Issue(s) #<CONFLICTED> are in progress in another session. Driver answers: Continue (recommended) / Abort. On Continue: for each N in `ISSUES`, driver runs `wip-state set <N>` (override for `other`; claim for `none`; idempotent for `same`). On Abort: `ACTION=blocked REASON=user_aborted`.
- `ASK_ID=wip_rc2`: wip-state set rc=2 for #N. Driver answers: Continue (acknowledge risk — driver treats as none, proceeds) / Abort.
- `ASK_ID=wip_error`: wip-state check failed (transient auth / session-id resolution failure — check `$CLAUDE_CODE_SESSION_ID`, rc=non-zero). Driver answers: Continue (treat as none, proceed) / Abort. Advisory: driver logs `[wip-state check failed for #N — proceeding as 'none']`.
- `ASK_ID=closed_reopen_<N>`: Issue #N is CLOSED. Driver answers: `reopen` / `remove` / `abort`. Remove is only offered when `len(closes_issues) >= 2`.
- `ASK_ID=meta_select`: meta issue has open sub-issues. Driver answers: `#<M>` (select sub-issue) / `abort`.
- `ASK_ID=fetch_failed_path_c`: `gh issue view` fetch failed. Driver answers: `continue` (Path C) / `abort`.
`PATH_DECISION=` values on `ACTION=done`:
- `A` — all N carry `intent:clarified` (and `FORCE_PATH_B` is not set from a fresh WIP claim).
- `B` — any N lacks `intent:clarified` OR WIP was freshly claimed for all N (`FORCE_PATH_B=true`). ALL_NONE path: `none` + for each N in `ISSUES`, `wip-state set <N>` (from fresh claim), then set `FORCE_PATH_B=1` — even when `intent:clarified` is present, FORCE_PATH_B routes to B. ISSUES[0] becomes closes_issues[0]; all entries become closes_issues in insertion order. ISSUES[@] are processed symmetrically.
- `C` — zero issues (`ISSUES=()`) OR `NON_GITHUB=1`.
- `META` — all issues carry `meta` label and have no open sub-issues.
### WI-2a — PM instructions
Run `node "$AGENTS_MAIN_ROOT/bin/pm-instructions" --timing session-start --checkpoint '<CHECKPOINT>'` (escape each `'` in the path as `'\''`).
Non-empty stdout → follow it for this session.
Non-zero exit → show its stderr line to the user and continue to WI-10.
### WI-10 — Parallel survey launch (all Paths)
Dispatch the `survey-code` + `survey-history` subagents per `skills/_shared/subagent-concurrency.md` SC-P (independent — distinct artifact paths, neither reads the other's output). For each: prompt `session-id=<resolved>`, `context_path=<PLANS_DIR>/<session-id>-context.md`, `artifact_path=<PLANS_DIR>/<session-id>-survey-{code|history}.md`, instruct to read context_path + follow `skills/<survey-code|survey-history>/SKILL.md` Procedure, write to artifact_path, do NOT invoke make-outline-plan. Substitute `<PLANS_DIR>` with the absolute path resolved at WI-1.
Each prompt also carries the canonical line of the `rules/shell-commands.md` Subagent Dispatch Prompts section.
Note: the Stop-guard silence during dispatch is automatic (PostToolUse marks the step `in_progress`). Do not emit `NEXT_STEP_PAUSE`.
### WI-11 — Post-check
Apply `skills/_shared/survey-artifact-valid.md` to each artifact. On invalid: emit `<<WORKFLOW_SURVEY_AGENT_FAILED: survey-code>>` or `<<WORKFLOW_SURVEY_AGENT_FAILED: survey-history>>`. Fall through to WI-12 on failure — do NOT abort. `clarify-intent` handles missing-or-invalid artifacts.
### WI-12 — Path-specific in-skill steps
#### Path META — meta label issue
WI-8 open sub-issue guard ensures all `ISSUES[@]` have no open sub-issues before reaching this path.
- PM1. `node "$AGENTS_MAIN_ROOT/bin/workflow/set-deliverable-type" --session "$SESSION_ID" --type wf-meta --advance --step workflow_init --complete` (single Bash call — records `deliverable_type` and completes `workflow_init` together; no `--next` since the next action is fixed at PM2).
- PM2. `echo "<<WORKFLOW_CLARIFY_INTENT_NOT_NEEDED: meta issue — WF-META type; intent confirmed from issue body>>"`.
- PM3. Use `/issue-create --skip-survey` with `--verdict bulk-sub-of --parent <meta-N> --manifest <file>` to create all planned sub-issues under the meta parent in a single bulk pass, then send the PM notifications per `skills/_shared/pm-notify.md`.
- PM4. Invoke `make-outline-plan`. (next-step auto-skips `detail` and 8 other non-applicable WF-CODE steps after outline completes — `make-detail-plan` is never invoked in WF-META.)
#### Path A — intent:clarified
- A1. Write the intent to the path `node "$AGENTS_MAIN_ROOT/bin/plan-artifact-path" --step clarify_intent` prints (`<PLANS_DIR>/<first_session_id>-intent.md`; on CLI failure halt and report its stderr) (strip sentinels from body): `# Agreed Requirements — <session-id>`, then immediately a `**Title:** <human-readable one-line title>` line (same data contract as clarify-intent CI-4), `## Issues` (one `- #<N>: <title>` line per entry in `ISSUES[@]`, in insertion order, no annotations), `## Glossary` (empty body), `## Background / Motivation`, `## Scope / Constraints`, `## Accepted Tradeoffs (intent)` (body: the empty marker of `skills/_shared/no-upstream-copy.md`; the outline stage writes its own). Title for each N from WI-4's `gh issue view`; fetch failure → `- #<N>: (title unavailable)`. **Never omit `## Issues`** or **`## Accepted Tradeoffs (intent)`** (a legacy `## Accepted Tradeoffs` is also read) — latter is `detail-planner.md` Approved Scope gate. `## Issues` is SSOT for `closes_issues` (canonical parser: `hooks/lib/parse-closes-issues.js`). `ISSUES[0]` is the first entry; it becomes `closes_issues[0]`; this entry becomes `closes_issues[0]`.
- A2. **Label + board-card parity for all N.** Invoke `skills/workflow-init/scripts/path-a-label-and-board.sh` with `"${REPO_MAP_ARGS[@]}"` followed by all entries of `ISSUES[@]` as positional args; export `SESSION_ID`, `AGENTS_MAIN_ROOT`. Adds `intent:clarified` (`--add-label "intent:clarified"`) to each related entry (fail-closed — on failure writes ABORT marker `<CONTROL_DIR>/workflow-init-aborted-pathA-multiN-label-failure.md` + exit 1). For every issue it runs `ensure-board-card.sh` (best-effort, warn-and-continue). Both idempotent.
- A3. `node "$AGENTS_MAIN_ROOT/bin/workflow/next-step" --advance --step workflow_init --complete` (no `--next` — the next action is fixed at A3a, not next-step's judgment), then, unchanged, as a separate Bash call: `echo "<<WORKFLOW_CLARIFY_INTENT_NOT_NEEDED: issue #{N} has intent:clarified label>>"`.
- A3a. **Complexity evaluation + outline-skip judgment**: follow `skills/_shared/complexity-and-outline-skip.md` end to end; its COS-3 outcome resumes here at A4.
- A4. Invoke `make-outline-plan` (surveys already complete via WI-9).
> When `--advance` is called without `--next`, no `ACTION=` block is ever emitted — proceed directly to the next documented in-skill step above rather than waiting on `next-step`'s judgment.
#### Path B — issue exists, no intent:clarified
- **B1.** Run `node "$AGENTS_MAIN_ROOT/bin/workflow/render-issue-comments" --checkpoint '<CHECKPOINT>' --issue <N>` against the driver's own `CHECKPOINT=` value and the same `<N>` B2 seeds; on a non-zero exit discard its stdout and keep its stderr out of every artifact; when that path holds an apostrophe, replace each `'` in it with `'\''` before pasting.
- **B2.** Write `<PLANS_DIR>/<session-id>-issue-prefill.md` with `<!-- Issue #<N> seed for clarify-intent. Confirm framing, do not start from scratch. -->`, `# Issue #<N>: <title>`, `<body>`, then B1's stdout verbatim, separated by one blank line; on a non-zero B1 rc omit the comments section entirely and fabricate no replacement.
- **B3.** `echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>"` (separate Bash call).
- **B4.** Invoke `clarify-intent` with `#<N>` in args so CI-1a auto-detect fires.
#### Path C — no issue
- C1. `echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>"` (separate Bash call).
- C2. Invoke `clarify-intent` (no pre-fill).
## Skip Conditions
Cannot be skipped. For docs-only bypass: `echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>"` directly.