# rebase\_worktree

Rebase a task's branch onto the newest commit of its base branch.

writes · not idempotent · destructive · MCP tool · [Agent](https://komrad.dev/latest/api/agent.md)

Komrad keeps the checkout at a ref first and mails the task's writer that its files moved. A rebase that conflicts stops and is left for the writer to resolve.

## Calling it

```bash
curl -X POST http://127.0.0.1:8787/komrad.agent.v1.AgentService/RebaseWorktree \
  -H 'Content-Type: application/json' \
  -d '{
  "task_id": "<task_id>"
}'
```

```bash
komrad rpc rebase-worktree \
  --task-id '<uuid>'
```

```json
{
  "name": "rebase_worktree",
  "arguments": {
    "task_id": "<task_id>"
  }
}
```

Offered by the komrad MCP server to orchestrator agents.

## Request

### RebaseWorktreeRequest

| Field | Type | Description |
| --- | --- | --- |
| [one of](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeRequest-task)\* |  | The task whose branch to rebase onto the base branch. |
| [`task_id`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeRequest-task_id) | uuid | The task, by id. |
| [`task_slug`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeRequest-task_slug) | string not empty | The task, by slug. |
| [`onto_base`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeRequest-onto_base) | bool | Re-target a child onto the workflow's base branch, rebasing only its own commits, so it no longer has a parent. |

## Response

### RebaseWorktreeResponse

| Field | Type | Description |
| --- | --- | --- |
| [`base_ref`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-base_ref) | string | The ref the branch moved onto. |
| [`base_sha`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-base_sha) | string | The commit [`base_ref`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-base_ref) named when komrad read it. |
| [`commits`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-commits) | int32 | How many commits the branch had that the base branch did not. |
| [`branch`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-branch) | string | The branch that moved. |
| [`conflicted`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-conflicted) | bool | Whether the rebase stopped on conflicts and is waiting for the agent. |
| [`moved`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-moved) | bool | Whether the branch reached the base branch without replaying anything, as when all its commits have landed. |
| [`landed_commits`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-landed_commits) | int32 | How many of the branch's commits had landed. The rebase dropped them. |
| [`replay_commits`](https://komrad.dev/latest/api/agent/rebase-worktree.md#komrad-agent-v1-RebaseWorktreeResponse-replay_commits) | int32 | How many of the branch's commits the rebase replayed. |
