Files
worktrunk/docs/content/claude-code.md
T
Maximilian RoosandClaude 8abefbce82 refactor(docs): unify AUTO-GENERATED marker form; share constants across crate boundary (#2418)
## Summary

Follow-ups from #2417 review, plus adjacent simplifications.

- **Cross-crate share of marker constants.** `MARKER_OPEN_PREFIX` and
`MARKER_CLOSE` now live in `src/docs.rs`. `src/help.rs` (the
`--help-page` producer of help-region markers) and
`tests/integration_tests/readme_sync.rs` (the consumer + producer of
snapshot/section markers) both reference them — drift becomes a build
error rather than a silent mismatch.
- **Drop `MARKER_OPEN_HTML_PREFIX`.** The `-HTML` variant emitted
visually identical wrapping; the suffix only signalled "in-place
refreshable" but the `.snap` ID + terminal-shortcode body in
`DOCS_SNAPSHOT_MARKER_PATTERN` already discriminate that. Standardised
on a single open prefix and stripped the `-HTML` literals from
`README.md`, the four standalone docs files, and the test file.
- **Help-page marker uses the shared prefix.** The mirrored close (`<!--
END AUTO-GENERATED from \`wt <cmd> --help-page\` -->`) stays as-is
because adjacent regions need unambiguous pairing, but the open prefix
now goes through `MARKER_OPEN_PREFIX`.
- **Drop `MarkerType::output_format()` / `extract_inner()`.** Both had a
single trivial non-panic branch that existed only to enforce "no
Snapshot markers in README" via `unreachable!()`. Replaced with one
explicit assertion in `sync_readme_markers` — surfaces the invariant as
an actionable error message instead of a panic.
- **Collapse `format_replacement`.** `wrap_in_marker` is invoked once
for both output formats; only body construction varies.
- **`__WT_QUOT__` rename in `tests/integration_tests/user_hooks.rs`.**
Inlined the single quotes — the `.replace('__WT_QUOT__', \"'\")` was
unnecessary indirection (the outer raw-string literal already tolerates
`'`, and TOML / Tera don't care about embedded `'`). Removes a
name-conflation footgun with the unrelated `__WT_QUOT__` placeholder in
`src/docs.rs`.

Net diff: -7 lines.

## Test plan

- [x] `cargo test --test integration` — full integration suite (1559
tests) pass
- [x] `cargo test --test integration readme_sync` — all 13 sync tests
pass; `test_readme_examples_are_in_sync` now produces a stable README on
a clean run (verified by re-running multiple times — no further updates
after the initial regeneration)
- [x] `cargo test --test integration
test_args_indexing_and_length_in_hook_template` — confirms the
user_hooks single-quote inlining works through TOML and Tera
- [x] Visual check via local Zola dev server: \`/worktrunk/\`,
\`/llm-commits/\`, \`/claude-code/\`, \`/tips-patterns/\`, \`/merge/\`,
\`/step/\`, \`/remove/\`, \`/hook/\`, \`/list/\` all render terminal
blocks cleanly with no leaked marker strings (`AUTO-GENERATED-HTML`,
`__WT_OPEN2__`, trailing `|||`)
- [x] `cargo clippy --all-targets --all-features` — clean
- [x] `cargo fmt --check` — clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-25 16:57:39 -07:00

4.8 KiB
Raw Blame History

+++ title = "Claude Code Integration" description = "Worktrunk plugin for Claude Code: configuration skill, worktree isolation for agents, and activity tracking for wt list." weight = 23

[extra] group = "Reference" +++

The worktrunk Claude Code plugin provides three features:

  1. Configuration skill — Documentation Claude Code can read, so it can help set up LLM commits, hooks, and troubleshoot issues
  2. Worktree isolation — When Claude Code agents create isolated worktrees, the plugin routes creation and removal through wt instead of raw git
  3. Activity tracking — Status markers in wt list showing which worktrees have active Claude sessions (🤖 working, 💬 waiting)

Installation

Recommended:

{{ terminal(cmd="wt config plugins claude install") }}

Manual equivalent:

{{ terminal(cmd="claude plugin marketplace add max-sixty/worktrunk|||claude plugin install worktrunk@worktrunk") }}

Configuration skill

The plugin includes a skill — documentation that Claude Code can read — covering worktrunk's configuration system. After installation, Claude Code can help with:

  • Setting up LLM-generated commit messages
  • Adding project hooks (pre-start, pre-merge, pre-commit)
  • Configuring worktree path templates
  • Fixing shell integration issues

Claude Code is designed to load the skill automatically when it detects worktrunk-related questions.

Activity tracking

The plugin tracks Claude sessions with status markers in wt list:

{% terminal(cmd="wt list") %} wt list Branch Status HEAD± main↕ Remote⇅ Path Commit Age Message @ main ^⇡ ⇡1 . 33323bc1 1d Initial commit

  • feature-api ↑ 🤖 ↑1 ../repo.feature-api 70343f03 1d Add REST API endpoints
  • review-ui ? ↑ 💬 ↑1 ../repo.review-ui a585d6ed 1d Add dashboard component
  • wip-docs ? – ../repo.wip-docs 33323bc1 1d Initial commit

○ Showing 4 worktrees, 2 with changes, 2 ahead {% end %}

  • 🤖 — Claude is working
  • 💬 — Claude is waiting for input

Manual status markers

Set status markers manually for any workflow:

{% terminal() %} wt config state marker set "🚧" # Current branch wt config state marker set "✅" --branch feature # Specific branch git config worktrunk.state.feature.marker '{"marker":"💬","set_at":0}' # Direct {% end %}

Worktree isolation

Claude Code agents can run in isolated worktrees (isolation: "worktree"). By default, Claude Code creates these with git worktree add. The plugin's WorktreeCreate and WorktreeRemove hooks route this through wt switch --create and wt remove instead, so worktrees created by agents get worktrunk's naming conventions, hooks, and lifecycle management.

Statusline

wt list statusline --format=claude-code outputs a single-line status for the Claude Code statusline. When the CI status cache is stale, this fetches from the network — typically 1–2 seconds — making it suitable for async statuslines but too slow for synchronous shell prompts. If a faster version would be helpful, please open an issue.

~/w/myproject.feature-auth !🤖 @+42 -8 ↑3 ⇡1 ● | Opus 🌔 65%

When Claude Code provides context window usage via stdin JSON, a moon phase gauge appears (🌕→🌑 as context fills).

Claude Code statusline demo

Add to ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "wt list statusline --format=claude-code"
  }
}