MoonshotAI / MoonshotAI/kimi-code

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

Open
#828 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

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

  • #818

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing related PR #818 and the legacy Kimi CLI's worktree behavior, since the issue names no files or tests. Trace the CLI flag handling, session metadata, and exit cleanup. Done means supporting the specified flag and naming behavior, rejecting --session and --continue, persisting both paths, and removing empty worktrees.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
cli, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.