mcpField
U
uninstall

uninstall

github.com/davepoonAgent 工作流3.7k68 次安装2 天前更新
代码仓库

关于 uninstall

用于彻底移除 claude-ops 插件及其创建内容的 Claude Code 技能。它会检查文件与设置,并在删除各类内容前逐项征求确认。

主要功能

  1. 01查找插件数据与缓存
  2. 02按确认移除凭据和偏好设置
  3. 03清理 Shell 导出项及 MCP 注册
  4. 04更新 Claude Code 插件设置

适用场景

  1. 01不再使用时移除 claude-ops
  2. 02删除前检查插件遗留内容

MCP 相关

该技能会检查 ~/.claude.json 中的 Telegram 和 Slack MCP 注册项,并提供移除选项。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davepoon/buildwithclaude --skill uninstall

安装后在 Claude Code 中输入/uninstall确认已加载。

详细介绍

OPS > 卸载

你正在对 claude-ops 插件执行完全卸载。这会移除插件和 /ops:setup 创建的所有内容。每个删除步骤都必须通过 AskUserQuestion 征得用户确认——绝不能静默删除。


步骤 1 — 确认意图

使用 AskUserQuestion:

This will completely remove claude-ops and all its data:
  - Plugin installation and marketplace registration
  - Stored preferences and project registry
  - Cached plugin files
  - Keychain credentials (Telegram, Slack tokens)
  - Shell profile exports (CLAUDE_PLUGIN_ROOT)
  - MCP server registrations (Telegram, Slack)

  [Uninstall everything]  [Cancel]

如果用户取消,立即停止。


步骤 2 — 检测现存内容

扫描所有 claude-ops 相关内容,并列出当前存在的项目:

# Preferences
PREFS_DIR="${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}"
ls -la "$PREFS_DIR" 2>/dev/null

# Cache
CACHE_DIR="$HOME/.claude/plugins/cache/ops-marketplace"
ls -la "$CACHE_DIR" 2>/dev/null

# Keychain entries (macOS)
for key in telegram-api-id telegram-api-hash telegram-phone telegram-session slack-xoxc slack-xoxd; do
  security find-generic-password -s "$key" 2>/dev/null && echo "FOUND: $key"
done

# Shell profile exports
grep -l 'CLAUDE_PLUGIN_ROOT' ~/.zshrc ~/.bashrc ~/.zprofile ~/.bash_profile 2>/dev/null

# MCP registrations
grep -l 'telegram\|slack-mcp' ~/.claude.json 2>/dev/null

打印找到内容的摘要,然后逐类删除。


步骤 3 — 移除钥匙串凭据

针对找到的每个钥匙串条目,通过 AskUserQuestion 询问:

Remove keychain credential: <key-name>?
  [Yes]  [Skip]

若回答“是”:

security delete-generic-password -s "<key-name>" 2>/dev/null

步骤 4 — 移除偏好设置和缓存

通过 AskUserQuestion 询问:

Remove plugin data?
  - Preferences: <prefs-dir>
  - Cache: <cache-dir>

  [Yes, delete both]  [Skip]

若回答“是”:

rm -rf "$PREFS_DIR"
rm -rf "$CACHE_DIR"

步骤 5 — 清理 shell 配置文件

对于每个包含 CLAUDE_PLUGIN_ROOT 的 shell 配置文件:

通过 AskUserQuestion 询问:

Remove CLAUDE_PLUGIN_ROOT export from <file>?
  [Yes]  [Skip]

若回答“是”,读取文件并删除包含 CLAUDE_PLUGIN_ROOT 的行。使用 sed 或类似工具——不要重写整个文件。只删除特定的 export 行。

sed -i '' '/CLAUDE_PLUGIN_ROOT/d' "<file>"

步骤 6 — 移除 MCP 注册项

检查 ~/.claude.json 是否包含插件添加的 MCP 服务条目(telegram、slack-mcp)。对每个条目:

通过 AskUserQuestion 询问:

Remove MCP server registration: <server-name> from ~/.claude.json?
  [Yes]  [Skip]

若回答“是”,使用 jq 移除该条目:

jq 'del(.mcpServers["<server-name>"])' ~/.claude.json > /tmp/claude-json-tmp && mv /tmp/claude-json-tmp ~/.claude.json

步骤 7 — 从 Claude Code 设置中移除插件

/plugin uninstall 界面不一定会清理设置文件。直接从 Claude Code 启动时读取的 JSON 配置文件中移除所有 ops 引用。

7a — 从 installed_plugins.json 中移除
INSTALLED="$HOME/.claude/plugins/installed_plugins.json"
if [ -f "$INSTALLED" ] && grep -q 'ops.*marketplace' "$INSTALLED"; then
  python3 -c "
import json, sys
with open('$INSTALLED') as f: data = json.load(f)
keys_to_remove = [k for k in data.get('plugins', {}) if 'ops-marketplace' in k or 'ops@ops' in k]
for k in keys_to_remove: del data['plugins'][k]
with open('$INSTALLED', 'w') as f: json.dump(data, f, indent=2)
print(f'Removed {len(keys_to_remove)} entries from installed_plugins.json')
"
else
  echo "No ops entries in installed_plugins.json"
fi
7b — 从 known_marketplaces.json 中移除
KNOWN="$HOME/.claude/plugins/known_marketplaces.json"
if [ -f "$KNOWN" ] && grep -q 'ops-marketplace' "$KNOWN"; then
  python3 -c "
import json
with open('$KNOWN') as f: data = json.load(f)
keys_to_remove = [k for k in data if 'ops-marketplace' in k or 'ops' in k.lower()]
for k in keys_to_remove: del data[k]
with open('$KNOWN', 'w') as f: json.dump(data, f, indent=2)
print(f'Removed {len(keys_to_remove)} marketplace entries from known_marketplaces.json')
"
else
  echo "No ops marketplace in known_marketplaces.json"
fi
7c — 从 settings.json 和 settings.local.json 中移除

~/.claude/settings.json 和 ~/.claude/settings.local.json 都可能包含 enabledPlugins 条目,以及引用 ops-marketplace 路径的过时 permissions.allow 条目。

for SETTINGS_FILE in "$HOME/.claude/settings.json" "$HOME/.claude/settings.local.json"; do
  [ -f "$SETTINGS_FILE" ] || continue
  if grep -q 'ops' "$SETTINGS_FILE"; then
    python3 -c "
import json, re
with open('$SETTINGS_FILE') as f: data = json.load(f)
# Remove ops from enabledPlugins
ep = data.get('enabledPlugins', {})
ops_keys = [k for k in ep if 'ops' in k.lower()]
for k in ops_keys: del ep[k]
# Remove ops-marketplace permission entries
perms = data.get('permissions', {})
if 'allow' in perms:
  before = len(perms['allow'])
  perms['allow'] = [p for p in perms['allow'] if 'ops-marketplace' not in p and 'claude-ops' not in p]
  removed = before - len(perms['allow'])
else:
  removed = 0
# Remove ops from extraKnownMarketplaces
ekm = data.get('extraKnownMarketplaces', {})
ekm_keys = [k for k in ekm if 'ops' in k.lower()]
for k in ekm_keys: del ekm[k]
with open('$SETTINGS_FILE', 'w') as f: json.dump(data, f, indent=2)
print(f'Cleaned $SETTINGS_FILE: {len(ops_keys)} plugin entries, {removed} permissions, {len(ekm_keys)} extra marketplaces')
"
  else
    echo "No ops references in $SETTINGS_FILE"
  fi
done
7d — 移除市场和缓存目录
rm -rf "$HOME/.claude/plugins/marketplaces/ops-marketplace" 2>/dev/null
rm -rf "$HOME/.claude/plugins/cache/ops-marketplace" 2>/dev/null
rm -rf "$HOME/.claude/plugins/data/ops-inline" 2>/dev/null
echo "Removed marketplace, cache, and data directories"

步骤 8 — 最终确认

打印:

claude-ops has been completely removed.

  Keychain:    <N> credentials deleted
  Preferences: deleted
  Cache:       deleted
  Shell:       <N> exports removed
  MCP:         <N> servers removed
  Settings:    cleaned (installed_plugins, known_marketplaces, settings)
  Directories: removed (marketplace, cache, data)

Run `/reload-plugins` then `/plugin` in Claude Code to verify ops no longer appears.

To reinstall later:
  /reload-plugins
  /plugin marketplace add Lifecycle-Innovations-Limited/claude-ops
  /plugin install ops@lifecycle-innovations-limited-claude-ops
  /reload-plugins
  /ops:setup

评论

支持 Markdown