wt

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

wt - Worktree Manager Skill

wt - 工作树管理工具

Manages isolated LlamaFarm development environments using git worktrees. Each worktree has its own services, ports, and data directories - enabling parallel agent sessions without conflicts.
管理基于git worktrees的LlamaFarm隔离开发环境。每个工作树都有独立的服务、端口和数据目录——支持并行运行Agent会话且无冲突。

Full Documentation

完整文档

For complete documentation, architecture details, and advanced usage: @scripts/wt/README.md

如需完整文档、架构细节和高级用法,请查看: @scripts/wt/README.md

Quick Reference

快速参考

TaskCommand
Create worktree and start services
wt create feat/my-feature
Create and cd into worktree
wt create --go feat/my-feature
List all worktrees with status
wt list
Check service health
wt status
or
wt health
Start/stop services
wt start
/
wt stop
View service logs
wt logs [server|rag|runtime|designer|all]
Delete worktree
wt delete <name>
Switch to worktree
wt switch <name>
Open Designer in browser
wt open
Diagnose issues
wt doctor
Clean orphaned data
wt gc

任务命令
创建工作树并启动服务
wt create feat/my-feature
创建工作树并进入该目录
wt create --go feat/my-feature
列出所有工作树及其状态
wt list
检查服务健康状态
wt status
wt health
启动/停止服务
wt start
/
wt stop
查看服务日志
wt logs [server|rag|runtime|designer|all]
删除工作树
wt delete <name>
切换到指定工作树
wt switch <name>
在浏览器中打开Designer
wt open
诊断问题
wt doctor
清理孤立数据
wt gc

When to Use wt

何时使用wt

Use
wt
when:
  • Starting isolated work on a feature/task that needs running services
  • Running parallel coding sessions (multiple agents or terminals)
  • Testing changes without affecting the main development environment
  • Avoiding port conflicts between concurrent LlamaFarm instances

在以下场景使用
wt
  • 开始开发某个功能/任务,需要运行独立的服务
  • 进行并行编码会话(多个Agent或终端)
  • 在不影响主开发环境的情况下测试变更
  • 避免并发LlamaFarm实例之间的端口冲突

Common Workflows

常见工作流

Starting a New Task

启动新任务

bash
undefined
bash
undefined

Create isolated environment with services running

创建带运行中服务的隔离环境

wt create --go feat/my-task
wt create --go feat/my-task

Work in the worktree...

在工作树中开展工作...

Services are already running on auto-assigned ports

服务已在自动分配的端口上运行

Check status anytime

随时检查状态

wt status
wt status

View logs if needed

必要时查看日志

wt logs server
undefined
wt logs server
undefined

Checking What's Running

查看运行中的实例

bash
undefined
bash
undefined

List all worktrees with their port assignments

列出所有工作树及其端口分配

wt list
wt list

Example output:

示例输出:

NAME STATUS SERVER DESIGNER RUNTIME

NAME STATUS SERVER DESIGNER RUNTIME

feat-my-task running 8150 5150 11150

feat-my-task running 8150 5150 11150

fix-bug stopped 8234 5234 11234

fix-bug stopped 8234 5234 11234

undefined
undefined

Cleaning Up

清理资源

bash
undefined
bash
undefined

Stop services and remove a worktree

停止服务并删除工作树

wt delete feat-my-task
wt delete feat-my-task

Remove data for worktrees that no longer exist

清理已不存在的工作树对应的数据

wt gc
wt gc

Remove worktrees for branches merged to main

删除已合并到main分支的工作树

wt prune
undefined
wt prune
undefined

Troubleshooting

故障排查

bash
undefined
bash
undefined

Diagnose common issues (ports, stale PIDs, missing tools)

诊断常见问题(端口、过期PID、缺失工具)

wt doctor
wt doctor

Restart stuck services

重启卡住的服务

wt stop && wt start
wt stop && wt start

Force delete if normal delete fails

若常规删除失败,强制删除

wt delete my-worktree --force

---
wt delete my-worktree --force

---

Service URLs

服务URL

Each worktree gets unique ports. Check URLs with:
bash
wt url
每个工作树都有唯一的端口。使用以下命令查看URL:
bash
wt url

Outputs:

输出示例:


If the Caddy proxy is running, use port-free URLs:

---

如果Caddy代理正在运行,可使用无端口URL:

---

Key Environment Details

关键环境细节

  • Worktrees location:
    ~/worktrees/llamafarm/
  • Data directories:
    ~/.llamafarm/worktrees/<name>/
  • Port allocation: Deterministic hash of worktree name (14345+offset, 5000+offset, 11000+offset)
  • Logs:
    ~/.llamafarm/worktrees/<name>/logs/

  • 工作树位置
    ~/worktrees/llamafarm/
  • 数据目录
    ~/.llamafarm/worktrees/<name>/
  • 端口分配:基于工作树名称的确定性哈希(14345+偏移量、5000+偏移量、11000+偏移量)
  • 日志位置
    ~/.llamafarm/worktrees/<name>/logs/

Notes for the Agent

给Agent的注意事项

  1. Always use
    wt create --go
    when setting up a new task environment - it handles everything (branch, deps, build, services)
  2. Check
    wt list
    first
    before creating a new worktree to see what already exists
  3. Use
    wt status
    to verify services are healthy before running tests or making API calls
  4. Run
    wt doctor
    when encountering unexplained service issues
  5. Clean up with
    wt delete
    when a task is complete to free resources
  1. 设置新任务环境时始终使用
    wt create --go
    ——它会处理所有事项(分支、依赖、构建、服务)
  2. 创建新工作树前先执行
    wt list
    ,查看已存在的工作树
  3. **运行测试或调用API前,使用
    wt status
    **验证服务是否健康
  4. 遇到无法解释的服务问题时,执行
    wt doctor
  5. 任务完成后使用
    wt delete
    清理
    ,释放资源