index.mdx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ---
  2. title: "Get started"
  3. description: "Get started with OpenCode."
  4. ---
  5. <Callout type="warning">
  6. These docs are for the beta version of OpenCode, which will become OpenCode 2.0. The beta is still changing: we may
  7. wipe your data, things may break, and APIs, configuration, and plugin APIs may change.
  8. </Callout>
  9. <Callout type="note">
  10. OpenCode 2 installs and runs as `opencode2`. It does not replace OpenCode 1's `opencode` binary, so you can keep both
  11. versions installed and run them side by side.
  12. </Callout>
  13. ## Install
  14. <Callout type="note">The curl install script is not available in beta.</Callout>
  15. You can also install it with the following package managers.
  16. <Tabs>
  17. <Tab title="npm">
  18. ```bash
  19. npm install -g @opencode-ai/cli@next
  20. ```
  21. </Tab>
  22. <Tab title="bun">
  23. ```bash
  24. bun install -g --trust @opencode-ai/cli@next
  25. ```
  26. </Tab>
  27. <Tab title="pnpm">
  28. ```bash
  29. pnpm add -g --allow-build=@opencode-ai/cli @opencode-ai/cli@next
  30. ```
  31. </Tab>
  32. <Tab title="Yarn">
  33. ```bash
  34. yarn global add @opencode-ai/cli@next
  35. ```
  36. </Tab>
  37. </Tabs>
  38. The package uses a trusted postinstall script to select the native `opencode2` binary for your platform. The Bun and pnpm
  39. commands above explicitly allow that script to run.
  40. ### Homebrew
  41. Homebrew installation is not available in beta.
  42. ### Arch Linux
  43. Arch Linux installation is not available in beta.
  44. ### Windows
  45. <Callout type="tip">
  46. For the best experience on Windows, install [Windows Subsystem for Linux
  47. (WSL)](https://learn.microsoft.com/windows/wsl/install), open your Linux distribution, and use one of the beta package
  48. manager commands above.
  49. </Callout>
  50. <Tabs>
  51. <Tab title="chocolatey">
  52. Chocolatey installation is not available in beta.
  53. </Tab>
  54. <Tab title="scoop">
  55. Scoop installation is not available in beta.
  56. </Tab>
  57. <Tab title="mise">
  58. Mise installation is not available in beta.
  59. </Tab>
  60. <Tab title="docker">
  61. Docker installation is not available in beta.
  62. </Tab>
  63. </Tabs>
  64. Standalone binaries are not available in beta.
  65. ---
  66. #### Prerequisites
  67. To use OpenCode in your terminal, you'll need:
  68. 1. A modern terminal emulator like:
  69. - [Ghostty](https://ghostty.org), Linux and macOS
  70. - [WezTerm](https://wezterm.org), cross-platform
  71. - [Alacritty](https://alacritty.org), cross-platform
  72. - [Kitty](https://sw.kovidgoyal.net/kitty/), Linux and macOS
  73. 2. API keys for the LLM providers you want to use.
  74. ---
  75. ## Connect
  76. With OpenCode you can use any LLM provider by configuring its API key.
  77. Run `/connect` in the TUI and select your provider.
  78. ```text
  79. /connect
  80. ```
  81. If you'd like easy access to all the best coding models you can try out
  82. [OpenCode Console](https://console.opencode.ai).
  83. You can also try [OpenCode Go](https://opencode.ai/go) a $10/month subscription
  84. plan that grants you access to the best open source models.
  85. Use `/models` to browse the providers and models available to your project. See [Providers](/providers) for connection and
  86. configuration details.
  87. ---
  88. ## Usage
  89. You are now ready to use OpenCode in your project. Here are a few common workflows.
  90. ### Ask questions
  91. Ask OpenCode to explain your codebase.
  92. <Callout type="tip">Use `@` to fuzzy search for files in the project.</Callout>
  93. ```text
  94. How is authentication handled in @packages/functions/src/api/index.ts
  95. ```
  96. ### Add features
  97. Ask OpenCode to add a feature by describing the desired behavior and providing relevant context.
  98. ```text
  99. When a user deletes a note, flag it as deleted in the database.
  100. Create a screen that shows recently deleted notes.
  101. From this screen, the user can restore a note or permanently delete it.
  102. ```
  103. <Callout type="tip">Give OpenCode plenty of context and examples.</Callout>
  104. ### Undo changes
  105. Use `/undo` when a change isn't what you wanted.
  106. ```text
  107. /undo
  108. ```
  109. OpenCode stages a conversation revert and restores your original message so you can revise it. In a Git repository, it
  110. also restores file changes when snapshots were captured successfully. Run `/undo` multiple times to move the conversation
  111. boundary back, or use `/redo` to restore the staged conversation and files. See [Undo](/snapshots) for
  112. limitations and safety details.
  113. ```text
  114. /redo
  115. ```
  116. ---
  117. ## Customize
  118. Make OpenCode your own by [picking a theme](/themes), [customizing
  119. keybinds](https://opencode.ai/docs/keybinds), [configuring formatters](/formatters), [creating commands](/commands), or
  120. editing the [OpenCode config](/config).