/openmatrix:om:deployfrom openmatrix
Analyzes project files and system environment to recommend deployment strategies, then generates reusable one-click scripts. Handles Docker, Kubernetes, npm publishing, and environment setup.
Ships in openmatrix. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
AI 应根据用户语义判断意图:
| 用户意图 | 应调用 |
|---|---|
| 实现功能 | /om:start |
| 修复 bug | /om:debug 或 /om:start |
| 查看状态 | /om:status |
| 用户消息 | 判断 | 结果 |
|---|---|---|
| "部署到服务器" | 部署意图 | 触发 ✓ |
| "用 Docker 运行" | 环境配置意图 | 触发 ✓ |
| "发布 npm 包" | 发布意图 | 触发 ✓ |
| "实现 API 接口" | 开发意图 | /om:start |
| "为什么部署失败" | 调查意图 | /om:debug |
cat .openmatrix/deploy-config.json 2>/dev/null || echo "NO_HISTORY"
如果有历史配置:
# 对比关键文件是否存在变化
ls -la Dockerfile docker-compose.yml Makefile Taskfile.yml 2>/dev/null
cat package.json 2>/dev/null | grep -E '"(deploy|start|build)"'
变更检测结果:
| 状态 | 处理 |
|---|---|
| 无历史配置 | 正常流程(分析+询问) |
| 无变更 | 直接使用上次配置,仅确认一次 |
| 有变更 | 重新分析并询问 |
直接读取项目文件,不调用 CLI:
# 项目配置文件
ls -la Dockerfile docker-compose.yml docker-compose.yaml Makefile Taskfile.yml Taskfile.yaml 2>/dev/null
ls -la k8s/ helm/ .github/workflows/ 2>/dev/null
cat package.json 2>/dev/null
cat go.mod 2>/dev/null
cat Cargo.toml 2>/dev/null
cat requirements.txt pyproject.toml 2>/dev/null
提取关键信息:
检测项目使用的包管理器和镜像源,如果是国外慢源则建议替换为国内镜像:
# npm/yarn/pnpm 源
npm config get registry 2>/dev/null
cat .npmrc 2>/dev/null
cat .yarnrc 2>/dev/null
cat .yarnrc.yml 2>/dev/null
# pip 源
cat pip.conf 2>/dev/null
pip config get global.index-url 2>/dev/null
# Docker 镜像源
cat /etc/docker/daemon.json 2>/dev/null
cat ~/.docker/daemon.json 2>/dev/null
# Go 代理
go env GOPROXY 2>/dev/null
# Rust 源
cat ~/.cargo/config.toml 2>/dev/null
# Gradle/Maven 源
cat build.gradle 2>/dev/null | grep -i "repositories" -A 5
cat pom.xml 2>/dev/null | grep -i "mirror" -A 5
AI 分析源速度,如果检测到国外源,建议替换:
| 包管理器 | 国外源 | 国内镜像 |
|---|---|---|
| npm/yarn/pnpm | registry.npmjs.org | https://registry.npmmirror.com |
| pip | pypi.org | https://pypi.tuna.tsinghua.edu.cn/simple |
| Docker | docker.io | mirror.ccs.tencentyun.com |
| Go | proxy.golang.org | https://goproxy.cn,direct |
| Rust/Cargo | crates.io | https://rsproxy.cn/crates.io-index |
| Gradle/Maven | repo.maven.apache.org | https://maven.aliyun.com/repository/public |
如果检测到慢源,输出建议并询问:
AskUserQuestion:
header: "镜像源"
question: "检测到 npm 使用官方源(registry.npmjs.org),国内访问较慢。是否切换到国内镜像?"
options:
- label: "切换到淘宝镜像 (推荐)"
description: "npmmirror.com,国内速度快,同步延迟 < 10 分钟"
- label: "保持不变"
description: "当前源可用,不需要切换"
- label: "使用其他镜像"
description: "指定自定义镜像地址"
用户确认后执行切换:
# npm
npm config set registry https://registry.npmmirror.com
# pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# Go
go env -w GOPROXY=https://goproxy.cn,direct
# Dockerfile 中的 apt 源(如果有)
# AI 读取 Dockerfile,将 archive.ubuntu.com 替换为 mirrors.aliyun.com
# 检测已安装的工具
docker --version 2>/dev/null && echo "docker:ok" || echo "docker:missing"
docker-compose --version 2>/dev/null && echo "docker-compose:ok" || echo "docker-compose:missing"
kubectl version --client 2>/dev/null && echo "kubectl:ok" || echo "kubectl:missing"
make --version 2>/dev/null && echo "make:ok" || echo "make:missing"
task --version 2>/dev/null && echo "task:ok" || echo "task:missing"
pm2 --version 2>/dev/null && echo "pm2:ok" || echo "pm2:missing"
node --version 2>/dev/null && echo "node:ok" || echo "node:missing"
# 操作系统
uname -s 2>/dev/null || echo "Windows"
基于收集到的信息,直接输出分析报告(不用 AskUserQuestion):
## 🔍 环境分析报告
**项目**: [名称] ([类型])
**操作系统**: [Linux/macOS/Windows]
### 已检测到的部署配置
- ✅ Dockerfile
- ✅ docker-compose.yml
- ❌ Makefile(未找到)
### 已安装的工具
- ✅ Docker 24.0.5
- ✅ make 4.3
- ❌ task(未安装)
- ❌ pm2(未安装)
AI 根据"项目配置 × 已安装工具"交叉分析,用 AskUserQuestion 展示推荐方案:
推荐逻辑(AI 自行判断,不是硬编码):
AskUserQuestion:
header: "部署方案"
question: "基于你的环境分析,推荐以下方案(已标注推荐原因):"
options:
- label: "Docker (推荐)"
description: "已有 Dockerfile + Docker 已安装,直接可用,环境隔离好"
- label: "Docker Compose"
description: "检测到 docker-compose.yml,适合多服务编排"
- label: "Make"
description: "已有 Makefile + make 已安装,运行 make deploy"
- label: "npm scripts"
description: "无需额外工具,直接用 package.json 中的 scripts"
AskUserQuestion:
header: "目标环境"
question: "部署到哪个环境?"
options:
- label: "本地开发 (推荐)"
description: "快速启动,用于开发调试"
- label: "测试环境"
description: "模拟生产配置,用于验证"
- label: "生产环境"
description: "需要完整配置和安全检查"
根据前面的分析和用户选择,将所有部署步骤写入 TodoWrite,逐条执行:
示例(Docker 本地部署 + 源优化 + 脚本生成):
TodoWrite({
todos: [
{ content: "切换 npm 源到淘宝镜像", activeForm: "正在切换 npm 镜像源", status: "pending" },
{ content: "构建 Docker 镜像", activeForm: "正在构建 Docker 镜像", status: "pending" },
{ content: "启动容器", activeForm: "正在启动容器", status: "pending" },
{ content: "验证部署:容器状态", activeForm: "正在检查容器状态", status: "pending" },
{ content: "验证部署:端口监听", activeForm: "正在检查端口", status: "pending" },
{ content: "验证部署:HTTP 连通", activeForm: "正在验证 HTTP 连通性", status: "pending" },
{ content: "生成 Taskfile.yml 一键脚本", activeForm: "正在生成一键脚本", status: "pending" },
{ content: "保存部署配置", activeForm: "正在保存部署配置", status: "pending" }
]
})
任务清单根据实际情况动态生成:
执行规则:
根据用户选择,AI 执行对应命令:
Docker 本地:
docker build -t <project-name> .
docker run -d -p <port>:<port> --name <project-name> <project-name>
Docker Compose:
docker-compose up -d --build
Make:
make deploy
npm scripts:
npm run build
npm run start &
执行部署后,AI 自动执行以下验证(按顺序,全部通过才算成功):
1. 检查容器/进程状态:
# Docker
docker ps --format "{{.Names}}\t{{.Status}}" | grep <project-name>
# Docker Compose
docker-compose ps
# PM2
pm2 list
# 进程检查
ps aux | grep <project-name>
2. 检查端口是否在监听:
# Linux/Mac
lsof -i :<port> 2>/dev/null || netstat -tlnp 2>/dev/null | grep <port>
# Windows
netstat -ano | findstr :<port>
3. HTTP 连通性验证(核心验证):
# 等待服务启动(最多重试 5 次,每次间隔 2 秒)
for i in 1 2 3 4 5; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:<port>/ 2>/dev/null)
if [ "$STATUS" -ge 200 ] && [ "$STATUS" -lt 400 ]; then
echo "HTTP $STATUS OK"
break
fi
sleep 2
done
# 获取响应内容摘要
curl -s http://localhost:<port>/ 2>/dev/null | head -20
4. 健康检查端点(如果存在):
curl -s http://localhost:<port>/health 2>/dev/null
curl -s http://localhost:<port>/api/health 2>/dev/null
curl -s http://localhost:<port>/healthz 2>/dev/null
5. 浏览器可访问性验证(Web 项目):
如果是 Web 项目,使用 Playwright 工具打开浏览器验证页面是否正常加载:
browser_navigate: http://localhost:<port>/
browser_snapshot: 检查页面是否正常渲染
browser_take_screenshot: 截图保存验证结果
browser_close
如果无法使用浏览器工具,输出可访问的 URL 供用户手动验证:
🌐 请在浏览器中访问: http://localhost:<port>/
6. 日志检查(任何验证失败时):
# Docker 日志
docker logs <project-name> --tail 50
# PM2 日志
pm2 logs <project-name> --lines 50
AI 根据验证结果输出状态报告:
验证成功:
## ✅ 部署验证报告
**服务状态**: 运行中 (Up 2 minutes)
**端口**: 3000 已监听
**HTTP 连通**: http://localhost:3000/ → 200 OK
**健康检查**: /health → 200 OK
### 验证清单
- ✅ 容器/进程正常运行
- ✅ 端口 3000 已监听
- ✅ HTTP 请求返回 200
- ✅ 页面可正常访问
### 访问地址
🌐 http://localhost:3000/
### 快捷命令
- 查看日志: docker logs -f <project-name>
- 停止服务: docker stop <project-name>
- 重启服务: docker restart <project-name>
验证失败:
## ❌ 部署验证失败
**问题**: 容器启动后立即退出
**状态**: Exited (1)
### 错误日志(最近 20 行)
<显示 docker logs 输出>
### 建议修复
1. 检查 Dockerfile 配置
2. 检查启动命令是否正确
3. 查看完整日志: docker logs <project-name>
验证失败时,询问用户是否要查看完整日志或尝试修复。
AskUserQuestion:
header: "一键脚本"
question: "部署完成!是否生成一键脚本方便后续开发调试?"
options:
- label: "生成 Taskfile.yml (推荐)"
description: "task 已安装 / 现代化工具,YAML 格式简洁,跨平台"
- label: "生成 Makefile"
description: "make 已安装 / 经典工具,已有 Makefile 时保持一致"
- label: "添加到 npm scripts"
description: "Node.js 项目,无需额外工具"
- label: "不需要"
description: "已有足够配置"
根据用户选择和项目实际情况,用 Write 工具生成脚本。
Taskfile.yml 示例(根据实际项目定制):
version: '3'
vars:
APP: '{{.APP | default "app"}}'
PORT: '{{.PORT | default "3000"}}'
tasks:
setup:
desc: 安装依赖
cmds:
- npm install
build:
desc: 构建项目
cmds:
- npm run build
test:
desc: 运行测试
cmds:
- npm test
dev:
desc: 本地开发(热重载)
cmds:
- npm run dev
deploy:local:
desc: 本地 Docker 部署
cmds:
- docker build -t {{.APP}} .
- docker run -d -p {{.PORT}}:{{.PORT}} --name {{.APP}} {{.APP}}
- echo "✅ 服务已启动 http://localhost:{{.PORT}}"
deploy:prod:
desc: 生产部署
cmds:
- docker build -t {{.APP}}:{{.VERSION}} .
- docker push {{.REGISTRY}}/{{.APP}}:{{.VERSION}}
logs:
desc: 查看日志
cmds:
- docker logs -f {{.APP}}
stop:
desc: 停止服务
cmds:
- docker stop {{.APP}} && docker rm {{.APP}}
Makefile 示例(根据实际项目定制):
APP ?= app
PORT ?= 3000
.PHONY: setup build test dev deploy-local deploy-prod logs stop
setup:
npm install
build:
npm run build
test:
npm test
dev:
npm run dev
deploy-local:
docker build -t $(APP) .
docker run -d -p $(PORT):$(PORT) --name $(APP) $(APP)
@echo "✅ 服务已启动 http://localhost:$(PORT)"
deploy-prod:
docker build -t $(APP):$(VERSION) .
docker push $(REGISTRY)/$(APP):$(VERSION)
logs:
docker logs -f $(APP)
stop:
docker stop $(APP) && docker rm $(APP)
将用户选择的部署方式保存到 .openmatrix/deploy-config.json:
{
"deployMethod": "docker",
"envType": "local",
"scriptTool": "taskfile",
"lastDetectedFiles": {
"Dockerfile": true,
"docker-compose.yml": false,
"Makefile": false,
"package.json": true
},
"lastDetectedTools": {
"docker": "24.0.5",
"make": "4.3",
"task": null
},
"timestamp": "2026-04-22T15:00:00Z"
}
下次运行时,对比 lastDetectedFiles 和当前实际文件状态,判断是否需要重新询问。
## ✅ 部署完成
**方案**: Docker 本地部署
**环境**: 本地开发
**脚本**: 已生成 Taskfile.yml
### 常用命令
- `task dev` — 本地开发
- `task deploy:local` — Docker 本地部署
- `task deploy:prod` — 生产部署
- `task logs` — 查看日志
- `task stop` — 停止服务
$ARGUMENTS
/om:deploy # 自动分析 → 推荐方案 → 执行 → 生成脚本
/om:deploy local # 直接指定本地环境
/om:deploy prod # 直接指定生产环境
## 核心原则
.openmatrix/deploy-config.json 存储上次部署选择:
lastDetectedFiles 和当前文件状态变更检测:
| 项目配置 | 系统工具 | 推荐方案 |
|---|---|---|
| 有 Dockerfile | docker 已安装 | Docker |
| 有 docker-compose | docker-compose 已安装 | Docker Compose |
| 有 k8s/ | kubectl 已安装 | Kubernetes |
| 有 Makefile | make 已安装 | Make |
| Node.js | pm2 已安装 | PM2 |
| Node.js | 无特殊工具 | npm scripts |
| 无任何配置 | docker 已安装 | 生成 Dockerfile |
| 无任何配置 | 无工具 | npm scripts / shell 脚本 |
| 条件 | 推荐 |
|---|---|
| task 已安装 | Taskfile.yml |
| make 已安装 / 已有 Makefile | Makefile |
| Node.js 项目 / 无工具 | npm scripts |
| Windows + 无工具 | package.json scripts |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (bigfish1913/openmatrix) — no native marketplace selected
npx claudepluginhub p/bigfish1913-openmatrix20 skills in this plugin
/om:approveUse when handling pending approvals including plan review, merge confirmation, deploy approval, and blocked task decisions during OpenMatrix execution. Triggers on APPROVAL intent: user wants to review and approve pending items, handle merge conflicts, or confirm deploy. DO NOT trigger on: starting tasks, debugging, or status checks. Intent signals: user mentions 'approve', 'review plan', 'confirm merge', 'approve deploy', or refers to pending approval actions./om:autoUse when the user wants fully automated task execution with zero manual approvals. Triggers on AUTOMATION intent: user explicitly requests hands-free execution, wants to skip all confirmations, or needs batch processing without interruptions. Expects plan.md + tasks-input.json to already exist (generated by /om:plan). DO NOT trigger on: interactive requests, debugging, or status checks. Intent signals: user says 'fully auto', 'hands-free', 'no interruptions', 'skip approvals', or describes large batch operations./om:brainstormUse when the user wants to explore requirements, design alternatives, or validate ideas before implementation. Triggers on CLARIFICATION/DESIGN intent: user needs to clarify unclear requirements, explore multiple approaches, or design architecture before coding. DO NOT trigger on: simple implementation requests (clear path), status checks, or pure information queries. Intent signals: user says 'how should I', mentions multiple options/uncertainties, describes complex system from scratch, or task scope is ambiguous./check自动检测项目可改进点并提供升级建议,用户确认后自动执行/om:debugUse when user encounters ANY technical problem and needs systematic diagnosis. Triggers on PROBLEM-EXPLORATION intent: user wants to understand WHY something failed, investigate root cause, or diagnose unexpected behavior. DO NOT trigger on: simple questions (how to do X), implementation requests (build/fix/add), or status checks. Intent signals: user seems confused about failure, asks '为什么', mentions error/issue without clear solution, wants to investigate before fixing./om:featureUse for small feature requests needing quick iteration. Triggers on MINOR-CHANGE intent: small/quick/simple changes, single component, few files, straightforward implementation. 2-5 task chunks, lightweight tracking, no task files. DO NOT trigger on: complex multi-module tasks or unclear requirements.