new-workspace
新しい実験や機能開発のために、Gitブランチやワークツリーを簡単に作成し、UV環境との連携もサポートすることで、安全かつ効率的な開発環境を構築するSkill。
📜 元の英語説明(参考)
Create a new Git branch or worktree for experiments or features. Use when starting a new experiment branch, creating an isolated workspace, or setting up a feature branch with worktree support and UV environment sync.
🇯🇵 日本人クリエイター向け解説
新しい実験や機能開発のために、Gitブランチやワークツリーを簡単に作成し、UV環境との連携もサポートすることで、安全かつ効率的な開発環境を構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o new-workspace.zip https://jpskill.com/download/8042.zip && unzip -o new-workspace.zip && rm new-workspace.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/8042.zip -OutFile "$d\new-workspace.zip"; Expand-Archive "$d\new-workspace.zip" -DestinationPath $d -Force; ri "$d\new-workspace.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
new-workspace.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
new-workspaceフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
新規 Git ワークスペース (ブランチまたはワークツリー) の作成
実験や機能のために、新規 Git ブランチまたはワークツリーを作成するユーザーを支援します。
ワークフロー
1. ワークスペースのタイプをユーザーに尋ねる
ユーザーに選択を促します。
- branch: 現在の作業ディレクトリに新しいブランチを作成します
- worktree: 別のディレクトリに新しいワークツリーを作成します
2. ブランチのタイプと名前を尋ねる
ユーザーにブランチのタイプを選択するように求めます。
- feature: 新機能用 (
feature/<name>を作成) - exp: 実験用 (
exp/<name>を作成)
次に、ブランチ名 (プレフィックスなし) を尋ねます。例:
- ユーザー入力:
authentication - 結果:
feature/authenticationまたはexp/authentication
3. 現在の Git の状態を確認する
何かを作成する前に、以下を確認します。
# Git リポジトリ内にいることを確認
git rev-parse --git-dir
# コミットされていない変更がないか確認
git status --porcelain
コミットされていない変更がある場合は、ユーザーに警告し、次のいずれかを行うか尋ねます。
- 変更を一時退避 (stash) して続行
- 最初に変更をコミット
- 操作をキャンセル
4. ブランチまたはワークツリーを作成する
オプション A: ブランチのみを作成
# 新しいブランチを作成してチェックアウト
git checkout -b <branch-type>/<branch-name>
成功メッセージと現在のブランチを表示します。
オプション B: ワークツリーを作成
手順:
-
プロジェクトのルートディレクトリを取得:
git rev-parse --show-toplevel -
ワークツリーのディレクトリ構造を作成:
# ワークツリーは次の場所に作成されます: <project-root>/../worktrees/<branch-name>/ PROJECT_ROOT=$(git rev-parse --show-toplevel) WORKTREE_DIR="$PROJECT_ROOT/../worktrees/<branch-type>-<branch-name>"
ワークツリーを作成
git worktree add "$WORKTREE_DIR" -b <branch-type>/<branch-name>
3. **IDE の構成ディレクトリを同期:**
プロジェクトのルートからワークツリーに IDE の構成フォルダーを自動的にコピーします。
```bash
# IDE の構成ディレクトリをコピー
for config_dir in .vscode .cursor .claude; do
if [ -d "$PROJECT_ROOT/$config_dir" ]; then
echo "Copying $config_dir configuration..."
cp -r "$PROJECT_ROOT/$config_dir" "$WORKTREE_DIR/"
echo "✓ $config_dir synced"
fi
done
重要: これらのディレクトリは、次の理由からコピー (シンボリックリンクではない) されます。
- 各ワークツリーは、必要に応じて独立した IDE 設定を持つことができる
- あるワークツリーでの変更が他のワークツリーに影響を与えない
- 実験/機能ごとに設定をカスタマイズできる
- .worktree-links 構成を確認:
プロジェクトのルートで .worktree-links ファイルを探します。
LINKS_CONFIG="$PROJECT_ROOT/.worktree-links"
if [ -f "$LINKS_CONFIG" ]; then
# リンクを読み込んで処理
while IFS= read -r line; do
# 空行とコメントをスキップ
[[ -z "$line" || "$line" =~ ^#.* ]] && continue
# ワークツリーから元の場所へのシンボリックリンクを作成
SOURCE="$PROJECT_ROOT/$line"
TARGET="$WORKTREE_DIR/$line"
if [ -e "$SOURCE" ]; then
# 必要に応じて親ディレクトリを作成
mkdir -p "$(dirname "$TARGET")"
ln -s "$SOURCE" "$TARGET"
echo "Linked: $line"
else
echo "Warning: Source not found: $line"
fi
done < "$LINKS_CONFIG"
fi
.worktree-links ファイルの形式:
# # で始まる行はコメントです
# プロジェクトのルートからの相対パスをリストしてリンクします
data/
models/
.env
configs/local_settings.yaml
- 新しいワークツリーで UV 環境を同期:
cd "$WORKTREE_DIR"
# pyproject.toml が存在するかどうかを確認 (uv を使用した Python プロジェクトを示す)
if [ -f "pyproject.toml" ]; then
echo "Syncing UV environment..."
uv sync
echo "UV environment synced successfully"
else
echo "No pyproject.toml found, skipping UV sync"
fi
- 概要を表示:
✓ Worktree created at: <worktree-path> ✓ Branch created: <branch-type>/<branch-name> ✓ Symlinks created: <count> items ✓ UV environment synced
To start working: cd <worktree-path>
### 5. エラー処理
一般的なエラーを処理します。
- **Git リポジトリ内にいない**: 明確なエラーメッセージを表示
- **ブランチが既に存在する**: ユーザーに次のいずれかを行うか尋ねます。
- 既存のブランチからワークツリーを作成 (該当する場合)
- 別の名前を選択
- キャンセル
- **ワークツリーのディレクトリが既に存在する**: 削除するか、別の名前を選択するように求めます
- **UV の同期に失敗**: エラーを表示しますが、ワークツリーの作成をロールバックしないでください
- **.worktree-links が見つからない**: シンボリックリンクを作成せずに続行 (これはオプション)
### 6. 追加機能
**オプション: 既存のワークツリーをリスト**
ユーザーがワークツリーオプションを選択した場合、最初に既存のワークツリーを表示します。
```bash
git worktree list
これは、ユーザーが既に何が存在するかを確認するのに役立ちます。
構成ファイルのテンプレート
プロジェクトに .worktree-links が存在しない場合は、一般的なデフォルトで作成することを提案できます。
# .worktree-links
#
# 新しいワークツリーで作成するシンボリックリンク
# プロジェクトのルートからの相対パスをリスト
# # で始まる行は無視されます
# エントリの例:
# data/
# models/
# .env
# configs/production.yaml
重要な注意点
- ワークツリーの分離: 各ワークツリーは独自の作業ディレクトリを持ちますが、同じ Git オブジェクトデータベースを共有します
- UV 環境: 各ワークツリーは、競合を避けるために独自の
.venv/(シンボリックリンクではない) を取得します - シンボリックリンクは絶対パス: シンボリックリンクでは絶対パスを使用して、ワークツリーの場所から確実に機能するようにします
- ブランチの追跡: 新しいブランチは、(リモートを追跡しない) ローカルブランチとして作成されます
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Create New Git Workspace (Branch or Worktree)
You are helping the user create a new Git branch or worktree for experiments or features.
Workflow
1. Ask User for Workspace Type
Ask the user to choose:
- branch: Create a new branch in the current working directory
- worktree: Create a new worktree in a separate directory
2. Ask for Branch Type and Name
Ask the user to choose the branch type:
- feature: For new features (creates
feature/<name>) - exp: For experiments (creates
exp/<name>)
Then ask for the branch name (without prefix). For example:
- User inputs:
authentication - Result:
feature/authenticationorexp/authentication
3. Verify Current Git State
Before creating anything, check:
# Ensure we're in a git repository
git rev-parse --git-dir
# Check for uncommitted changes
git status --porcelain
If there are uncommitted changes, warn the user and ask if they want to:
- Stash changes and continue
- Commit changes first
- Cancel operation
4. Create Branch or Worktree
Option A: Create Branch Only
# Create and checkout new branch
git checkout -b <branch-type>/<branch-name>
Show success message and current branch.
Option B: Create Worktree
Steps:
-
Get project root directory:
git rev-parse --show-toplevel -
Create worktree directory structure:
# Worktrees will be at: <project-root>/../worktrees/<branch-name>/ PROJECT_ROOT=$(git rev-parse --show-toplevel) WORKTREE_DIR="$PROJECT_ROOT/../worktrees/<branch-type>-<branch-name>"
Create worktree
git worktree add "$WORKTREE_DIR" -b <branch-type>/<branch-name>
3. **Sync IDE configuration directories:**
Automatically copy IDE configuration folders from project root to worktree:
```bash
# Copy IDE configuration directories
for config_dir in .vscode .cursor .claude; do
if [ -d "$PROJECT_ROOT/$config_dir" ]; then
echo "Copying $config_dir configuration..."
cp -r "$PROJECT_ROOT/$config_dir" "$WORKTREE_DIR/"
echo "✓ $config_dir synced"
fi
done
Important: These directories are copied (not symlinked) so that:
- Each worktree can have independent IDE settings if needed
- Changes in one worktree don't affect others
- You can customize settings per experiment/feature
- Check for .worktree-links configuration:
Look for .worktree-links file in the project root:
LINKS_CONFIG="$PROJECT_ROOT/.worktree-links"
if [ -f "$LINKS_CONFIG" ]; then
# Read and process links
while IFS= read -r line; do
# Skip empty lines and comments
[[ -z "$line" || "$line" =~ ^#.* ]] && continue
# Create symlink from worktree to original location
SOURCE="$PROJECT_ROOT/$line"
TARGET="$WORKTREE_DIR/$line"
if [ -e "$SOURCE" ]; then
# Create parent directory if needed
mkdir -p "$(dirname "$TARGET")"
ln -s "$SOURCE" "$TARGET"
echo "Linked: $line"
else
echo "Warning: Source not found: $line"
fi
done < "$LINKS_CONFIG"
fi
Format of .worktree-links file:
# Lines starting with # are comments
# List relative paths from project root to link
data/
models/
.env
configs/local_settings.yaml
- Sync UV environment in the new worktree:
cd "$WORKTREE_DIR"
# Check if pyproject.toml exists (indicating a Python project with uv)
if [ -f "pyproject.toml" ]; then
echo "Syncing UV environment..."
uv sync
echo "UV environment synced successfully"
else
echo "No pyproject.toml found, skipping UV sync"
fi
- Display summary:
✓ Worktree created at: <worktree-path> ✓ Branch created: <branch-type>/<branch-name> ✓ Symlinks created: <count> items ✓ UV environment synced
To start working: cd <worktree-path>
### 5. Error Handling
Handle common errors:
- **Not in a git repository**: Show clear error message
- **Branch already exists**: Ask if user wants to:
- Create worktree from existing branch (if applicable)
- Choose a different name
- Cancel
- **Worktree directory already exists**: Ask to remove or choose different name
- **UV sync fails**: Show error but don't rollback worktree creation
- **.worktree-links not found**: Continue without creating symlinks (this is optional)
### 6. Additional Features
**Optional: List existing worktrees**
If user chooses worktree option, first show existing worktrees:
```bash
git worktree list
This helps user see what already exists.
Configuration File Template
If .worktree-links doesn't exist in the project, you can offer to create it with common defaults:
# .worktree-links
#
# Symlinks to create in new worktrees
# List paths relative to project root
# Lines starting with # are ignored
# Example entries:
# data/
# models/
# .env
# configs/production.yaml
Important Notes
- Worktree isolation: Each worktree has its own working directory but shares the same Git object database
- UV environment: Each worktree gets its own
.venv/(not symlinked) to avoid conflicts - Symlinks are absolute paths: Use absolute paths in symlinks to ensure they work from the worktree location
- Branch tracking: New branches are created as local branches (not tracking remote)