Ranking|Claude Code Mods

ModsCode / Claude Code Mods / Ranking / worktrees

worktrees

A chip with your git worktrees and a pane that shows each one's branch, uncommitted changes and pull request, opens it in the app's Terminal and removes the clean ones whose branch is merged.

Code you can checkTerminal + desktopPaneBandToastBoxButtonText
runs programs, draws

What it does

  • Draws a band above the prompt, a pane, toasts
  • Adds /worktrees
  • Watches Bash calls
  • Hooks session.start, state.set, ui.close
  • Keeps its own state between turns

Good points

  • No network calls
  • Written in TypeScript
  • Handles errors
  • Writes no files

Code to start from

A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.

Starter (register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like worktrees by Lucas Leandro (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/lucasleandro08-worktrees/
// Written by ModsCode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
  // the band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const total = '…'
    const merged = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" gap={1} alignItems="center" marginBottom={1}>
          <Text color="#50fa7b">
            🌳
          </Text>
          <Button label={`${total} worktree`} dimColor />
          <Text color="#bd93f9">
            {merged}
            {" merged, can go"}
          </Text>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Worktrees" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const n = '…'
    const length = '…'
    const error = '…'
    const shortPath = '…'
    const branch = '…'
    const head = '…'
    const changes = '…'
    const number = '…'
    const state = '…'
    const number2 = '…'
    const state2 = '…'
    const number3 = '…'
    const state3 = '…'
    const shortPath2 = '…'
    const branch2 = '…'
    const number4 = '…'
    const state4 = '…'
    const number5 = '…'
    const state5 = '…'
    const number6 = '…'
    const state6 = '…'
    const shortPath3 = '…'
    const branch3 = '…'
    const number7 = '…'
    const state7 = '…'
    const number8 = '…'
    const state8 = '…'
    const number9 = '…'
    const state9 = '…'
    return (
      <Box flexDirection="column" backgroundColor="#282a36" paddingX={1} paddingY={1}>
        <Box flexDirection="row" alignItems="center" gap={1}>
          <Text color="#50fa7b" bold>
            🌳 Worktrees
          </Text>
          <Text color="#6272a4">
            {`${n}${length}`}
            {" in "}
            {length}
            {" repo"}
          </Text>
          <Box flexGrow={1} />
          <Text color="#6272a4">
            refreshing…
          </Text>
          <Button label="Refresh" dimColor />
        </Box>
        <Text color="#ff5555">
          {error}
        </Text>
        <Text color="#6272a4" italic>
          No extra worktrees here. Add folders that hold your repos in /config → worktrees → Roots.
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row" alignItems="center" gap={1} backgroundColor="#44475a" paddingX={1}>
            <Text color="#bd93f9" bold>
              {shortPath}
            </Text>
            <Text color="#6272a4">
              {"⑂ "}
              {branch}
            </Text>
            <Box flexGrow={1} />
            <Button label={`Remove ${length} merged`} dimColor plain />
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number}
                {" "}
                {state}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number2}
                {" "}
                {state2}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number3}
                {" "}
                {state3}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row" alignItems="center" gap={1} backgroundColor="#44475a" paddingX={1}>
            <Text color="#bd93f9" bold>
              {shortPath2}
            </Text>
            <Text color="#6272a4">
              {"⑂ "}
              {branch2}
            </Text>
            <Box flexGrow={1} />
            <Button label={`Remove ${length} merged`} dimColor plain />
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number4}
                {" "}
                {state4}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number5}
                {" "}
                {state5}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number6}
                {" "}
                {state6}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row" alignItems="center" gap={1} backgroundColor="#44475a" paddingX={1}>
            <Text color="#bd93f9" bold>
              {shortPath3}
            </Text>
            <Text color="#6272a4">
              {"⑂ "}
              {branch3}
            </Text>
            <Box flexGrow={1} />
            <Button label={`Remove ${length} merged`} dimColor plain />
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number7}
                {" "}
                {state7}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number8}
                {" "}
                {state8}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
          <Box flexDirection="row" paddingX={1} gap={1}>
            <Box>
              <Text color="#6272a4" wrap="truncate-middle">
                {`detached ${head}`}
              </Text>
            </Box>
            <Box width={10}>
              <Text color="#ffb86c">
                {`${changes} changed`}
              </Text>
            </Box>
            <Box width={12}>
              <Text>
                #
                {number9}
                {" "}
                {state9}
              </Text>
            </Box>
            <Box flexDirection="row" gap={1}>
              <Button label="Terminal" dimColor plain />
              <Button label="Remove" dimColor plain />
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const message = '…'
    const length = '…'
    await $.ui.toast(`Could not open the terminal: ${message}`)
    await $.ui.toast(`Removed ${length} worktree.`)
    return next(e)
  })
}

The mod's own code

Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.

plugins/worktrees/hooks/register.tsx lines 242–259 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (!(await read($, active)) || (await barOwnsChips($))) return next(e)
    const rest = await next(e)
    if (e.props.hasSurvey) return rest

    const all = await read($, repos)
    const total = all.reduce((n, repo) => n + repo.worktrees.length, 0)
    if (total === 0) return rest
    const cwd = await $.session.cwd()
    const merged = all.reduce((n, repo) => n + repo.worktrees.filter(row => canRemove(row, cwd)).length, 0)
    const ui = $.ui.resolve(e)
    return (
      <ui.Box flexDirection="column">
        <WorktreesChip ui={ui} total={total} merged={merged} onOpen={() => openPane($, settings)} />
        {rest}
      </ui.Box>
    )
  })
plugins/worktrees/ui/chip.tsx lines 8–18 · Band
export function WorktreesChip({ ui, total, merged, onOpen }: { ui: Ui; total: number; merged: number; onOpen: () => unknown }) {
  const { Box, Text, Button } = ui

  return (
    <Box flexDirection="row" gap={1} alignItems="center" marginBottom={1}>
      <Text color={DRACULA.green}>🌳</Text>
      <Button key="open-worktrees" label={`${total} worktree${total === 1 ? '' : 's'}`} dimColor onPress={onOpen} />
      {merged > 0 && <Text color={DRACULA.purple}>{merged} merged, can go</Text>}
    </Box>
  )
}
plugins/worktrees/hooks/register.tsx lines 261–288 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE_ID }, async ($, e) => {
    const ui = $.ui.resolve(e)
    if (!(await read($, active))) {
      return <ui.Box padding={1}><ui.Text color="#6272a4">{OFF_TEXT}</ui.Text></ui.Box>
    }
    try {
      return (
        <WorktreesPane
          ui={ui}
          width={e.props.bodyColumns}
          home={(await $.env.get('HOME')) ?? ''}
          cwd={await $.session.cwd()}
          repos={await read($, repos)}
          isLoading={await read($, isLoading)}
          error={await read($, lastError)}
          updatedAt={await read($, updatedAt)}
          busy={await read($, busy)}
          onRefresh={() => load($, settings)}
          onTerminal={row => openTerminal($, row)}
          onRemove={(repo, rows) => remove($, settings, repo, rows)}
        />
      )
    } catch (err) {
      const message = err instanceof Error ? err.message : String(err)
      $.ui.log(`worktrees render failed: ${message}`)
      return <PaneError ui={ui} message={message} onRefresh={() => load($, settings)} />
    }
  })
plugins/worktrees/ui/pane.tsx lines 28–51 · Pane
export function WorktreesPane(props: WorktreesPaneProps) {
  const { ui, repos, isLoading, error, updatedAt } = props
  const { Box, Text, Button } = ui
  const total = repos.reduce((n, repo) => n + repo.worktrees.length, 0)

  return (
    <Box flexDirection="column" backgroundColor={DRACULA.background} paddingX={1} paddingY={1}>
      <Box flexDirection="row" alignItems="center" gap={1}>
        <Text color={DRACULA.green} bold>🌳 Worktrees</Text>
        <Text color={DRACULA.comment}>{total} in {repos.length} repo{repos.length === 1 ? '' : 's'}</Text>
        <Box flexGrow={1} />
        <Text color={DRACULA.comment}>
          {isLoading ? 'refreshing…' : updatedAt > 0 ? `updated ${new Date(updatedAt).toTimeString().slice(0, 8)}` : ''}
        </Text>
        <Button key="refresh" label="Refresh" dimColor onPress={props.onRefresh} />
      </Box>
      {error !== '' && <Text color={DRACULA.red}>{error}</Text>}
      {repos.length === 0 && !isLoading && (
        <Text color={DRACULA.comment} italic>No extra worktrees here. Add folders that hold your repos in /config → worktrees → Roots.</Text>
      )}
      {repos.map(repo => <RepoView {...props} repo={repo} />)}
    </Box>
  )
}
plugins/worktrees/ui/pane.tsx lines 53–88 · Pane
function RepoView(props: WorktreesPaneProps & { repo: RepoRow }) {
  const { ui, repo, home, cwd } = props
  const { Box, Text, Button } = ui
  const removable = repo.worktrees.filter(row => canRemove(row, cwd))
  const branchWidth = Math.max(14, Math.min(44, props.width - 46))

  return (
    <Box key={`repo-${repo.main}`} flexDirection="column" marginTop={1}>
      <Box flexDirection="row" alignItems="center" gap={1} backgroundColor={DRACULA.currentLine} paddingX={1}>
        <Text color={DRACULA.purple} bold>{shortPath(repo.main, home)}</Text>
        {repo.branch !== '' && <Text color={DRACULA.comment}>⑂ {repo.branch}</Text>}
        <Box flexGrow={1} />
        {removable.length > 1 && (
          <Button key={`remove-merged-${repo.main}`} label={`Remove ${removable.length} merged`} dimColor plain onPress={() => props.onRemove(repo, removable)} />
        )}
      </Box>
      {repo.worktrees.map(row => (
        <Box key={`worktree-${row.path}`} flexDirection="row" paddingX={1} gap={1}>
          <Box width={branchWidth}>
            <Text color={row.branch === '' ? DRACULA.comment : DRACULA.foreground} wrap="truncate-middle">{row.branch || `detached ${row.head.slice(0, 7)}`}</Text>
          </Box>
          <Box width={10}>
            <Text color={row.changes > 0 ? DRACULA.orange : DRACULA.comment}>{row.changes > 0 ? `${row.changes} changed` : 'clean'}</Text>
          </Box>
          <Box width={12}><PrLabel ui={ui} row={row} /></Box>
          {props.busy === row.path ? <Text color={DRACULA.yellow}>removing…</Text> : (
            <Box flexDirection="row" gap={1}>
              <Button key={`terminal-${row.path}`} label="Terminal" dimColor plain onPress={() => props.onTerminal(row)} />
              {canRemove(row, cwd) && <Button key={`remove-${row.path}`} label="Remove" dimColor plain onPress={() => props.onRemove(repo, [row])} />}
            </Box>
          )}
        </Box>
      ))}
    </Box>
  )
}
plugins/worktrees/ui/pane.tsx lines 90–98 · Pane
function PrLabel({ ui, row }: { ui: Ui; row: WorktreeRow }) {
  const { Text } = ui
  if (row.pr) {
    const color = row.pr.state === 'OPEN' ? DRACULA.green : row.pr.state === 'MERGED' ? DRACULA.purple : DRACULA.red
    return <Text color={color}>#{row.pr.number} {row.pr.state.toLowerCase()}</Text>
  }
  if (row.isMerged) return <Text color={DRACULA.purple}>merged</Text>
  return <Text color={DRACULA.comment}>no PR</Text>
}
Licence text (MIT)
MIT License

Copyright (c) 2026 Lucas Leandro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

How to build this: Pane (panel), Deny a tool call

What its code calls

runs programsreads filesenv varstool callsrememberscalls tools

What its code shows

Read from the source at commit ce6f382945a2 on 2026-10-11. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.

Decides the listing: code you can check
Entry readEvery module hooks/hooks.json names was read.plugins/worktrees/hooks/register.tsx
ParsesEvery file parses as TypeScript or JavaScript.8 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs
Calls in the openNetwork and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open
For you to weigh before installing
Where it drawsThe terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, the same in both
Install lineWhether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there
Programs on WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether every program it starts is named in the code and is not a shell, an interpreter or a network tool.plugins/worktrees/hooks/register.tsx:73 a program named at run time
Reads and sendsWhether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads environment variables, files and reaches the network, an MCP server
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets ModsCode show its code; otherwise the code is linked.MIT
Settings hooksHooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone
Servers it shipsMCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/
Skills, commands, agentsWhat its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.no skills, commands, agents or workflows
Tools and MCPWhether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).tool.call: mcp__terminal__run_in_terminal
Asks of the modelCompletions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command worktrees
Events it hooksBy what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: command.run (worktrees), tool.call (Bash) · also: state.set, session.start, ui.close, ui.render (AbovePrompt, Pane) · timers: clock.every
Reads, by nameThe environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: HOME; files: a path computed at run time
Writes, by nameThe files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.writes no files, environment variables, settings or conversation rows

This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen

Install it

Check it yourself before you install it. Mods run unsandboxed, with your permissions, and ModsCode does not vouch for what this code does. Read its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.

From its marketplace

Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:

/plugin marketplace add lucasleandro08/claude-mods
/plugin install worktrees@dracula-mods
/reload-plugins

This installs the marketplace's latest commit, which may not be the one read here (ce6f382945a2). Compare them before you install. /reload-plugins loads it into a session that is already open.

Try the commit ModsCode read

No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:

git clone https://github.com/lucasleandro08/claude-mods
git -C claude-mods checkout ce6f382945a27f7afceb54e31779fffb45534200
claude plugin validate claude-mods/plugins/worktrees
claude --plugin-dir claude-mods/plugins/worktrees

The validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.

Ask Claude about it

With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:

Read the ModsCode mod "lucasleandro08-worktrees" with its code and make me one like it

Search them from Claude: the MCP connector

Similar mods

More from this repository

See all 12 mods in this repository

Badge for your README

If this is your mod, paste this into your README. It links to this page.

README.md
[![ModsCode](https://modscode.com/badge/lucasleandro08-worktrees.svg)](https://modscode.com/claude-mods/mods/lucasleandro08-worktrees/)