一键导入
workflow-init
Routing entry point for the Claude Code workflow. Inspects
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Routing entry point for the Claude Code workflow. Inspects
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Conduct a decision-tree interview with the user to lock in requirements, motivation, scope, and non-goals before planning.
Stage 3 of three-stage planning pipeline. Produce a file-level implementation plan via detail-planner/detail-reviewer loop, then get user approval. Inputs are confirmed intent (<session-id>-intent.md) and outline (<session-id>-outline.md) from prior stages.
Edit source code for the current task. Delegates editing and lint/typecheck/self-repair to a subagent.
Plan and write test cases with high reasoning effort. Test iteration runs in a subagent to minimize confirmations.
Explore the codebase to understand existing patterns, constraints, and relevant files before planning.
Investigate git history, docs/history.md, and GitHub issue/PR timeline since the relevant issue opened, to surface changes that may invalidate the issue's premises.
| name | workflow-init |
| description | Routing entry point for the Claude Code workflow. Inspects |
| model | sonnet |
IMPORTANT: Interactive session required. Hard-fail in non-interactive contexts (claude -p, /loop, subagents).
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.
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.
Canonical: skills/_shared/non-github-remote-gate.md. NON_GITHUB=1 → skip Steps WI-3..WI-8 (issue detection / gh issue view / route logic), proceed as Path C. Steps WI-9..WI-12 (context.md write, survey launch, C1–C2) run as normal.
#NRegex (?:[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)?)?#\d+ (detects all three forms: #N, repo#N, owner/repo#N):
node "$AGENTS_CONFIG_DIR/bin/parse-issue-tokens" "<token>" to get [{number, repo?}]. Set ISSUES=(<number>). If repo is present and short-form (no /), resolve via gh repo view "<repo>" --json owner,name --jq '.owner.login + "/" + .name'; on failure, use AskUserQuestion to confirm CWD fallback. Build REPO_MAP_ARGS array: for each entry with repo field set, add --repo-map 0:<resolved-owner/repo>.node "$AGENTS_CONFIG_DIR/bin/parse-issue-tokens" <tokens...> to get [{number, repo?}] for each. For each entry with repo field: if short-form (no /), resolve via gh repo view "<repo>" --json owner,name --jq '.owner.login + "/" + .name'; on failure, AskUserQuestion to confirm CWD fallback (do NOT silently fall back). Build REPO_MAP_ARGS array: for each entry at index i with repo set, add --repo-map i:<resolved-owner/repo>. Pass bare issue numbers AND "${REPO_MAP_ARGS[@]}" to bash "$AGENTS_CONFIG_DIR/skills/workflow-init/scripts/filter-primary-candidates.sh" "${REPO_MAP_ARGS[@]}" <bare-numbers...>. Pipe filter-primary-candidates.sh stdout lines to node "$AGENTS_CONFIG_DIR/bin/parse-issue-tokens" to recover [{number, repo?}] and rebuild ISSUES array and REPO_MAP_ARGS from filtered results. Set ISSUES=(<numbers, in emission order>). ISSUES[0] becomes closes_issues[0]; all entries become closes_issues in insertion order; no AskUserQuestion is fired.CLAUDE_SESSION_ID from $CLAUDE_ENV_FILE; fallback date +%Y%m%d-%H%M%S. Set SID_PASS=(--session-id "$CLAUDE_SESSION_ID") if resolved from $CLAUDE_ENV_FILE or $CLAUDE_SESSION_ID env; else SID_PASS=(). Then for each N at index i in ISSUES[@], run gh issue view <N> ${ISSUE_REPO[$i]:+--repo "${ISSUE_REPO[$i]}"} --json number,title,body,labels,state,createdAt and retain the JSON per-N. (ISSUE_REPO is the per-index repo map built in WI-3; local issues have no entry.) If ANY N's fetch fails, AskUserQuestion "Continue as Path C?" — yes: Path C; no: abort. (Symmetric: one session-level question regardless of which index failed.) ISSUES[0] (the first entry) is used downstream only as the Path B prefill seed (positional reference). CLOSED-state handling for all entries is deferred to WI-6.
Run bash "$AGENTS_CONFIG_DIR/skills/workflow-init/scripts/aggregate-wip-check.sh" "${REPO_MAP_ARGS[@]}" "${ISSUES[@]}". Output classifies and routes:
ALL_SAME <wip> → continue (this session already owns WIP on every issue).ALL_NONE → bash "$AGENTS_CONFIG_DIR/skills/workflow-init/scripts/wip-set-resume.sh" "${REPO_MAP_ARGS[@]}" "${ISSUES[@]}". Exit 0 (ALL_SET): WIP set for all eligible N's. Exit 1 (NEEDS_CLARIFY <N,...>): set FORCE_PATH_B=1; early-claim WIP for each OPEN non-meta N (best-effort; RC2 escalates with exit 2). clarify-intent Completion re-confirms WIP idempotently on all N. Exit 2 (RC2 <N>): AskUserQuestion "WIP set rc=2 for # (session-id/env failed). How to proceed?" → "Continue (skip WIP, acknowledge risk)" → warn + continue; "Abort session" → echo "<<WORKFLOW_ABORTED_WIP_CHECK_ERROR: #{N}>>" + stop.MIXED_SAME_NONE → for each N at index i where WIP == none, call bash "$AGENTS_CONFIG_DIR/bin/github-issues/wip-state.sh" "${SID_PASS[@]}" ${ISSUE_REPO[$i]:+--repo "${ISSUE_REPO[$i]}"} set <N> (best-effort) to bring related issues up to parity.ANY_OTHER <N,...> → let CONFLICTED=<list>. Single AskUserQuestion "Issue(s) # may be in progress in another session. Continue?" options Continue (recommended) / Abort. On Continue: for each N at index i in ISSUES, call bash "$AGENTS_CONFIG_DIR/bin/github-issues/wip-state.sh" "${SID_PASS[@]}" ${ISSUE_REPO[$i]:+--repo "${ISSUE_REPO[$i]}"} set <N> (override for other N; claim for none N; same N idempotent; best-effort per-N). On Abort: emit echo "<<WORKFLOW_ABORTED_WIP_CONFLICT: #{CONFLICTED}>>" and stop.ERROR <N,...> → AskUserQuestion "WIP check failed for #<N,...> (transient auth/gh error or session-id resolution failure — check $CLAUDE_ENV_FILE or $CLAUDE_SESSION_ID). How to proceed?" with two options: "Continue without WIP tracking (acknowledge risk)" → warn [workflow-init: wip-state check failed for #<N> — proceeding as 'none' for that issue] and treat each as none and continue; "Abort session" → emit echo "<<WORKFLOW_ABORTED_WIP_CHECK_ERROR: #{N,...}>>" and stop.Run bash "$AGENTS_CONFIG_DIR/skills/workflow-init/scripts/closed-detection.sh" "${REPO_MAP_ARGS[@]}" "${ISSUES[@]}". For each <N> closed: AskUserQuestion "Issue # CLOSED. How to proceed?" with options "Reopen and continue" / "Remove from session" (offered only when len(closes_issues) >= 2, ensuring at least 1 remains) / "Abort" (emit <<WORKFLOW_ABORTED_ISSUE_CLOSED: #N>>).
STATE=error → warn-and-continue (does NOT abort).
On "Reopen and continue": gh issue reopen <N> ${ISSUE_REPO[$i]:+--repo "${ISSUE_REPO[$i]}"} is executed (where i is N's index in ISSUES). Downstream in WI-12 Path A2, path-a-label-and-board.sh calls ensure-board-card.sh <N>. When the issue is OPEN and its board card Status is Done, ensure-board-card.sh resets Status to In Progress before any other board mutation, preventing the Projects v2 Done → auto-close loop (#579). If the reset fails, ensure-board-card.sh warns and exits 0 without modifying the board — the operator must inspect the warning and re-run ensure-board-card.sh <N> manually.
For each N in ISSUES[@], extract labels[].name from its gh issue view JSON. Retain per-N label sets for the route decision in WI-8.
If ALL issues in ISSUES[@] carry the meta label → Path META (WI-12 Path META). Before entering Path META: for each N at index i, resolve OWNER_REPO as follows: if ISSUE_REPO[$i] is set, use that value directly; otherwise run gh repo view --json nameWithOwner --jq '.nameWithOwner'. Then loop over ISSUES[@]: for each N at index i, run bash "$AGENTS_CONFIG_DIR/skills/workflow-init/scripts/list-open-sub-issues.sh" "$OWNER_REPO" "$N".
AskUserQuestion — one option per #M: title line from script stdout. If user selects a valid option: set ISSUES=($SELECTED_N), then gh issue view $SELECTED_N --json number,title,body,labels,state,createdAt to re-fetch per-N JSON cache and label set. Clear meta routing; fall through to standard FORCE_PATH_B / A/B routing. If user enters "Other" with a parseable #M: same re-fetch + fallthrough. If "Other" is unparseable: echo "<<WORKFLOW_ABORTED_META_SUBISSUE_SELECTION: invalid input>>" and stop.AskUserQuestion "sub-issue fetch failed for #N. How to proceed?" → "Continue to Path META" / "Abort (<<WORKFLOW_ABORTED_META_SUBISSUE_FETCH_ERROR: #N>>)".If any issue carries meta but not all → warn "mixed meta/non-meta issues — falling through to Path A/B" and continue with standard routing below.
If FORCE_PATH_B=1 (set by WI-5 ALL_NONE when not every N had intent:clarified, or when any label probe failed) OR any N in ISSUES[@] lacks the intent:clarified label → Path B. Only when every N carries intent:clarified → Path A. Path B is the default.
<PLANS_DIR>/<session-id>-context.md sections:
## Session metadata: session-id, ISO-8601 timestamp, path (A/B/C), issue-number (<N> or (none)).## User initial prompt: original user message; "(none)" if empty.## Issue body: full body (Path C: "(none — no issue)"); strip <<WORKFLOW_[A-Z_]+[^>]*>> sentinels.## Issue metadata: title, state, labels, createdAt (all (none) for Path C).## Keywords: ≥4-char tokens from user prompt + issue title + issue body; stop-word excluded; deduplicated; top 20 space-separated (Path C: user prompt only).In a single assistant message, invoke BOTH as parallel Agent tool calls (run_in_background: false). For each of survey-code / survey-history: 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. Inject all paths as resolved strings (orchestrator substitutes <PLANS_DIR> for the absolute path from WI-1) — Agent subagents cannot expand $VAR.
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-8 open sub-issue guard ensures all ISSUES[@] have no open sub-issues before reaching this path.
bin/workflow/set-workflow-type "$SESSION_ID" "wf-meta" (separate Bash call, before any sentinel).echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>" (separate Bash call).echo "<<WORKFLOW_CLARIFY_INTENT_NOT_NEEDED: meta issue — WF-META type; intent confirmed from issue body>>"./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.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.)<PLANS_DIR>/<session-id>-intent.md (strip sentinels from body): # Agreed Requirements — <session-id>, ## Issues (one - #<N>: <title> line per entry in ISSUES[@], in insertion order, no annotations), ## Background / Motivation, ## Scope / Constraints, ## Accepted Tradeoffs (none — capture at outline stage). Title for each N from WI-4's gh issue view; fetch failure → - #<N>: (title unavailable). Never omit ## Issues or ## Accepted Tradeoffs — latter is detail-planner.md Approved Scope gate. ## Issues is SSOT for closes_issues (canonical parser: hooks/lib/parse-closes-issues.js).node "$AGENTS_CONFIG_DIR/bin/cc-session-title" set-issue "$(pwd)" "<PLANS_DIR>"skills/workflow-init/scripts/path-a-label-and-board.sh with "${REPO_MAP_ARGS[@]}" followed by all entries of ISSUES[@] as positional args; export PLANS_DIR, SESSION_ID, AGENTS_CONFIG_DIR. Adds intent:clarified (--add-label "intent:clarified") to each related entry (fail-closed — on failure writes ABORT marker <PLANS_DIR>/<session-id>-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.echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>" then echo "<<WORKFLOW_CLARIFY_INTENT_NOT_NEEDED: issue #{N} has intent:clarified label>>".workflow_init + clarify_intent complete; remaining 8 steps pending.make-outline-plan (surveys already complete via WI-9).<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>.echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>" (separate Bash call).clarify-intent with #<N> in args so step 1a auto-detect fires.echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>" (separate Bash call).clarify-intent (no pre-fill).Cannot be skipped. For docs-only bypass: echo "<<WORKFLOW_MARK_STEP_workflow_init_complete>>" directly.