# Arrange with AI agents

Once your pull request is open, ask your coding agent to arrange it. The agent reads the change, orders the files so each comes after what it depends on, groups them into sections with notes and checklists, saves the order, and gives you the link.

```text
Arrange PR #123 in LogiKFlow in logical order.
```

LogiKFlow is a remote [MCP](https://modelcontextprotocol.io) server, so it works with any agent that supports remote MCP servers with OAuth.

## Connect

The server URL is:

```text
https://logikflow.dev/mcp
```

### Claude Code

```bash
claude mcp add --transport http logikflow https://logikflow.dev/mcp
```

Then run `/mcp` in Claude Code, select **logikflow**, and choose **Authenticate**. Add `--scope user` to the command to make it available in every project, not just the current one.

### Cursor

Add to `~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project:

```json
{
  "mcpServers": {
    "logikflow": { "url": "https://logikflow.dev/mcp" }
  }
}
```

### VS Code

Add to `.vscode/mcp.json`:

```json
{
  "servers": {
    "logikflow": { "type": "http", "url": "https://logikflow.dev/mcp" }
  }
}
```

### Other clients

Add a remote server that uses the streamable HTTP transport, with the URL above. The client registers itself automatically.

### Signing in

The first time, your browser opens a LogiKFlow page asking whether the app may act for you. It shows which app is asking and where access is sent. Choose **Allow**, then sign in with GitHub. For private repositories, the LogiKFlow GitHub App must be installed on the owning account or organization; see [Quickstart](/docs/quickstart#2-install-the-app-for-private-repositories).

## Ask

Run the agent from the repository's checkout. It can then read the whole codebase, not just the diff, and the order is much better.

```text
Arrange PR #123 in LogiKFlow in logical order.
```

```text
Create a LogiKFlow review for https://github.com/acme/app/pull/123 and add review checklists.
```

```text
Arrange the open PR for this branch in LogiKFlow.
```

```text
I pushed new commits to PR #123. Re-arrange it in LogiKFlow and keep the existing sections where they still fit.
```

Say what you care about and the agent takes it into account, for example "put the migration first" or "keep the tests at the end".

## What the agent does

1. Reads the [ordering guide](/docs/ordering-guide) with `get_ordering_guide`.
2. Fetches the changed files and any saved order with `get_pull_request`.
3. Studies the change, locally if it can, or from the patches.
4. Saves the order with `save_reading_order`.
5. Replies with the review link.
6. Asks whether you'd like a diagram, unless the pull request is small or your repository decides for it (see below).

## Diagrams

An agent can also draw a **flow diagram** of the change: boxes for each step or piece, grouped and connected with labelled arrows, laid out automatically. Reviewers open it from the **Diagram** tab on the pull request, and clicking a box opens its file, or the exact change inside it.

Diagrams are optional. After arranging, the agent asks whether you want one. Answer yes or no, or ask for one directly:

```text
Draw a flow diagram of PR #123 in LogiKFlow.
```

```text
Redraw the LogiKFlow diagram for PR #123; the retry path changed.
```

Redrawing replaces the diagram without touching the reading order. To stop the question, or to get a diagram every time, add a `diagram:` line to your [conventions file](/docs/conventions#diagrams). People with write access can remove a diagram from the Diagram tab.

The [MCP reference](/docs/mcp-reference) documents each tool.

## Safety

- **The agent acts as you.** It reads only what your GitHub account can read, and saves only on repositories where you have write access.
- **It can't drop or invent files.** Every changed file must appear exactly once, or nothing is saved and the agent gets the list to fix. Diagram boxes can only link to files and changes that are in the pull request.
- **It can't silently overwrite.** If someone saved a new order in the meantime, the agent gets a conflict and asks you.
- **It's labelled.** Orders saved by an agent say *arranged by octo's AI agent* on the page and in History, and any earlier version can be restored.
- **You can disconnect.** Remove the server from your agent.

## Troubleshooting

| Message | What to do |
|---|---|
| GitHub access for this connection has expired | Reconnect: in Claude Code, `/mcp`, then **Authenticate**. |
| This pull request doesn't exist or this account can't see it | Check the owner, repo and number. For a private repository, install the GitHub App on the owning account. |
| doesn't have write access | Only people who can push to the repository can save an order. |
| The order must list every changed file exactly once | The agent will usually fix this itself. If it doesn't, ask it to call `get_pull_request` again and include every file. |
| Conflict | Someone saved a newer order. Ask the agent to fetch it and decide whether to replace it. |
| Rate limited | Wait a minute. The limit is 120 requests per minute per person. |
