home / skills / shotaiuchi / dotclaude / wf0-restore

This skill restores an existing workspace to resume work across devices by reloading state, branches, and optional worktrees.

npx playbooks add skill shotaiuchi/dotclaude --skill wf0-restore

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.2 KB
---
name: wf0-restore
description: 既存のワークスペースを復元
argument-hint: "[work-id]"
---

**Always respond in Japanese.**

# /wf0-restore

Restore an existing workspace for resuming work on a different PC or recreating a worktree.

## Usage

```
/wf0-restore [work-id]
```

## Arguments

- `work-id`: Optional. Uses `active_work` from state.json, or presents candidates via AskUserQuestion.

## Processing

### 1. Check Prerequisites

Require `jq` and `git`.

### 2. Resolve work-id

Argument → `active_work` → AskUserQuestion with available work-ids (show branch and current phase for each).

### 3. Fetch Remote

`git fetch --all --prune`

### 4. Restore Branch

Get branch/base from state.json. Check local branch → remote branch → error if neither exists. Checkout accordingly.

### 5. Restore Worktree (Optional)

If `config.worktree.enabled`: create worktree if not exists, update `.wf/local.json` with path.

### 6. Update active_work

Set `active_work` in state.json.

### 7. Display Status

Show: Work ID, Branch, Base, Current phase, Next phase, Docs path, next step command.

## Notes

- Error if state.json missing or work-id not found
- Worktree root directory created automatically

Overview

This skill restores an existing workspace so you can resume work on another machine or recreate a worktree. It automates validation, branch checkout, optional worktree creation, and state updates so the workspace is ready to continue where you left off. It reports a clear next-step command and workspace metadata after completion.

How this skill works

The skill requires jq and git, then resolves the target work-id from the argument, the saved active_work, or an interactive selection. It fetches remotes, determines whether to checkout a local or remote branch, and fails if neither exists. If worktree support is enabled, it creates the worktree and writes the local path into .wf/local.json. Finally it updates active_work in state.json and prints summarized status and the recommended next command.

When to use it

  • Moving development to a different PC and needing the same workspace layout
  • Recovering a workspace after cloning or re-cloning a repository
  • Recreating a lost or accidentally removed worktree for ongoing work
  • Switching machines during a multi-machine workflow
  • Preparing a CI or ephemeral environment to continue an interrupted task

Best practices

  • Ensure jq and git are installed before running the skill
  • Keep state.json and config files committed or backed up so the skill can find work metadata
  • Run git fetch --all --prune manually if you suspect stale refs before restore
  • Verify branch and base exist remotely if not present locally to avoid errors
  • Enable worktree in config only when you want per-work directories maintained

Example use cases

  • Restore the workspace for work-id 123 to continue a code review on a different laptop
  • Recreate a per-feature worktree after cloning the repository on a new build server
  • Resume work automatically by calling the skill with no argument when active_work is set
  • Select from several candidate work-ids when you are unsure which task was active

FAQ

What happens if state.json is missing?

The skill fails early with an error indicating state.json is required and halts to avoid guessing workspace metadata.

How does the skill choose which branch to checkout?

It prefers a matching local branch, falls back to the corresponding remote branch, and errors if neither exists.

Will the skill create the worktree directory for me?

Yes — if config.worktree.enabled is true the skill creates the worktree root and updates .wf/local.json with the path; otherwise it skips worktree steps.