# create_plan

URL: https://codepanel.ai/docs/mcp-server/create_plan

The CodePanel MCP tool that saves a plan with numbered steps, or a sub-plan under one step, so an agent can work through it across sessions.

`create_plan` saves a plan: a title, an optional goal and repository, and ordered steps numbered `S1`, `S2` and so on. Give a `parentPlanId` and `parentStep` and the new plan becomes a sub-plan that expands one step of another plan. It returns the whole plan with its `nextAction`. It needs the `reviews:write` scope, and it works only where the deployment has plan tracking turned on.

## When to call it

- **Before work that will outlast one session,** so the next session, or another agent, can pick it up with [`get_plan`](/docs/mcp-server/get_plan).
- **When one step is too big to do in one go.** Make a sub-plan for it instead of adding a dozen vague steps to the parent.
- **When the finish line can be checked.** Give each step `acceptance`, what must be true for it to count as done. Marking that step `done` then needs `evidence`, as [`update_plan_step`](/docs/mcp-server/update_plan_step) explains.

Don't create a plan for a task you can finish now.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `title` | string, at most 200 characters | yes |  |
| `goal` | string | no | What the plan achieves and why |
| `repo` | string | no | Repository as owner/name |
| `parentPlanId` | string | no | Make this a sub-plan of that plan |
| `parentStep` | string | no | The parent's step this sub-plan expands; required with parentPlanId |
| `steps` | array of objects, at most 200 | no |  |
| `steps[].title` | string, at most 200 characters | yes |  |
| `steps[].detail` | string | no | How to do it, files, constraints |
| `steps[].acceptance` | string | no | What must be true for it to count as done; marking it done then needs evidence |
| `agent` | string | no | Your agent name, kept in the plan's history |

It writes: the server marks it `readOnlyHint: false`, so a client that asks before writes asks here.

Only `title` is required. `steps` can be left out and added later with [`add_plan_steps`](/docs/mcp-server/add_plan_steps); a plan with no steps has the `nextAction` `add_steps`. Each step is `{ title, detail?, acceptance? }`. `detail` is for how to do it (files, constraints), `acceptance` for how to know it is done. A plan holds at most 200 steps.

`repo` must be a repository you have connected. A sub-plan takes its parent's repository when you leave `repo` out.

If you don't pass `agent`, the MCP client's own name is stored in the history.

### Sub-plans

A sub-plan is a full plan of its own, hung on one step of its parent:

- `parentPlanId` and `parentStep` go together. One without the other fails with `parentPlanId and parentStep go together: a sub-plan expands one step`.
- The parent must be `active`, and the step must not be `done` or `skipped`. Reopen the step first.
- Plans nest at most 5 deep, and a plan holds at most 50 sub-plans.
- While the sub-plan is active, the parent step can only be set to `in_progress`. It can't be marked `done`, `blocked` or `skipped` until the sub-plan completes or is abandoned. Block a step inside the sub-plan instead.
- The parent's `nextAction` leads into the sub-plan only while the parent step is `in_progress`. Start the step, then follow `nextAction`.

An account holds at most 1,000 plans. Other limits: a title is at most 200 characters, and a goal, `detail` or `acceptance` at most 20,000.

With plan tracking off on the deployment, the call fails with `CodePanel: Plan tracking is off on this deployment (PLAN_TRACKING)`, and nothing is saved.

## What it returns

The plan, in the shape [`get_plan`](/docs/mcp-server/get_plan) returns: `planId`, `status` (always `active` at first), `progress`, `steps`, a `history` with one `created` entry, and `nextAction`. For a sub-plan, `parentPlanId` and `parentStep` say where it hangs, and the parent's history gets a `subplan_added` entry.

## Examples

These responses come from a test account on a local backend.

### A plan with two steps

```json title="Call"
{
  "title": "Fix rate limiter bucket key",
  "goal": "Make the login limit apply per client, not per X-Forwarded-For value",
  "repo": "codepanel-dev/web-app",
  "steps": [
    {
      "title": "Key the limiter on the trusted hop",
      "detail": "src/server/auth/rateLimit.ts:48",
      "acceptance": "A test sends ten requests with different X-Forwarded-For values and the eleventh is refused"
    },
    {
      "title": "Run INCR and EXPIRE atomically"
    }
  ],
  "agent": "claude-code"
}
```

```json title="Result"
{
  "createdAt": 1794614635238,
  "goal": "Make the login limit apply per client, not per X-Forwarded-For value",
  "history": [
    {
      "agent": "claude-code",
      "at": 1794614635238,
      "detail": "2 steps",
      "from": null,
      "id": "x57fkms5m38sve8tfpcrbcyr4d8j7hmm",
      "kind": "created",
      "reason": null,
      "step": null,
      "to": null
    }
  ],
  "nextAction": {
    "action": "start",
    "planId": "xd7ffsskhwq6bg3ff59ptazsh98j7xjs",
    "reason": "it is the next pending step",
    "step": "S1",
    "steps": []
  },
  "parentPlanId": null,
  "parentStep": null,
  "planId": "xd7ffsskhwq6bg3ff59ptazsh98j7xjs",
  "progress": {
    "blocked": 0,
    "done": 0,
    "inProgress": 0,
    "pending": 2,
    "skipped": 0,
    "total": 2
  },
  "repo": "codepanel-dev/web-app",
  "status": "active",
  "steps": [
    {
      "acceptance": "A test sends ten requests with different X-Forwarded-For values and the eleventh is refused",
      "completedAt": null,
      "detail": "src/server/auth/rateLimit.ts:48",
      "evidence": null,
      "reason": null,
      "ref": "S1",
      "status": "pending",
      "subplans": [],
      "title": "Key the limiter on the trusted hop",
      "updatedAt": 1794614635238
    },
    {
      "acceptance": null,
      "completedAt": null,
      "detail": null,
      "evidence": null,
      "reason": null,
      "ref": "S2",
      "status": "pending",
      "subplans": [],
      "title": "Run INCR and EXPIRE atomically",
      "updatedAt": 1794614635238
    }
  ],
  "title": "Fix rate limiter bucket key",
  "updatedAt": 1794614635238
}
```

`nextAction` says to start `S1`. `S1` has an `acceptance`, so it can only be marked `done` with `evidence`. `S2` has none.

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel plan create <file or ->` reads this tool's JSON from a file or stdin ([CLI](/docs/cli#tracked-plans)) |
| HTTP API | [`POST /plans`](/docs/api#post-plans) with the same fields |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Save a plan to work through over many sessions: a title, an optional goal and repo, and ordered steps (numbered S1, S2, ... for the plan's life). With parentPlanId and parentStep (like S2) it is a sub-plan expanding that step: the parent's nextAction then leads into it, and the parent step cannot be marked done while it is active. Returns the plan: planId, status (active, completed, abandoned), progress, steps (ref like S3, status pending|in_progress|done|blocked|skipped, acceptance, evidence, reason, subplans), history (newest first, with deviations and reasons) and nextAction. Act on nextAction: start or continue its step (in its planId, which may be a sub-plan), unblock its steps, add_steps, or done.

## Related

- [`add_plan_steps`](/docs/mcp-server/add_plan_steps): grow the plan later.
- [`update_plan_step`](/docs/mcp-server/update_plan_step): work through the steps.
- [`get_plan`](/docs/mcp-server/get_plan): read it back in another session.
- [Keep a long plan across sessions](/docs/mcp-server#keep-a-long-plan-across-sessions): the workflow.
- [Tracked plans](/docs/api#tracked-plans): the rules, in the HTTP API reference.
