{
  "slug": "neonctl-checkout-pins-a-branch-in-neon-28add5af46b4",
  "title": "neonctl checkout pins a branch in .neon",
  "tools": [
    "neonctl"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-06-04T13:28:49.000Z",
  "announced_at": "2026-06-04T13:28:49.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When switching a repository’s Neon context to a branch, run `neonctl checkout <id|name>`; it resolves the branch for the active project and updates `.neon` so subsequent commands use it. In CI or without a TTY, pass the branch explicitly.",
    "examples": [
      "neonctl checkout <id|name>",
      "neonctl checkout <branch> --project-id <project_id>"
    ],
    "gotchas": [
      "Version: v2.22.2",
      "[id|name]: Branch ID or name. Omit only in an interactive terminal to choose from a branch list; `br-…` is treated as an ID. A missing name may be offered for creation interactively.",
      "--project-id <id>: Select the project; takes precedence over the closest `.neon` project ID and single-project API-key auto-detection.",
      "--org-id <id>: Organization ID; used to identify the organization when supplied. Otherwise checkout can use the existing `.neon` value or look it up from the project.",
      "--api-key <neon_api_key>: Authenticates the command with a Neon API key instead of `neonctl auth`.",
      "Prerequisite: Install the Neon CLI; the README documents `npm i -g neonctl` and requires Node.js 18.0 or higher for npm installation.",
      "Prerequisite: Authenticate with `neonctl auth` or pass `--api-key`.",
      "Prerequisite: In CI or without a TTY, pass the branch explicitly.",
      "An omitted branch is supported only in an interactive terminal; in CI or without a TTY, pass a branch explicitly.",
      "A `br-…` value is treated as an id and matched strictly; a nonexistent id produces a not-found error and is not created.",
      "A missing name can be created only through the interactive-terminal offer; in a non-interactive context a missing name produces a not-found error.",
      "Project resolution order is `--project-id`, the closest `.neon`, then auto-detection when the API key maps to exactly one project.",
      "When a project has an organization, checkout writes `orgId` as well as `projectId` and `branchId`; when `orgId` is unknown it is looked up from the project."
    ]
  },
  "why_it_matters": "Switch a repository’s Neon CLI context to the branch being worked on.",
  "before": "Use `neonctl set-context` to write `.neon` context directly; checkout is documented as a focused helper over `set-context` for switching branches.",
  "sources": [
    "https://github.com/neondatabase/neonctl/releases/tag/v2.22.2",
    "https://github.com/neondatabase/neonctl/pull/497",
    "https://github.com/neondatabase/neonctl/blob/v2.22.2/README.md"
  ],
  "rank": 0.95049,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2a-20261017",
    "verdict_id": "wave2a-20261017:wave2a-20261017-36c2bc321495e539-3:gate",
    "evidence_hash": "54af7d3b6f9046345b81475124f92065ccd208bf51a027b6f5c4c0710c9c5c4f"
  },
  "review": {
    "draft_hash": "b8f3d063e906bbe6ad7c267a1e94e28c4b8034fca33a8a6e0640f2ba443d7115",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2a-20261017:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.95 >= 0.9; 2 needed) and Jev gave 0.84 (>= 0.6 needed)."
  }
}
