Skip to content

安裝 ​

先決條件 ​

  • Node.js 20.19.0 或更高版本 — 檢查您的版本:node --version

透過 AI 助手安裝 ​

不想手動操作?將下方的提示詞貼到任何能執行 shell 指令的程式碼助手(例如 Claude Code、Codex、Cursor、Gemini CLI、Copilot 以及其他支援的工具)。它會安裝 CLI、初始化此專案,並回報實際執行的結果。

下方的手動步驟是唯一的正確來源 — 提示詞只是為您執行這些步驟。如果您的助手暫停並回報結果,這是設計如此:在執行任何需要特權的操作前它會先詢問,且絕不會修改您的 shell 啟動檔案。請自行透過套件管理器和疑難排解完成這些部分。

text
Install OpenSpec in this project and set it up for me. Follow these steps in
order, and stop where a step tells you to stop.

1. RUNTIME. Run `node --version`. OpenSpec needs Node.js 20.19.0 or higher. If
   Node is missing or older, say so and stop — don't install Node, switch
   versions, or reconfigure my version manager for me.

2. INSTALL. Use whichever package manager is already on my PATH, preferring npm:
     npm install -g @fission-ai/openspec@latest
     pnpm add -g @fission-ai/openspec@latest
     bun add -g @fission-ai/openspec@latest
     yarn global add @fission-ai/openspec@latest   (Yarn 1.x only)
   Don't pick based on this project's lockfile — a global install has nothing to
   do with how this repo's own dependencies are installed. If none of those four
   is available, stop and tell me — don't improvise an install. (If I'm on Nix,
   point me at the Nix section of the OpenSpec installation docs instead.)
   Show me the exact command and let me confirm before you run it; this installs
   software outside the project, and I may want a different package manager to
   own it.
   Stop and ask me again if the install needs sudo or admin rights, fails with a
   permissions error, or reports that its global bin directory is missing or
   unconfigured. Never edit my shell startup files (.bashrc, .zshrc, .profile,
   fish, PowerShell profile), and never run a setup command that edits them for
   me — show me the change and let me make it.

3. PATH. Run `openspec --version`. If the command isn't found, it may just be
   missing from this shell: tell me where the package manager installed it and
   how to add that directory to PATH for my shell and OS, then stop until I
   confirm. If it prints an older version than the one the install just
   reported, an earlier copy is shadowing it on PATH — tell me both versions
   instead of continuing. If I use a version manager, say so rather than editing
   PATH around it: with nvm or fnm the CLI is tied to the Node version that was
   active when you installed it, and with asdf or volta a shim may need
   regenerating.

4. INITIALIZE. Ask me which AI coding tool or tools I use and map each to an id
   from `openspec init --help` (Copilot is `github-copilot`, Zoo Code is
   `roocode`). `--tools` takes a comma-separated list, so name all of them.
   `openspec init --tools <ids>` deletes leftovers from older OpenSpec versions
   automatically, without asking — including `opsx-*.md` prompt files in my home
   directory (Codex keeps them in ~/.codex/prompts). Before you run it, look for
   those: `.../commands/openspec/` folders, OpenSpec marker blocks in files like
   CLAUDE.md or AGENTS.md, and home-directory `opsx-*.md` prompts. List whatever
   you find and wait for my go-ahead; if you find nothing, say so and carry on
   without asking. An existing `openspec/` folder is not a problem — init
   refreshes it and leaves my specs and changes alone.
   Confirm I'm in the right folder too: init creates `openspec/` wherever it
   runs, including inside a monorepo package.
   Then run: openspec init --tools <ids>

5. REPORT. Don't assume what should exist — tell me what init actually printed:
   how many skills and/or commands it created and where, the config file line,
   any "Setup required" note, and what to restart or reload. Some tools are
   skills-only and correctly create zero command files, so missing commands is
   not a failure on its own. If init said nothing was generated, relay the fix
   it suggested instead of retrying. Finish by telling me how to invoke OpenSpec
   in my tool, and take the exact spelling from the files init created rather
   than from its summary line: the punctuation differs per tool (/opsx:propose
   in some, /opsx-propose in others, @opsx-propose in Amazon Q), and tools that
   get skills instead of commands are invoked by skill name (/openspec-propose,
   or $openspec-propose in Codex, or /skill:openspec-propose in Kimi Code).

提示詞中沒有任何供應商特定的內容:它只是純文字說明加上本頁文件中的相同指令。它適用於 macOS、Linux 和 Windows,並且在步驟需要您授權時會刻意暫停而非擅自處理。您的助手需要能夠執行 shell 指令 — 部分 IDE 整合無法做到這一點。

套件管理器 ​

npm ​

bash
npm install -g @fission-ai/openspec@latest

pnpm ​

bash
pnpm add -g @fission-ai/openspec@latest

yarn ​

bash
yarn global add @fission-ai/openspec@latest

Yarn 2 及之後版本(Berry)已移除 global 指令。在這些版本上,請改用 npm、pnpm 或 bun 安裝 OpenSpec — 全域 CLI 不需要與專案共用相同的套件管理器。

deno ​

Deno 有時在解析 @latest 標籤時會遇到問題,但我們可以在初始安裝時指定版本。 如果發生此情況,您可以嘗試將 @latest 標籤替換為版本號,例如 @^1.3.1

bash
deno install --global \
  --allow-read --allow-write --allow-env --allow-sys=cpus,homedir --allow-net=edge.openspec.dev \
  npm:@fission-ai/openspec@latest
# or
deno install --global \
  --allow-read --allow-write --allow-env --allow-sys=cpus,homedir --allow-net=edge.openspec.dev \
  npm:@fission-ai/openspec@^1.3.1

注意:如果您的子指令會啟動外部工具(例如 config edit、feedback 或 workspace open),您可能需要加上範圍限定的 --allow-run=<program>。

bun ​

Bun 可以全域安裝 OpenSpec,但 OpenSpec 目前運行在 Node.js 上。 您仍然需要在 PATH 上擁有 Node.js 20.19.0 或更高版本。

bash
bun add -g @fission-ai/openspec@latest

Nix ​

直接運行 OpenSpec 而無需安裝:

bash
nix run github:Fission-AI/OpenSpec -- init

或安裝到您的 profile:

bash
nix profile install github:Fission-AI/OpenSpec

或將其加入 flake.nix 中的開發環境:

nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    openspec.url = "github:Fission-AI/OpenSpec";
  };

  outputs = { nixpkgs, openspec, ... }: {
    devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
      buildInputs = [ openspec.packages.x86_64-linux.default ];
    };
  };
}

驗證安裝 ​

bash
openspec --version

更新 ​

升級套件,然後刷新每個專案的生成檔案:

bash
npm install -g @fission-ai/openspec@latest   # or pnpm/yarn/bun equivalent
openspec update                              # run inside each project

openspec update 會為您已設定的工具重新生成 skill 和 command 檔案,使您的斜線指令與已安裝的版本保持同步。它也會檢查是否有更新的 CLI 版本已發布並提供升級選項,因為升級正是讓新工作流程可用的前提 — 請參閱CLI 參考。

卸載 ​

沒有 openspec uninstall 指令,因為 OpenSpec 只是一個全域套件加上專案中的部分檔案。移除它只需幾個手動步驟,且不會觸及您的原始碼。

1. 移除全域套件:

bash
npm uninstall -g @fission-ai/openspec   # or: pnpm rm -g / yarn global remove / bun rm -g

2. 從專案中移除 OpenSpec(選做)。 如果您不再需要其規格和變更記錄,請刪除 openspec/ 目錄:

bash
rm -rf openspec/

執行此操作前請三思:openspec/specs/ 和 openspec/changes/archive/ 是系統行為及變更原因的記錄。如果您可能還需要這些歷史記錄,請保留該目錄(或將其保留在 git 中),即使已卸載。

3. 移除生成的 AI 工具檔案(選做)。 OpenSpec 會將 skill 和 command 檔案寫入各工具的目錄中,例如 .claude/skills/openspec-*/、.cursor/commands/opsx-* 等。請刪除您已設定的工具對應的 openspec-* skills 和 opsx-* commands。各工具的具體路徑列於支援的工具中。

如果您在 CLAUDE.md 或 AGENTS.md 等檔案中也有 OpenSpec 標記區塊,請手動移除這些區塊;這些檔案中您自己的內容則保留不動。

下一步 ​

安裝完成後,在您的專案中初始化 OpenSpec:

bash
cd your-project
openspec init

請參閱快速入門了解完整教學。