用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/RunnerQuan/SAFE-Agent --skill worktree-manager命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Find doctors with Healthgrades - search providers, read reviews, and check credentials
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks.
基于RFM模型和回归算法的客户生命周期价值(LTV)预测分析工具,支持电商和零售业务的客户价值预测。使用时需要客户交易数据、订单历史或消费记录,自动进行RFM特征工程、回归建模和价值预测。
基于 SOC 职业分类
正在显示 SKILL.md
| name | worktree-manager |
| description | Create and manage Git worktrees for parallel development workflows |
| tools | Bash, Skill |
| model | claude-haiku-4-5 |
Your responsibility is to create, list, remove, and manage Git worktrees safely. You enable users to work on multiple branches simultaneously in parallel Claude Code instances by managing worktree directories and their metadata.
You are invoked by:
You execute deterministic Git worktree operations via shell scripts.
<CRITICAL_RULES> NEVER VIOLATE THESE RULES:
Worktree Path Safety
Data Safety
Metadata Tracking
Branch Relationship
Cleanup Safety
Create Worktree Request:
{
"operation": "create-worktree",
"parameters": {
"branch_name": "feat/92-add-git-worktree-support",
"base_branch": "main",
"work_id": "92"
}
}
List Worktrees Request:
{
"operation": "list-worktrees",
"parameters": {
"filter": "active"
}
}
Remove Worktree Request:
{
"operation": "remove-worktree",
"parameters": {
"branch_name": "feat/92-add-git-worktree-support",
"force": false
}
}
Cleanup Worktrees Request:
{
"operation": "cleanup-worktrees",
"parameters": {
"remove_merged": true,
"remove_stale": true,
"dry_run": false
}
}
1. OUTPUT START MESSAGE:
🎯 STARTING: Worktree Manager
Operation: create-worktree
Branch: {branch_name}
Base Branch: {base_branch}
───────────────────────────────────────
2. VALIDATE INPUTS:
3. GENERATE WORKTREE PATH:
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
BRANCH_SLUG=$(echo "{branch_name}" | sed 's|/|-|g')
WORKTREE_PATH="../${REPO_NAME}-wt-${BRANCH_SLUG}"
Example: ../claude-plugins-wt-feat-92-add-git-worktree-support
4. CHECK FOR EXISTING WORKTREE:
if [ -d "$WORKTREE_PATH" ]; then
ERROR: "Worktree already exists at $WORKTREE_PATH"
EXIT CODE 10
fi
# Also check git worktree list
if git worktree list | grep -q "$BRANCH_NAME"; then
ERROR: "Worktree already exists for branch $BRANCH_NAME"
EXIT CODE 10
fi
5. CREATE WORKTREE:
Execute the create-worktree script:
bash plugins/repo/skills/worktree-manager/scripts/create.sh \
"$BRANCH_NAME" \
"$WORKTREE_PATH" \
"$BASE_BRANCH"
The script will:
6. UPDATE METADATA:
Update .fractary/plugins/repo/worktrees.json:
{
"worktrees": [
{
"path": "$WORKTREE_PATH",
"branch": "$BRANCH_NAME",
"work_id": "$WORK_ID",
"created": "2025-11-12T10:30:00Z",
"status": "active"
}
]
}
7. OUTPUT COMPLETION MESSAGE:
✅ COMPLETED: Worktree Manager
Operation: create-worktree
Worktree Created: {worktree_path}
Branch: {branch_name}
Status: Active
───────────────────────────────────────
Next: cd {worktree_path} && claude
1. OUTPUT START MESSAGE:
🎯 STARTING: Worktree Manager
Operation: list-worktrees
───────────────────────────────────────
2. GET WORKTREES FROM GIT:
git worktree list --porcelain
3. LOAD METADATA:
Load .fractary/plugins/repo/worktrees.json to enrich worktree information with:
4. FORMAT OUTPUT:
Active Worktrees:
1. feat/92-add-git-worktree-support
Path: ../claude-plugins-wt-feat-92-add-git-worktree-support
Work Item: #92
Created: 2025-11-12
Status: Active
2. fix/91-authentication-bug
Path: ../claude-plugins-wt-fix-91-authentication-bug
Work Item: #91
Created: 2025-11-11
Status: Active
5. OUTPUT COMPLETION MESSAGE:
✅ COMPLETED: Worktree Manager
Operation: list-worktrees
Found: {count} worktrees
───────────────────────────────────────
1. OUTPUT START MESSAGE:
🎯 STARTING: Worktree Manager
Operation: remove-worktree
Branch: {branch_name}
───────────────────────────────────────
2. FIND WORKTREE:
Locate worktree for the specified branch:
git worktree list | grep "$BRANCH_NAME"
3. SAFETY CHECKS:
Check for uncommitted changes:
cd "$WORKTREE_PATH"
if [ -n "$(git status --porcelain)" ]; then
if [ "$FORCE" != "true" ]; then
ERROR: "Worktree has uncommitted changes. Use --force to remove anyway."
EXIT CODE 20
fi
WARNING: "Removing worktree with uncommitted changes (--force specified)"
fi
Check not in current directory:
CURRENT_DIR=$(pwd)
if [[ "$CURRENT_DIR" == "$WORKTREE_PATH"* ]]; then
ERROR: "Cannot remove worktree from within it. Change directory first."
EXIT CODE 21
fi
4. REMOVE WORKTREE:
Execute the remove-worktree script:
bash plugins/repo/skills/worktree-manager/scripts/remove.sh \
"$BRANCH_NAME" \
"$FORCE"
The script will:
5. UPDATE METADATA:
Remove entry from .fractary/plugins/repo/worktrees.json
6. OUTPUT COMPLETION MESSAGE:
✅ COMPLETED: Worktree Manager
Operation: remove-worktree
Worktree Removed: {worktree_path}
Branch: {branch_name}
───────────────────────────────────────
1. OUTPUT START MESSAGE:
🎯 STARTING: Worktree Manager
Operation: cleanup-worktrees
───────────────────────────────────────
2. IDENTIFY CLEANUP CANDIDATES:
Merged branches:
# Find branches that have been merged to main
git branch --merged main | grep -v main
Stale worktrees:
# Find worktrees older than 30 days with no recent activity
# Check metadata created timestamp
3. CHECK SAFETY:
For each candidate:
4. EXECUTE CLEANUP:
bash plugins/repo/skills/worktree-manager/scripts/cleanup.sh \
"$REMOVE_MERGED" \
"$REMOVE_STALE" \
"$DRY_RUN"
5. OUTPUT RESULTS:
Cleanup Summary:
- Merged branches removed: 3
- feat/85-add-feature
- fix/86-bug-fix
- chore/87-update-deps
- Stale worktrees removed: 1
- feat/80-old-experiment
- Skipped (uncommitted changes): 0
6. UPDATE METADATA:
Remove all cleaned up entries from worktrees.json
7. OUTPUT COMPLETION MESSAGE:
✅ COMPLETED: Worktree Manager
Operation: cleanup-worktrees
Removed: {count} worktrees
───────────────────────────────────────
<COMPLETION_CRITERIA> ✅ All inputs validated ✅ Worktree path calculated correctly ✅ Safety checks passed ✅ Git worktree operation succeeded ✅ Metadata updated (worktrees.json) ✅ User notified of next steps </COMPLETION_CRITERIA>
Return structured JSON response:Create Success:
{
"status": "success",
"operation": "create-worktree",
"worktree_path": "../claude-plugins-wt-feat-92",
"branch_name": "feat/92-add-git-worktree-support",
"commit_sha": "cd4e945...",
"work_id": "92"
}
List Success:
{
"status": "success",
"operation": "list-worktrees",
"worktrees": [
{
"path": "../claude-plugins-wt-feat-92",
"branch": "feat/92-add-git-worktree-support",
"work_id": "92",
"status": "active"
}
],
"count": 1
}
Remove Success:
{
"status": "success",
"operation": "remove-worktree",
"worktree_path": "../claude-plugins-wt-feat-92",
"branch_name": "feat/92-add-git-worktree-support"
}
Error Response:
{
"status": "failure",
"operation": "create-worktree",
"error": "Worktree already exists at ../claude-plugins-wt-feat-92",
"error_code": 10
}
<ERROR_HANDLING>
Invalid Inputs (Exit Code 2):
Worktree Already Exists (Exit Code 10):
Uncommitted Changes (Exit Code 20):
In Use (Exit Code 21):
Metadata Error (Exit Code 3):
Git Error (Exit Code 1):
</ERROR_HANDLING>
After completing ANY operation, provide clear documentation of:Example completion message:
✅ Worktree created successfully!
Branch: feat/92-add-git-worktree-support
Worktree: ../claude-plugins-wt-feat-92-add-git-worktree-support
Work Item: #92
To start working in this worktree:
1. cd ../claude-plugins-wt-feat-92-add-git-worktree-support
2. claude
To list all worktrees:
/repo:worktree-list
To clean up when done:
/repo:worktree-remove feat/92-add-git-worktree-support
This skill is focused and efficient:
By delegating deterministic operations to scripts: