superpowers 是一套很不错的harness,但它对很多日常 cc 会话来说有点重。
复杂任务里,它的 TDD、debugging、review、planning 流程很有用。
但简单改个 bug、查段代码、跑个测试时,头脑风暴 触发太频繁,让人不胜其烦。
最近 Claude Code 加了两个能力:
v2.1.128:--plugin-dir支持本地.zippluginv2.1.129:--plugin-url支持远程.zipplugin
也就是说,plugin 可以只在单次会话里加载了。
于是我做了一个 claude-sp,用法基本替代原来的 claude,但只在这次会话里加载 superpowers。
mkdir -p ~/.local/bin
把脚本保存为:
~/.local/bin/claude-sp
脚本内容:
#!/usr/bin/env bash
set -euo pipefail
repo="obra/superpowers"
branch="main"
cache_dir="${HOME}/.cache/claude-sp"
plugin_dir="${cache_dir}/superpowers"
sha_file="${plugin_dir}/.claude-sp-source-sha"
plugin_json="${plugin_dir}/.claude-plugin/plugin.json"
fetch_remote_sha() {
curl -fsSL \
-H 'Accept: application/vnd.github+json' \
"https://api.github.com/repos/${repo}/commits/${branch}" |
node -e "let s='';process.stdin.on('data',d=>s+=d);process.stdin.on('end',()=>{const j=JSON.parse(s); console.log(j.sha);})"
}
verify_plugin_json() {
[[ -f "$1" ]] || return 1
node -e "JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))" "$1"
}
install_latest() {
local sha tmp tarball extract root
sha="$(fetch_remote_sha)"
tmp="$(mktemp -d)"
tarball="${tmp}/superpowers.tar.gz"
extract="${tmp}/extract"
mkdir -p "${extract}" "${cache_dir}"
echo "[claude-sp] updating superpowers: ${sha}" >&2
curl -fL --retry 2 --retry-delay 1 \
-o "${tarball}" \
"https://github.com/${repo}/archive/${sha}.tar.gz"
tar -xzf "${tarball}" -C "${extract}"
root="$(find "${extract}" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
verify_plugin_json "${root}/.claude-plugin/plugin.json"
rm -rf "${plugin_dir}.previous"
[[ -e "${plugin_dir}" ]] && mv "${plugin_dir}" "${plugin_dir}.previous"
mv "${root}" "${plugin_dir}"
echo "${sha}" > "${sha_file}"
rm -rf "${plugin_dir}.previous" "${tmp}"
}
if ! verify_plugin_json "${plugin_json}" 2>/dev/null; then
install_latest
fi
exec claude --plugin-dir "${plugin_dir}" "$@"
然后注册到 ~/.zshrc:
chmod +x ~/.local/bin/claude-sp
grep -q 'export PATH="$HOME/.local/bin:$PATH"' ~/.zshrc || \
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
之后直接用:
claude-sp
claude-sp -p "帮我 review 当前 diff"
claude-sp --continue
这样 superpowers 不再是常驻负担,而是需要时才召唤出来。
复杂任务有流程,简单任务保持清爽。
2 个帖子 - 2 位参与者