gitbutlerapp/gitbutler

Agent changes not auto-assigned to virtual branches

Open

#13297 opened on Apr 14, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (19,787 stars) (862 forks)batch import
bugcodegenhelp wanted

Description

Version

0.19.7

Operating System

Windows

Distribution Method

msi (Windows)

Describe the issue

On Windows (v0.19.7), changes made by Claude Code are not automatically assigned to their respective virtual branches. All changes appear in the unstaged area of the default/leftmost branch, regardless of which virtual branch the agent session is tied to.

This happens with both:

  • Agents Tab (built-in UI): Starting a Claude Code session tied to a specific branch — changes are not routed to that branch.
  • Terminal with Hooks: Running Claude Code in PowerShell with but claude pre-tool / post-tool / stop hooks configured in .claude/settings.local.json.

The Rules drawer does show auto-generated rules after starting an AI session (e.g. claude --resume {uuid} → Assign to branch {branch_name}), so the session-to-branch mapping appears to be created correctly. However, the rules do not seem to take effect — file changes are still not routed to the correct branch.

Environment:

  • GitButler: 0.19.7
  • OS: Windows
  • Shell: PowerShell
  • GitButler CLI: Installed and confirmed working (but --version)
  • Claude Code: Installed, logged in via Team plan subscription
  • GitHub account: Connected and authenticated in GitButler

How to reproduce (Optional)

Via Agents Tab:

  1. Open GitButler and create two virtual branches (e.g. branch-A, branch-B)
  2. Open the Agents Tab
  3. Start a Claude Code session tied to branch-A
  4. Let the agent make file changes
  5. Observe that all changes appear in branch-B (or the default/leftmost branch), not in branch-A
  6. Clicking commit on branch-A shows all files checked, including files that should belong to branch-B

Via Terminal with Hooks:

  1. Install GitButler CLI: copy "C:\Program Files\GitButler\but.exe" "$env:LOCALAPPDATA\Microsoft\WindowsApps\but.exe"
  2. Add hooks to .claude/settings.local.json:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|MultiEdit|Write",
        "hooks": [{ "type": "command", "command": "but claude pre-tool" }]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Edit|MultiEdit|Write",
        "hooks": [{ "type": "command", "command": "but claude post-tool" }]
      }
    ],
    "Stop": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "but claude stop" }]
      }
    ]
  }
}
  1. Run Claude Code in PowerShell and make changes
  2. Observe that changes are not assigned to any specific virtual branch

Expected behavior (Optional)

Changes made by a Claude Code session should be automatically assigned to the virtual branch that session is tied to, based on the auto-generated Rules (Claude Code Session ID filter). Each branch should only show its own changes when committing.

Relevant log output (Optional)

No error messages observed. GitButler appears to function normally — it creates the `.husky_` managed hooks (`GITBUTLER_MANAGED_HOOK_V1`), auto-generates Rules with session IDs, and detects file changes. The only issue is that changes are not routed to the correct branch despite the rules being present.

Contributor guide