跳轉到主要內容
外掛程式市場是可用外掛程式的目錄,可輕鬆發現、安裝和管理 Claude Code 擴充功能。本指南展示如何使用現有市場以及為團隊分發建立自己的市場。

概述

市場是一個 JSON 檔案,列出可用的外掛程式並描述在何處找到它們。市場提供:
  • 集中式發現:在一個地方瀏覽來自多個來源的外掛程式
  • 版本管理:自動追蹤和更新外掛程式版本
  • 團隊分發:在整個組織中共享必需的外掛程式
  • 靈活的來源:支援 git 儲存庫、GitHub 儲存庫、本地路徑和套件管理器

先決條件

  • 已安裝並執行 Claude Code
  • 基本熟悉 JSON 檔案格式
  • 建立市場:Git 儲存庫或本地開發環境

新增和使用市場

使用 /plugin marketplace 命令新增市場以存取來自不同來源的外掛程式:

新增 GitHub 市場

新增包含 .claude-plugin/marketplace.json 的 GitHub 儲存庫
/plugin marketplace add owner/repo

新增 Git 儲存庫

新增任何 git 儲存庫
/plugin marketplace add https://gitlab.com/company/plugins.git

新增本地市場以進行開發

新增包含 .claude-plugin/marketplace.json 的本地目錄
/plugin marketplace add ./my-marketplace
新增 marketplace.json 檔案的直接路徑
/plugin marketplace add ./path/to/marketplace.json
透過 URL 新增遠端 marketplace.json
/plugin marketplace add https://url.of/marketplace.json

從市場安裝外掛程式

新增市場後,直接安裝外掛程式:
從任何已知市場安裝
/plugin install plugin-name@marketplace-name
互動式瀏覽可用的外掛程式
/plugin

驗證市場安裝

新增市場後:
  1. 列出市場:執行 /plugin marketplace list 以確認已新增
  2. 瀏覽外掛程式:使用 /plugin 查看來自市場的可用外掛程式
  3. 測試安裝:嘗試安裝外掛程式以驗證市場是否正常運作

設定團隊市場

透過在 .claude/settings.json 中指定必需的市場,為團隊專案設定自動市場安裝:
{
  "extraKnownMarketplaces": {
    "team-tools": {
      "source": {
        "source": "github",
        "repo": "your-org/claude-plugins"
      }
    },
    "project-specific": {
      "source": {
        "source": "git",
        "url": "https://git.company.com/project-plugins.git"
      }
    }
  }
}
當團隊成員信任儲存庫資料夾時,Claude Code 會自動安裝這些市場以及 enabledPlugins 欄位中指定的任何外掛程式。

建立自己的市場

為團隊或社群建立和分發自訂外掛程式集合。

市場建立的先決條件

  • Git 儲存庫(GitHub、GitLab 或其他 git 託管)
  • 了解 JSON 檔案格式
  • 一個或多個要分發的外掛程式

建立市場檔案

在儲存庫根目錄中建立 .claude-plugin/marketplace.json
{
  "name": "company-tools",
  "owner": {
    "name": "DevTools Team",
    "email": "[email protected]"
  },
  "plugins": [
    {
      "name": "code-formatter",
      "source": "./plugins/formatter",
      "description": "Automatic code formatting on save",
      "version": "2.1.0",
      "author": {
        "name": "DevTools Team"
      }
    },
    {
      "name": "deployment-tools",
      "source": {
        "source": "github",
        "repo": "company/deploy-plugin"
      },
      "description": "Deployment automation tools"
    }
  ]
}

市場架構

必需欄位

欄位類型描述
namestring市場識別碼(kebab-case,無空格)
ownerobject市場維護者資訊
pluginsarray可用外掛程式清單

選用中繼資料

欄位類型描述
metadata.descriptionstring簡短的市場描述
metadata.versionstring市場版本
metadata.pluginRootstring相對外掛程式來源的基本路徑

外掛程式項目

外掛程式項目基於外掛程式資訊清單架構(所有欄位均為選用)加上市場特定欄位(sourcecategorytagsstrict),其中 name 為必需。
必需欄位:
欄位類型描述
namestring外掛程式識別碼(kebab-case,無空格)
sourcestring|object從何處擷取外掛程式

選用外掛程式欄位

標準中繼資料欄位:
欄位類型描述
descriptionstring簡短的外掛程式描述
versionstring外掛程式版本
authorobject外掛程式作者資訊
homepagestring外掛程式首頁或文件 URL
repositorystring原始碼儲存庫 URL
licensestringSPDX 授權識別碼(例如 MIT、Apache-2.0)
keywordsarray用於外掛程式發現和分類的標籤
categorystring用於組織的外掛程式類別
tagsarray用於可搜尋性的標籤
strictboolean要求外掛程式資料夾中的 plugin.json(預設值:true) 1
元件設定欄位:
欄位類型描述
commandsstring|array命令檔案或目錄的自訂路徑
agentsstring|array代理檔案的自訂路徑
hooksstring|object自訂掛鉤設定或掛鉤檔案的路徑
mcpServersstring|objectMCP 伺服器設定或 MCP 設定的路徑
1 - 當 strict: true(預設值)時,外掛程式必須包含 plugin.json 資訊清單檔案,市場欄位補充這些值。當 strict: false 時,plugin.json 是選用的。如果遺失,市場項目將作為完整的外掛程式資訊清單。

外掛程式來源

相對路徑

對於同一儲存庫中的外掛程式:
{
  "name": "my-plugin",
  "source": "./plugins/my-plugin"
}

GitHub 儲存庫

{
  "name": "github-plugin",
  "source": {
    "source": "github",
    "repo": "owner/plugin-repo"
  }
}

Git 儲存庫

{
  "name": "git-plugin",
  "source": {
    "source": "url",
    "url": "https://gitlab.com/team/plugin.git"
  }
}

進階外掛程式項目

外掛程式項目可以覆蓋預設元件位置並提供其他中繼資料。請注意,${CLAUDE_PLUGIN_ROOT} 是一個環境變數,會解析為外掛程式的安裝目錄(詳見環境變數):
{
  "name": "enterprise-tools",
  "source": {
    "source": "github",
    "repo": "company/enterprise-plugin"
  },
  "description": "Enterprise workflow automation tools",
  "version": "2.1.0",
  "author": {
    "name": "Enterprise Team",
    "email": "[email protected]"
  },
  "homepage": "https://docs.company.com/plugins/enterprise-tools",
  "repository": "https://github.com/company/enterprise-plugin",
  "license": "MIT",
  "keywords": ["enterprise", "workflow", "automation"],
  "category": "productivity",
  "commands": [
    "./commands/core/",
    "./commands/enterprise/",
    "./commands/experimental/preview.md"
  ],
  "agents": [
    "./agents/security-reviewer.md",
    "./agents/compliance-checker.md"
  ],
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [{"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh"}]
      }
    ]
  },
  "mcpServers": {
    "enterprise-db": {
      "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
      "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"]
    }
  },
  "strict": false
}
架構關係:外掛程式項目使用外掛程式資訊清單架構,所有欄位均為選用,加上市場特定欄位(sourcestrictcategorytags)。這表示 plugin.json 檔案中有效的任何欄位也可以在市場項目中使用。當 strict: false 時,如果不存在 plugin.json,市場項目將作為完整的外掛程式資訊清單。當 strict: true(預設值)時,市場欄位補充外掛程式自己的資訊清單檔案。

託管和分發市場

選擇最適合外掛程式分發需求的託管策略。

在 GitHub 上託管(建議)

GitHub 提供最簡單的分發方法:
  1. 建立儲存庫:為市場設定新儲存庫
  2. 新增市場檔案:使用外掛程式定義建立 .claude-plugin/marketplace.json
  3. 與團隊共享:團隊成員使用 /plugin marketplace add owner/repo 新增
優點:內建版本控制、問題追蹤和團隊協作功能。

在其他 git 服務上託管

任何 git 託管服務都可用於市場分發,使用任意 git 儲存庫的 URL。 例如,使用 GitLab:
/plugin marketplace add https://gitlab.com/company/plugins.git

使用本地市場進行開發

在分發前在本地測試市場:
新增本地市場進行測試
/plugin marketplace add ./my-local-marketplace
測試外掛程式安裝
/plugin install test-plugin@my-local-marketplace

管理市場操作

列出已知市場

列出所有已設定的市場
/plugin marketplace list
顯示所有已設定的市場及其來源和狀態。

更新市場中繼資料

重新整理市場中繼資料
/plugin marketplace update marketplace-name
從市場來源重新整理外掛程式清單和中繼資料。

移除市場

移除市場
/plugin marketplace remove marketplace-name
從設定中移除市場。
移除市場將卸載您從中安裝的任何外掛程式。

市場疑難排解

常見市場問題

市場未載入

症狀:無法新增市場或看不到其中的外掛程式 解決方案
  • 驗證市場 URL 是否可存取
  • 檢查 .claude-plugin/marketplace.json 是否存在於指定路徑
  • 使用 claude plugin validate 確保 JSON 語法有效
  • 對於私人儲存庫,確認您有存取權限

外掛程式安裝失敗

症狀:市場出現但外掛程式安裝失敗 解決方案
  • 驗證外掛程式來源 URL 是否可存取
  • 檢查外掛程式目錄是否包含必需的檔案
  • 對於 GitHub 來源,確保儲存庫是公開的或您有存取權
  • 透過手動複製/下載測試外掛程式來源

驗證和測試

在共享前測試市場:
驗證市場 JSON 語法
claude plugin validate .
新增市場進行測試
/plugin marketplace add ./path/to/marketplace
安裝測試外掛程式
/plugin install test-plugin@marketplace-name
如需完整的外掛程式測試工作流程,請參閱在本地測試外掛程式。如需技術疑難排解,請參閱外掛程式參考

後續步驟

對於市場使用者

  • 發現社群市場:在 GitHub 上搜尋 Claude Code 外掛程式集合
  • 貢獻回饋:向市場維護者報告問題並建議改進
  • 共享有用的市場:幫助團隊發現有價值的外掛程式集合

對於市場建立者

  • 建立外掛程式集合:圍繞特定使用案例建立主題市場
  • 建立版本控制:實施清晰的版本控制和更新政策
  • 社群參與:收集回饋並維護活躍的市場社群
  • 文件:提供清晰的 README 檔案,說明市場內容

對於組織

  • 私人市場:為專有工具設定內部市場
  • 治理政策:建立外掛程式核准和安全審查的指南
  • 培訓資源:幫助團隊有效發現和採用有用的外掛程式

另請參閱