/setup — 初始化專案

執行此指令將自動配置 Morphowiki 工作區,將空白目錄轉換為功能完備的構詞學字典環境。

/setup — Initialize the project

Run this once inside Claude Code to turn the empty cloned folder into a working Morphowiki workspace.

功能說明

Morphowiki 由多個相互關聯的模組組成:包含單字、前綴、字根、後綴的字典架構;複習網頁的伺服器與前端界面;預設排除的常用詞(stopwords)清單;以及相關的 npm 套件。若手動建立這些組件,極易發生目錄遺漏或檔案命名錯誤,導致後續指令失效。

/setup 旨在實現「一鍵配置」:自動建立完整的目錄樹、生成初始設定檔、寫入約 150 個預設停用詞,並執行 npm install 安裝複習界面所需的環境。您只需在 Claude Code 中執行一次即可完成部署。

辨析:/setup/init 的區別

/initClaude Code 內建指令,用於生成專案說明檔 CLAUDE.md。而 /setup 是本專案專有的初始化工具。初次使用時請務必執行 /setup。若誤用 /init 雖不致損壞系統,但無法建立字典所需的資料夾結構。

Why this exists

Morphowiki isn't a one-file tool. It has several moving parts that depend on each other: the dictionary folders (for words, prefixes, roots, suffixes), the review web app (server plus front-end), a default list of high-frequency English function words to skip (the stopwords), and the npm packages the review app needs. If you had to create all that by hand, it would be easy to miss a folder or mistype a filename, and then every other skill would fail.

/setup handles all of it in one go: the folder tree, the seed files, a list of about 150 default stopwords, and the npm install for the review server. You only need to type /setup once inside Claude Code.

Very important: /setup is not /init.

/init is a built-in Claude Code command that generates a CLAUDE.md file (an instruction file for the LLM). /setup is this project's own command that builds the Morphowiki folder structure. For first-time setup, type /setup, not /init. Running /init by mistake won't break anything, but it won't create the dictionary folders either.

預期結果範例

進入 Morphowiki 專案路徑後,於 Claude Code 輸入:

/setup

系統將回報執行進度(實際文字可能因版本微調):

環境檢測 Node.js: v20.11.0  (OK)
配置目錄結構:
  dictionary/           [已建立]
  dictionary/words/     [已建立]
  dictionary/prefix/    [已建立]
  dictionary/root/      [已建立]
  dictionary/suffix/    [已建立]
  review/               [已建立]
  review/web/           [已建立]

初始化核心檔案:
  dictionary/index.md       [已同步]
  dictionary/log.md         [證實建立]
  dictionary/stopwords.md   [已寫入 ~150 個功能詞]
  review/flashcards.json    [已建立]
  review/server.js          [已導出]
  review/web/index.html     [已建立]
  review/web/app.js         [已建立]
  review/web/style.css      [已建立]
  review/package.json       [已建立]

安裝複習組件環境:npm install --prefix review  (成功)

建議後續步驟:
  /ingest <單字>       收錄首個單字
  /flashcard <單字>    加入複習清單
  /review-word         啟動複習界面

完成後,工作區結構如下:

Morphowiki/
├── .claude/skills/        ← 核心邏輯 (Skills)
├── dictionary/            ← 字典資料庫
│   ├── index.md           ← 單字總索引
│   ├── log.md             ← 系統操作日誌
│   ├── stopwords.md       ← 停用詞白名單
│   ├── words/             ← 單字 Markdown
│   ├── prefix/            ← 前綴庫
│   ├── root/              ← 字根庫
│   └── suffix/            ← 後綴庫
├── review/                ← 複習模組
│   ├── server.js          ← 本機伺服器
│   ├── flashcards.json    ← 複習排程與進度
│   ├── package.json
│   ├── node_modules/      ← 執行環境組件
│   └── web/               ← 前端 UI
└── CLAUDE.md, README.md 等

至此,專案已配置完成,您可以開始使用 /ingest 建檔。

A concrete example

Suppose you just downloaded Morphowiki from GitHub. You open Claude Code, navigate into the project folder, and type:

/setup

Claude Code will report back what it did (the exact wording varies by version, but it looks roughly like this):

Detected Node.js: v20.11.0  (OK)
Created directories:
  dictionary/           created
  dictionary/words/     created
  dictionary/prefix/    created
  dictionary/root/      created
  dictionary/suffix/    created
  review/               created
  review/web/           created

Created files:
  dictionary/index.md       created
  dictionary/log.md         created
  dictionary/stopwords.md   created  (~150 default function words)
  review/flashcards.json    created
  review/server.js          created
  review/web/index.html     created
  review/web/app.js         created
  review/web/style.css      created
  review/package.json       created

Installed review dependencies: npm install --prefix review  (OK)

Next steps:
  /ingest <word>       Pick up your first word
  /flashcard <word>    Add it to the review deck
  /review-word         Open the review web app

Afterwards, your project folder looks like this:

Morphowiki/
├── .claude/skills/        ← Skills loaded by Claude Code
├── dictionary/
│   ├── index.md           ← Dictionary table of contents (skill-maintained)
│   ├── log.md             ← Append-only activity log
│   ├── stopwords.md       ← Words to skip (default + custom)
│   ├── words/             ← One .md file per word
│   ├── prefix/            ← One .md file per prefix
│   ├── root/              ← One .md file per root
│   └── suffix/            ← One .md file per suffix
├── review/
│   ├── server.js          ← Local server (node runs this)
│   ├── flashcards.json    ← Flashcard data (SM-2 progress)
│   ├── package.json
│   ├── node_modules/      ← Appears after npm install
│   └── web/               ← Flip-card review UI front-end
└── CLAUDE.md, README.md, etc.

At this point the project is ready, and your next step is to pick up your first word with /ingest.

操作指南

  1. 前置需求:確保已安裝 Claude Code,並完成 Morphowiki 專案下載(Git 或 ZIP)。若尚未安裝環境,請參閱入門設定
  2. 啟動環境:進入專案根目錄(cd 進去後執行 claude)。
  3. 執行初始化:輸入 /setup 並按 Enter。程式通常在一分鐘內完成(主要時間取決於網路安裝 npm 套件的速度)。
  4. 確認狀態:檢視輸出結果,確認目錄、核心檔案、Node.js 檢測及相依套件均顯示為「成功」或「OK」。
  5. 結構驗證(選用):使用檔案總管確認根目錄下已生成 dictionary/review/ 資料夾。

重複執行說明:您可以隨時重新執行 /setup。系統會自動跳過已存在的檔案,不會覆蓋或損壞您的個人字典資料。

Step by step

  1. Check the prerequisites. You need Claude Code already installed, and the Morphowiki repo downloaded to your machine (via git clone or a ZIP download). If you don't have Claude Code yet, head back to Getting Started first.
  2. Open Claude Code inside the project folder. Start Claude Code from inside your Morphowiki folder (in a terminal, cd into it and run claude, or use your IDE integration). Claude Code will treat that folder as the current project.
  3. Type /setup. In the Claude Code chat input, type /setup and press Enter. The whole thing usually finishes in under a minute (npm install is the slowest step, depending on your network).
  4. Read the completion report. Claude Code will list every directory, every file, the Node.js detection result, and the npm install result. Skim it for the words "failed" or "error".
  5. (Optional) Confirm the folders are really there. Open the project in File Explorer (Windows), Finder (macOS), or with ls in a terminal. You should see new dictionary/ and review/ folders.
  6. (Optional) What if Node.js isn't installed? Claude Code will warn you and keep going. The dictionary side will still work. You only need Node.js later when you run /review-word to open the review web app — you can install it then.

Can I run it more than once? Yes. /setup skips files that already exist instead of overwriting them. If you're not sure whether you ran it before, running it again is safe — it will report "already exists" rather than error out.

疑難排除與後續步驟

常見誤區 1:將 /setup 誤植為 /init這是最常見的錯誤。/init 僅生成給 AI 參考的說明,無法配置工作環境。請認明使用 /setup

常見誤區 2:在錯誤的路徑下執行。Claude Code 會視目前路徑為專案根目錄。若於桌面或個人根目錄執行,會導致環境配置錯置。執行前請確認已 cd 進入 Morphowiki 資料夾。

常見誤區 3:環境缺失 Node.js。字典建檔功能並非必須具備 Node.js。您可以先行開始 /ingest,待需要使用 /review-word 複習功能時,再前往 nodejs.org 安裝穩定版環境。

常見誤區 4:npm 失敗即視為整體失敗。並非如此。若 npm install 失敗,僅代表複習界面無法啟動,字典架構通常已建立完成。您可以手動於終端機執行 npm install --prefix review 來修補環境。

後續探索:

Common mistakes & next steps

Common mistake 1: typing /init instead of /setup. This is the easiest pitfall. /init is a built-in Claude Code command that generates a CLAUDE.md file for the LLM to read — it has nothing to do with this project's initialization. For this project, use /setup. Running /init by mistake won't damage existing files, but you'll end up with an unwanted CLAUDE.md (or your original one overwritten) and the dictionary folders still won't be created.

Common mistake 2: running /setup in the wrong folder. Claude Code treats the current working folder as the project root. If you accidentally launch Claude Code from your desktop or home folder and then type /setup, the dictionary will be built there. Use your file manager to confirm you're inside the Morphowiki folder before you launch Claude Code.

Common mistake 3: panicking if Node.js isn't installed. You don't need to solve it right away. /setup warns when it can't detect Node.js, but the dictionary folders, stopwords, and ingest features are completely unaffected. Wait until you actually want to use /review-word to open the review web app, then download the LTS version from nodejs.org.

Common mistake 4: thinking the whole setup failed because npm install failed. It didn't. The folders and files are created before npm runs, so a failure there only means the review web app's dependencies aren't installed yet. You can still use /ingest to pick up words; later, from the project root, run npm install --prefix review in a terminal to finish the install.

Next steps:

  • Move on to /ingest to pick up your first word and watch the LLM break it into prefix, root, and suffix with two-way links.
  • If you're still unsure what Claude Code is or why you launch it from inside a folder, re-read Getting Started.
  • Curious what this dictionary looks like conceptually? Read What is a Morphowiki.