Skip to content

Instantly share code, notes, and snippets.

@tomioe
Last active February 4, 2026 22:54
Show Gist options
  • Select an option

  • Save tomioe/5038760f7f40d0c7eb86b2cc4a538b7f to your computer and use it in GitHub Desktop.

Select an option

Save tomioe/5038760f7f40d0c7eb86b2cc4a538b7f to your computer and use it in GitHub Desktop.
Bash script for setting up obra/superpowers in gemini-cli
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}
msg() {
echo >&2 -e "${1-}"
}
die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "${RED}${msg}${NOFORMAT}"
exit "$code"
}
setup_colors
pushd . &>/dev/null
md_to_toml() {
if [[ ! -f "$1" ]]; then
echo "file no existy"
return
fi
md_file="$1"
descr=$(grep -oP '(?<=description: )[^.]+' ${md_file} | tr -d '"')
prompt=$(tail -n1 ${md_file})
toml_output="$(basename "$1" .md).toml"
echo "description = \"${descr}\"" >> ${toml_output}
echo "prompt = \"${prompt}\"" >> ${toml_output}
}
rm -rf ./skills
rm -rf ./commands
SUPERPOWERS_PATH="${1:-/home/user/github/superpowers}"
msg "Using 'superpowers' path at: ${SUPERPOWERS_PATH}"
if [[ ! -d "${SUPERPOWERS_PATH}" ]]; then
die "Superpowers Directory not found!\nPlease pass it as argument 1 or clone into 'cd ~/github && git clone https://github.com/obra/superpowers/'"
fi
for superpowers_subdir in "skills" "commands"; do
if [[ ! -d "${SUPERPOWERS_PATH}/${superpowers_subdir}" ]]; then
_die "Sub directory '${superpowers_subdir}' not found, exiting..."
fi
done
mkdir -p commands/superpowers
mkdir skills && cd $_
for skills in ${SUPERPOWERS_PATH}/skills/*; do
target="$(basename "${skills}")"
cp -r ${skills} ${target}
cd ${target}
replace=$(<SKILL.md head -n2 | tail -n1)
renamed="superpowers:$(echo "${replace}" |cut -d" " -f2)"
new="name: ${renamed}"
sed -i "s|${replace}|${new}|gm" SKILL.md
cd ..
done
rm -rf ./writing-skills/ # not supported in gemini for now!
declare -A SKILL_REPLACEMENTS
SKILL_REPLACEMENTS["CLAUDE.md"]="GEMINI.md"
SKILL_REPLACEMENTS[".claude"]=".gemini"
SKILL_REPLACEMENTS["Claude Code"]="Gemini"
SKILL_REPLACEMENTS["Claude"]="Gemini"
set +o errexit
for replacement in "${!SKILL_REPLACEMENTS[@]}"; do
grep -zlr "${replacement}" | xargs -I{} sed -i "s|${replacement}|${SKILL_REPLACEMENTS[${replacement}]}|gm" {}
done
set -o errexit
cd ..
cd commands/superpowers
for command in ${SUPERPOWERS_PATH}/commands/*; do
md_to_toml "${command}"
done
popd &>/dev/null
cat <<EOF > gemini-extension.json
{
"name": "gemini-superpowers",
"version": "1.0.0"
}
EOF
msg "\"Setup\" complete."
read -r -p "Install? [Y/n] " response
response=${response:-Y}
if [[ "$response" =~ ^[Yy] ]]; then
gemini extensions link .
else
echo "Installation aborted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment