Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Docs: Improve Claude Code integration for `wt beta statusline`
Maximilian Roosade515f0561b
diff --git a/README.md b/README.mdindex b8e4342bc..45f9a1aab 100644--- a/README.md+++ b/README.md@@ -991,13 +991,28 @@ Preview tabs (toggle with `1`/`2`/`3`):Single-line status for shell prompts, starship, or editor integrations.+**Claude Code integration** (`--claude-code`): Reads workspace context from+stdin, outputs directory, branch status, and model name.+```-branch status ±working commits upstream ci+~/w/myproject.feature-auth !🤖 ±+42 -8 ↑3 ⇡1 ● | Opus```-**Claude Code integration** (`--claude-code`): Reads workspace context from-stdin, outputs directory, branch status, and model name. Can be used by Claude-Code hooks to show worktree state in the status line.+<details>+<summary>Claude Code configuration</summary>++Add to `~/.claude/settings.json`:++```json+{+ "statusLine": {+ "type": "command",+ "command": "wt beta statusline --claude-code"+ }+}+```++</details>## Project Statusdiff --git a/src/commands/statusline.rs b/src/commands/statusline.rsindex 37d886295..10bd087b3 100644--- a/src/commands/statusline.rs+++ b/src/commands/statusline.rs@@ -147,19 +147,45 @@ pub fn run(claude_code: bool) -> Result<()> {let mut output = String::new();// Directory (claude-code mode only)- if claude_code {- output = format_directory_fish_style(&cwd.display().to_string());- }+ let dir_str = if claude_code {+ let formatted = format_directory_fish_style(&cwd.display().to_string());+ output = formatted.clone();+ Some(formatted)+ } else {+ None+ };// Git statuslet repo = Repository::at(&cwd);if repo.git_dir().is_ok()&& let Some(status_line) = get_git_status(&repo, &cwd)?{- if !output.is_empty() {- output.push_str(" ");+ // In claude-code mode, skip branch name if directory matches worktrunk template+ // TODO: Use actual configured template from config instead of hardcoding ".{branch}"+ // Template: {repo}.{branch} - so directory should end with ".{branch}"+ let status_to_show = if let Some(ref dir) = dir_str {+ // status_line format: "branch rest..." - check if dir ends with .branch+ if let Some((branch, rest)) = status_line.split_once(" ") {+ let pattern = format!(".{branch}");+ if dir.ends_with(&pattern) {+ // Directory already shows branch via worktrunk template, skip it+ rest.to_string()+ } else {+ status_line+ }+ } else {+ status_line+ }+ } else {+ status_line+ };++ if !status_to_show.is_empty() {+ if !output.is_empty() {+ output.push_str(" ");+ }+ output.push_str(&status_to_show);}- output.push_str(&status_line);}// Model name (claude-code mode only)