Skip to content

feat: add -w, --worktree [name] flag for isolated sessions #828

@rrva

Description

@rrva

Problem

Users running multiple Kimi Code sessions on the same repository need a way to avoid file conflicts and branch-switching overhead. The legacy Kimi CLI already supports this with a worktree flag, and users expect the same capability in Kimi Code CLI.

Proposed solution

Add a -w, --worktree [name] CLI flag that creates a new git worktree for the session:

  • New worktrees live under <repo-root>/.kimi/worktrees/<name> with a detached HEAD checkout at the current HEAD.
  • Auto-generate a three-word slug name when no name is supplied.
  • Reject combinations with --session or --continue.
  • Persist worktree_path and parent_repo_path in session metadata.
  • Clean up the worktree on exit when the session is empty.

Related PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions