task-workspace
Provision, report, or attach a dedicated git worktree and branch for the active task so parallel tasks do not collide on one working tree. Opt-in, git-gated. Use when a task needs an isolated worktree and branch, or to attach one to an in-flight task. Do not use for the ephemeral slice-level worktrees implement-fleet manages, a non-git project, or closing the task (task-close owns teardown).
- License 许可
- MIT
- 最近更新
- 2026-10-10
- Stars
- ★ 10
- Forks
- 0
01 前言 Front Matter
- name
- task-workspace
- metadata
- { "tools": "Read, Write, Edit, Bash, Glob, Grep", "category": "state-and-navigation", "provenance": "first-party", "x-wos-profiles": "full", "suggested-model": "claude-opus-5-5", "multi-repo-aware": "false", "primary-cursor-mode": "Agent", "context-layers-consumed": "memory", "context-layers-produced": "memory" }
- description
- Provision, report, or attach a dedicated git worktree and branch for the active task so parallel tasks do not collide on one working tree. Opt-in, git-gated. Use when a task needs an isolated worktree and branch, or to attach one to an in-flight task. Do not use for the ephemeral slice-level worktrees implement-fleet manages, a non-git project, or closing the task (task-close owns teardown).
03 SKILL.md 正文
Act as a senior/staff engineering workflow workspace operator.
Goal: Provision a dedicated git worktree and branch for the active task on a git-backed project (or report the current one, or attach one to a task already in progress), so several tasks run in parallel on the same repository without colliding on one working tree or one checked-out branch. This is opt-in, git-gated, and additive: when isolation is not requested or the project is not a git repo, this command is a no-op and every other command behaves exactly as today.
This command is distinct from:
implement-fleet: which creates ephemeral, slice-level worktrees for parallel slices inside one task and tears them down at the wave merge. task-workspace creates one durable worktree for the whole task. When a task worktree is active, fleet slice worktrees branch from the task branch, not the repo base (ADR-0074 D-3).task-init: which creates the task memory folder and can invoke this command during initialization when isolation is requested. On an attended run with a remote, task-init also creates the task branch in place, with no worktree (ADR-0233); this command is for a task that needs a second working tree. task-workspace owns only the git worktree lifecycle, not the task-memory files.task-close: which owns teardown. task-workspace never removes a worktree;task-closerunsgit worktree removeplusgit worktree prunewith an unclean-tree guard (ADR-0074 D-5, D-6).
See ADR-0074 for the contract this command implements.
Mandatory context bootstrap (before any output):
- Resolving the spec and
wos/<topic>.md: canonical repository FIRST. Otherwise use active-adapter docs:~/.claude/workflow-docs(CLAUDE_WORKFLOW_DOCS_DIR),~/.cursor/workflow-docs(WORKFLOW_DOCS_DIR; project.cursor/workflow-docson project installs),~/.codex/workflow-docs(CODEX_WORKFLOW_DOCS_DIR), or<kimi-home>/workflow-docs(KIMI_WORKFLOW_DOCS_DIR). Nonempty overrides win. Kimi home:KIMI_CODE_HOME, else existing~/.kimi-code, else existing~/.kimi, default~/.kimi-code. Use one root for both paths; try other adapters if absent or unknown. Report resolved root, fallback to other adapters, or missing mandatory context in### Command transcript. Installed snapshots refresh and prune retired topics only on sync. - Read these sections in
WORKFLOW_OPERATING_SYSTEM.mdfirst:## LLM execution contract## Editor mode policy(mode definitions only; the tool mapping table is lazy-loaded inwos/editor-mode-mappings.mdand needed only for non-Claude-Code tools)## Global output contract(including Adaptive handoff and Mode selection rule)## Cross-cutting workflow guardrails
- Read additional sections only when relevant to this command's role:
## Multi-repo support (v1)(the SOURCE_OF_TRUTH workspace schema this command reads and writes; full detail inwos/multi-repo-support.md)
- Read the active task's memory:
SOURCE_OF_TRUTH.md(active codebase path, active or base branch, and any existing## Workspacesection)TASK_STATE.md(task slug, current phase, whether isolation was requested)
- Read canonical command inventory when a clone is available; otherwise use installed Fhorja commands and skills.
- Align all routing recommendations and next-command suggestions with the current command set.
- Official next-command names only: every recommended next command (including the handoff
Run nowline) MUST use a registered canonical command name or available installed Fhorja command or skill. Never invent names (invalid:worktree-add,task-worktree,provision). One exception:Run now: nonewithMode: N/Adeclares that the chain has ended and no following command would be honest, defined under### Official command names (routing integrity)(ADR-0126); use it only when nothing honest remains, never to end a chain that has a real next step.
Required inputs:
- active task folder path (
projects/<client>__<project>/active/YYYY-MM-DD_<task-slug>/) - SOURCE_OF_TRUTH.md (the target codebase path and its base branch)
- TASK_STATE.md (the task slug, used to derive the branch and worktree names)
- the requested action:
provision(default),status, orattach(retrofit a worktree onto an in-flight task) - intended editor mode (Agent to actually run git and persist the SOURCE_OF_TRUTH write; Ask or Plan to dry-run the proposed commands without touching the filesystem)
Operating rules:
- Do not implement production code. This command manages the git worktree lifecycle, writes one SOURCE_OF_TRUTH section and the
Task branch:andBase branch:lines in TASK_STATE.md; it changes no product code. - Handoff: end with the adaptive
### Handoffblock perWORKFLOW_OPERATING_SYSTEM.md## Global output contract(Mode A compact or Mode B full). - Git-gate first (ADR-0074 D-2). Run
git rev-parse --is-inside-work-treeon the target codebase path. IF it is not a git repository, return a shortNO_OP_TRACEnaming the gate and stop: this command does nothing on non-git projects, and the task continues on the single working tree unchanged. WHENSOURCE_OF_TRUTH.md ## Active codebase / repocarries aRecommended action:line fromtask-init's Git-authority preflight, theNO_OP_TRACESHALL cite that recommended action verbatim (for examplegit init -b main, requires human authorization) instead of only naming the gate, so the no-op still moves the git-authority decision forward. Zero new calls: this reuses thegit rev-parseresult and theSOURCE_OF_TRUTH.mdread this command already performs. - Opt-in (ADR-0074 D-2). Provision only when isolation is explicitly requested (the
provisionorattachaction, or an opt-in signal fromtask-init). Never provision a worktree as a side effect of another action. When isolation is not requested, this command is a no-op. - Naming conventions (ADR-0074). Let
<task-dir>be the full task-folder name (YYYY-MM-DD_<task-slug>, theactive/directory name, not the bare slug) so branch names stay unique across dates. Derive the task branch astask/<task-dir>and the worktree path as../<repo-basename>-worktrees/<task-dir>. Keep the worktree outside the main working tree so it is never nested inside the tracked repo. - Provision action. In Agent mode, create the worktree and branch off the base branch:
git worktree add -b task/<task-dir> ../<repo-basename>-worktrees/<task-dir> <base-branch>. The new worktree's HEAD comes from the base branch's committed HEAD, so uncommitted work in the main tree is not carried over (git-scm behavior; seeREFERENCES.md). In Ask or Plan mode, emit the exact command as aPROPOSEDstep and do not run it. - A task branch
task-initalready created (ADR-0233). Before the collision check, readTask branch:inTASK_STATE.md ## Resume notes. WHEN it names a branch, that name (a-2suffix included) SHALL be the task branch instead of the derived one. IF that branch is checked out in the main working tree THEN this command SHALL NOT provision: it returns theNO_OP_TRACEthe collision rule below names, because git checks a branch out in one working tree only and the slice work already sits on it. IF it is checked out nowhere THEN attach it withgit worktree add ../<repo-basename>-worktrees/<task-dir> <that branch>(no-b). - Branch-collision handling (git one-checkout-per-branch rule). A branch checks out in only one worktree at a time. Before
add, checkgit worktree listandgit branch --list task/<task-dir>. IFtask/<task-dir>already exists and is checked out in another worktree, do NOT--force. WHEN that worktree is the main working tree and the branch is this task's ownTask branch:(task-init created it in place, ADR-0233), return a shortNO_OP_TRACEsaying the task already runs on its branch there and that a separate worktree needs that branch checked out nowhere else first. Otherwise take the first free suffixed name (task/<task-dir>-2, then-3, with the worktree path taking the same suffix), provision on it, and name the suffix in the output instead of asking. IF the branch exists but is not checked out anywhere, attach it withgit worktree add ../<repo-basename>-worktrees/<task-dir> task/<task-dir>(no-b). - Attach action (retrofit). For a task already in progress, run the same provisioning against the current base branch and record the result, without touching any task-memory content other than the two writes below. This is the path that adopts a running task.
- Status action. Report the task's worktree path, branch, and
git worktree liststate read-only; write nothing. - Record the workspace (substrate write). On a successful provision or attach, write a
## Workspacesection intoSOURCE_OF_TRUTH.mdwith the worktree path, the task branch, and the base branch it was cut from. This is a substrate write: followcommands/_shared/substrate-write-protocol.md(transaction header above the section, one audit line in.wos/VERIFICATION_LOG.jsonl). - Record the task branch (ADR-0233). On the same success, this command SHALL write
Task branch: <the branch the worktree checks out>andBase branch: <the branch it was cut from>intoTASK_STATE.md ## Resume notes, replacing any earlier value of either line, under the same substrate-write protocol. A worktree task is then an attended chain on a task branch like any other, sobranch-commitandpr-packageread its branch from the same line. These two writes and## Workspaceare the only task memory this command writes. - Distinct from fleet (ADR-0074 D-3). Do not create, merge, or remove any
implement-fleetslice worktree. When a task worktree is active,implement-fleetbranches its slice worktrees offtask/<task-dir>; that behavior lives inimplement-fleet, not here. - Never tear down. This command does not remove worktrees or delete branches. Teardown is
task-close's responsibility (ADR-0074 D-5, D-6). If the user asks to remove a worktree, route totask-close. - Idempotency and no-op. IF the task already has a
## Workspacesection pointing at a live worktree (present ingit worktree list) and a matchingTask branch:line, return a shortNO_OP_TRACE; do not re-add or rewrite. - Multi-repo tasks (a
## Repositoriessection inSOURCE_OF_TRUTH.md) are out of scope for this version: do NOT provision. Return a short refusal naming multi-repo worktree provisioning as unsupported in v1, and ask the user to name the single repo to isolate (or to rungit worktreeper repo by hand). Never silently pick one repo out of several.
Required output:
- Git-gate result (git repo confirmed, or
NO_OP_TRACEfor a non-git project) - Requested action (
provision,status, orattach) and the derived branch and worktree path - Collision check result (branch free, attached to an existing branch, provisioned on a suffixed name, or
NO_OP_TRACEbecause the task's own branch is checked out in the main working tree) - The exact git command run (Agent) or proposed (Ask or Plan), with its real output when run
- The
## Workspacesection written toSOURCE_OF_TRUTH.md, or aNO_OP_TRACEwhen already provisioned - Recommended next command
- Recommended editor mode
- Why that is the correct next step
- What should explicitly not be done yet
Claim grounding (active epistemic humility)
Claim grounding (active epistemic humility). This block governs what you may assert and how you record it. It is keyed to the substrate section you are writing, not to which command is running, and it is INERT on any output that writes none of the claim-bearing sections below. Full contract and rationale: wos/active-epistemic-humility.md.
-
When this applies. This block fires ONLY while you are writing a claim-bearing substrate section:
TASK_STATE.md ## Current known facts,## Risks to watch,## Observations,## Active files in scope,## Canonical decisions;DECISIONS.md ## Locked decisions;IMPLEMENTATION_PLAN.md ## Current gaps,## Risks and mitigations;IMPACT_ANALYSIS.md;EXTERNAL_RESEARCH.md;REFERENCES.md; or any section whose content is a statement a later command or a human decision will act on. WHEN your output writes none of these, this block imposes nothing: skip it and proceed. This is the D-13 inert clause; a fully-grounded or claim-free output pays nothing. -
The unit is the load-bearing claim. A load-bearing claim is one a downstream command or a human decision consumes. A passing aside is not load-bearing; a statement someone will act on is. Apply the rest of this block per load-bearing claim, not per sentence.
-
Ground it or abstain. Before you assert a load-bearing claim, trace it to the enumerable grounded set: a captured
REFERENCES.mdentry, a file read in this session, command output actually seen, or a passing deterministic gate. A claim supported only by model memory is OUTSIDE the grounded set, including when you are right, because that support is not observable. WHEN a load-bearing claim falls outside the set, do NOT assert it: either investigate until it is grounded, or abstain per rule 6. -
Status records provenance, never confidence. WHERE you attach an epistemic status to a claim, the status names WHERE THE CLAIM CAME FROM: a
REFERENCES.mdentry title, a file path plus line, or the gate output it came from. It SHALL NOT express a degree of certainty. Do NOT add a confidence field, a numeric threshold, or a self-assessment prompt anywhere; a self-reported confidence signal is not a usable control signal (wos/active-epistemic-humility.mdPart 1.3). A status whose referent slot is empty is read as UNKNOWN, not as a weak yes. -
Persisted claims carry the status; chat-only claims carry it when they route. Every load-bearing claim you write into a task-memory artifact carries its provenance referent, and that referent travels with the claim so a later command reads it too; do not drop it at the write boundary. A load-bearing claim that appears only in a chat-turn output carries a status only when it crosses the grounding boundary and triggers a route (an abstention, an escalation).
-
Abstain as a routed continuation, never a bare refusal. WHEN you abstain, name the specific investigation that would settle the question AND route to the command that runs it (
capture-references,code-locate,incident-triage, or the fitting one). A withholding that stalls the work is invalid output. Abstention is distinct fromNO_OP:NO_OPmeans there is no work to do; abstention means there is work and the grounding to do it is missing. -
An unfired gate is not evidence. The absence of a fired check does not mean grounding existed. Do not read silence here as a pass.
Standard output layout (required)
Produce the command output using this structure (English only):
Artifact changes
Follow ## Global output contract in WORKFLOW_OPERATING_SYSTEM.md for APPLIED / PROPOSED / SKIP rules. Every listed file carries one of those three tokens, in Lean output too; a prose verb like "written" is not a label.
Command transcript
Brief audit trail (max 4 lines; max 3 in no-op runs with NO_OP_TRACE).
Handoff
Use the adaptive ending format of WORKFLOW_OPERATING_SYSTEM.md ## Global output contract. Every Handoff is one fenced text block with all four lines, Run now:, Mode:, Work complexity: and Reason:, on a stop and on a refusal too; the terminal form is Run now: none with Mode: N/A. A new Mode:, a model or a fresh session is never a stop, an offered choice is one, and Reason: names a role, never a model.
Definition of done (command output)
- The git-gate ran first: a non-git project returns
NO_OP_TRACEand no worktree is created. - Provisioning is opt-in: a worktree is created only for an explicit
provisionorattachaction, never as a side effect. - The derived branch (
task/<task-dir>) and worktree path (../<repo-basename>-worktrees/<task-dir>) follow the ADR-0074 conventions, and the branch-collision check ran before anyadd(no--force). - On a successful provision or attach in Agent mode,
SOURCE_OF_TRUTH.mdhas a## Workspacesection with the worktree path, task branch, and base branch, written per the substrate write protocol with one audit line, and markedAPPLIEDin every mode (ADR-0199);TASK_STATE.md ## Resume notescarries the matchingTask branch:andBase branch:lines (ADR-0233). - The command never removes a worktree or deletes a branch (teardown is
task-close), and never touches animplement-fleetslice worktree. - An already-provisioned task returns
NO_OP_TRACEinstead of re-adding. - Output ends with a complete
### Handoffblock per the adaptive format inWORKFLOW_OPERATING_SYSTEM.md## Global output contract. - Before declaring this output done, confirm it satisfies the shared Definition of done (command outputs) and Gate conditions in WORKFLOW_OPERATING_SYSTEM.md.
Quality bar:
Optimize for a safe, opt-in, git-gated provision that never forces a branch, never tears down, and records exactly one workspace section and the task branch so downstream commands and task-close can find the worktree.
04 同仓库更多 Skills
fixture-status
Fixture skill that reads status only. Use when you want a quick status. Do not use when several plans run at once (use fixture-plan-fleet).
fixture-plan
Fixture skill that plans a thing end to end. Use when the plan is missing. Do not use when you only need a status read.
fixture-plan-fleet
Fixture skill, the fleet variant of fixture-plan. Use when several plans run at once. Do not use for a single plan (use fixture-plan).
fixture-status
Fixture skill that reads status only. Use when you want a quick status. Do not use when several plans run at once (use fixture-plan-fleet).
fixture-plan
Fixture skill that plans a thing end to end. Use when the plan is missing. Do not use when you only need a status read (use fixture-status).
fixture-plan-fleet
Fixture skill, the fleet variant of fixture-plan. Use when several plans run at once. Do not use for a single plan (use fixture-plan).