Skip to content

Run your own tools and scripts in a worktree

Status: Shipped

Each worktree terminal is a real shell in the worktree’s folder, so make, just, your own scripts and any agent CLI run there exactly as they do in any other terminal. The difference is that once an agent has launched there, the folder holds the team context that agent asked for: CLAUDE.md, AGENTS.md, skills and anything else in its context, written as real files and hidden from git.

To run several agents at once, open a worktree per story and split the terminal area into tiles. Each agent works in its own folder and branch, and you watch them side by side, with live diffs.

What the terminal gives you

When CodeSense opens a terminal for a worktree, it starts a login zsh (zsh -l) with the worktree as its working directory.

  • Your zsh config loads. CodeSense points ZDOTDIR at a small wrapper directory (~/.codesense/shell/zsh) whose files source your own .zshenv, .zprofile, .zshrc and .zlogin. Your aliases, functions, PATH additions and tools all apply.
  • CodeSense adds a little. ~/.codesense/bin goes first on PATH, and the shell gets a few CODESENSE_* variables, such as CODESENSE_TAB_SESSION_ID.
  • The prompt is a Starship preset by default. With Shell integration on (the default), CodeSense renders its bundled Starship prompt using the Compact preset. To keep the prompt your own config sets, open Settings, find Terminal prompt and choose Plain (“Your default shell prompt (no Starship)”).

Run your scripts in a worktree

  1. Launch a story’s worktree (see Launch your first agent), or open the terminal of a worktree you already have.

  2. Check that the context is there. CodeSense copies an agent’s context in when the agent launches in the worktree; a terminal you open on your own doesn’t trigger that copy:

    Terminal window
    ls .claude/skills
    # add-endpoint release-notes review-pr write-migration
  3. Run what you normally run. In the Ledgerline sample, a worktree for story LL-214 might run:

    Terminal window
    npm test # the repo's own scripts
    just migrate # your task runner
    ./scripts/dev.sh # or anything you keep in the repo

Anything you start here, including another agent CLI, reads the same CLAUDE.md, AGENTS.md and .claude/skills/ as every other agent on the story. Nothing extra shows up in git status, because CodeSense lists the paths it copied in .git/info/exclude.

Headless runs, pre-commit hooks and CI-style scripts you start here read the same context files, because they’re plain files in the folder. No special integration is involved.

When the window closes, and when you quit

  • Closing the window keeps CodeSense running in the background, so its terminals and the processes in them keep going.
  • Quitting CodeSense ends its terminal sessions. The next launch opens fresh shells.
How we know this is accurate 13 sources

Checked against the app at 1b3d5a69d73473db077dfb44f4390b42cded6bd4.

Feature inventory

  • WW-1
  • D-1
  • D-2
  • D-6
  • D-13
  • D-16
  • A-27
  • A-28

Code

  • src-tauri/src/commands/pty.rs
  • src-tauri/resources/shell-integration/codesense-shell-init.zsh
  • src/shared/constants/settings-options.ts
  • src/shared/stores/viewer-store.ts
  • src/shared/lib/worktree/setup.ts