Skip to content

Add a project script hook that runs when T3 deletes a worktree (e.g. runOnWorktreeDelete) #33096

Closed

Description

@ryoppippi

Problem

t3.json scripts can run when a worktree is created (runOnWorktreeCreate) and when a thread settles (runOnSettle). Nothing runs when T3 deletes a worktree, although T3 now deletes them automatically (Storage cleanup: worktreeOnDelete, worktreeOnMerge, worktreeAfterDays, worktreeUnchanged).

Per-worktree state that lives outside the worktree directory therefore leaks. In our repo that is direnv's allow entry, plus the Nix GC roots behind .direnv and the dev shell it pins. We also need to stop dev services that were started from the worktree.

runOnSettle is not a substitute. A settled thread resumes in the same worktree, so tearing down the direnv/Nix state there forces a full dev-shell rebuild on every resume.

Prior art

Codex local environments have a [cleanup] script that runs when the worktree is removed, next to [setup]. We use it to run direnv revoke, remove .direnv, and stop dev services, so this is a direct parity gap.

Proposal

Add a boolean on a script, for example:

{
  "name": "Teardown worktree",
  "command": "./scripts/teardown.sh",
  "runOnWorktreeDelete": true
}
  • Runs in the worktree before T3 removes it, for every deletion path (thread deleted, merged, age-based, unchanged).
  • Receives T3CODE_WORKTREE_PATH and T3CODE_PROJECT_ROOT, like the create hook.
  • Failure or timeout is logged but never blocks the deletion.
  • Skipped for threads without their own worktree, matching runOnSettle.

Context

Checked the public schema at https://t3.codes/schema/t3.json and the Nightly app bundle: the only runOn* keys are runOnWorktreeCreate and runOnSettle.

Activity

  1. locked and limited conversation to collaborators on Nov 8, 2026
  2. converted this issue into a discussion #33099 on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions