/spex:initfrom spex
Initializes or updates a project using the specify CLI with flags for refreshing templates, upgrading the CLI, or resetting status.
Ships in spex. 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.
You MUST complete ALL steps below. Do not stop after Step 1.
Run the command from <spex-init-command> in the <spex-context> system reminder. This is your first and only Bash call. Do not run anything else before it.
DECLARATION_EXISTED=true or DECLARATION_EXISTED=false line from the output (printed when the command runs without flags). Step 2 needs it.NEED_INSTALL: show output, STOP.ERROR or the script exits with a non-zero status other than 3 (3 means RESTART_REQUIRED): show the error, STOP. Do not continue to Step 2, Step 3 or the restart advice.
ERROR: ... has local edits and differs from .specify/templates/overrides/..., show the message verbatim: a core template was edited in place while an override for it also exists. Nothing was changed. The user merges the edits into the override (or reverts the core template) and runs init again.1 and ERROR: spex-worktrees requires the spec-kit git extension when spex-worktrees is enabled but the git extension cannot be enabled. Show the message with its two fixes: add the git extension (specify extension add git / specify extension enable git) and run /spex:init again, or re-run setup with an extension selection that leaves out spex-worktrees (the message shows the specify workflow run ... -i extensions=... command). Do not tell the user to disable spex-worktrees by hand.--refresh or --update and output contains RESTART_REQUIRED: SKIP Steps 2 and 3. Templates and extensions were refreshed. When the project has a declaration (.specify/spex.json), the refresh re-applied its extension selection exactly (extensions toggled by hand are reset, and the output names every change); without a declaration, the enabled/disabled state of the installed extensions is preserved. No permission rules are added, but the refresh rewrites the legacy Bash(*), Read(*), Edit(*) and Write(*) rules that earlier spex versions wrote to the bare tool names (Bash, Read, Edit, Write, same meaning) in .claude/settings.json and .claude/settings.local.json, and prints one Migrated: ... line per changed file. Go directly to Step 4 and report that the refresh completed, including any Preserved:, Enabled:, Disabled:, Migrated: or WARNING: lines and any Stealth mode: ..., Repaired stealth mode: ... or WARNING: stealth mode is NOT fully active lines (with the paths listed below it) from the output. Tell the user to restart Claude Code.READY or RESTART_REQUIRED: do not summarize yet, go to Step 2.You MUST ask all 3 questions below in a SINGLE AskUserQuestion call. Do NOT split, merge, reword, or reorder them. Pass them exactly as specified:
(multiSelect: true, header: "Quality"): "Which quality & review extensions do you want to enable?"
(multiSelect: true, header: "Workflow"): "Which workflow extensions do you want to enable?"
(multiSelect: false, header: "Permissions"): "How should spex commands handle permission prompts?"
Then apply the selections:
Dependency resolution: spex-deep-review, spex-teams and spex-collab require spex-gates. If the user selected any of them but NOT spex-gates, spex-gates is enabled automatically. Warn:
Note: spex-gates was auto-enabled because depends on it.
Extensions: The selection is exact: the selected extensions (plus spex-gates when required) are enabled, and every other optional extension is disabled. Do not run specify extension enable or specify extension disable yourself. Resolve, apply and persist the selection with the spex scripts, in this order. <scripts> is the directory that contains the spex-init.sh from <spex-init-command> (use its absolute path). <csv> is the comma-separated list of the selected extensions (empty when none was selected), and <permissions> is none, standard or yolo for the permission choice below:
set -e
RESOLVED=$(python3 "<scripts>/spex-setup-profile.py" resolve --root "$PWD" \
--extensions "spex,<csv>" --legacy-permissions <permissions> [--harness claude])
SELECTED=$(printf '%s' "$RESOLVED" | jq -r '.extensions | join(",")')
sh "<scripts>/spex-apply-extensions.sh" "$SELECTED"
rm -f .specify/.spex-detach-was-enabled
case ",$SELECTED," in
*,spex-worktrees,*)
jq -e '.extensions.git.enabled == true' .specify/extensions/.registry >/dev/null 2>&1 ||
specify extension enable git >/dev/null 2>&1 || specify extension add git >/dev/null 2>&1 || true
jq -e '.extensions.git.enabled == true' .specify/extensions/.registry >/dev/null 2>&1 || {
echo "ERROR: spex-worktrees requires the spec-kit git extension" >&2
echo "Fix it with one of: specify extension add git, then run /spex:init again;" >&2
echo "or run /spex:init again with a selection that leaves out spex-worktrees." >&2
exit 1
} ;;
esac
printf '%s' "$RESOLVED" | python3 "<scripts>/spex-setup-profile.py" persist --root "$PWD"
Run the block as one Bash call so set -e stops it before persist when a step fails.
--harness claude only when Step 1 printed DECLARATION_EXISTED=false. When it printed DECLARATION_EXISTED=true, leave the stored harness as it is.--extensions with spex, so choosing no optional extension yields only spex.--legacy-permissions maps None to safe, Standard to autonomous and YOLO to yolo in .specify/spex.json.ERROR: spex-worktrees requires the spec-kit git extension, offer the two fixes from Step 1: add the git extension and run /spex:init again, or choose again without spex-worktrees. Otherwise report the Enabled: / Disabled: lines in Step 4.Permissions: The specify CLI does not manage permissions. All Claude permission writes go through spex-permissions.sh in the same <scripts> directory. Do not edit .claude/settings.json yourself, and do not merge rules with your own jq calls. Run the block for the user's choice as one Bash call, copying the rule arguments verbatim (do not modify or rephrase the permission strings):
sh "<scripts>/spex-permissions.sh" apply \
Skill 'Bash(specify *)' 'Bash(*spex-init.sh*)' 'Bash(*spex-ship-statusline.sh*)'
sh "<scripts>/spex-permissions.sh" migrate
sh "<scripts>/spex-permissions.sh" apply --default-mode bypassPermissions \
Bash Read Edit Write WebFetch WebSearch Skill \
'Bash(specify *)' 'Bash(*spex-init.sh*)' 'Bash(*spex-ship-statusline.sh*)'
sh "<scripts>/spex-permissions.sh" migrate
Note: defaultMode: "bypassPermissions" skips all permission prompts. The broad allow rules serve as additional fallback. Use this for unattended ship pipelines or when you trust the agent fully. The bare tool names Bash, Read, Edit and Write allow the tool for every command and every path, including sibling worktrees outside the working directory. Never write Bash(*), Read(*), Edit(*) or Write(*) instead: current Claude Code releases flag these forms, and Read(*), Edit(*) and Write(*) only cover the working directories there.sh "<scripts>/spex-permissions.sh" migrate
apply appends the missing rules to the project's .claude/settings.json (created when missing) without re-sorting the existing list, and leaves every other setting alone. migrate rewrites the legacy Bash(*), Read(*), Edit(*) and Write(*) rules to the bare names in .claude/settings.json and .claude/settings.local.json. Both print their results on stderr: Permissions configured in .claude/settings.json (<n> rules added), Default mode set to bypassPermissions in .claude/settings.json when YOLO changed the default mode, one Migrated: ... line per repaired file, and WARNING: ... lines for files they left alone (including a project settings path that resolves to the user-level ~/.claude settings, which spex never changes). Keep these lines for Step 4.
Scan the available skills list from the system reminder for companion plugins:
Check for any of these upstream superpowers skills: test-driven-development, systematic-debugging, brainstorming, writing-plans. These are skills from obra/superpowers that complement spex but are NOT bundled with it.
spex-gates extension in Step 2: show a recommendation in the Step 4 report (see below). Do NOT block init or make it an error.Summarize: extensions enabled, permission level, and companion plugins detected. Relay every Preserved:, Migrated: and WARNING: line from the Step 1 and Step 2 output verbatim (for a full init as well as for --refresh and --update), so the user sees which permission rules were rewritten and which settings files were left alone. Tell the user to restart Claude Code if Step 1 said RESTART_REQUIRED, if a Permissions configured in ... (<n> rules added) line has n greater than 0, if a Default mode set to ... line appeared, or if any Migrated: line appeared.
Stealth mode (spex-detach): when the output of Step 1 or of the Step 2 block contains Stealth mode: ..., Repaired stealth mode: ... or WARNING: stealth mode is NOT fully active lines, show them to the user verbatim, including the indented path lines below a warning. Never claim stealth mode is active unless a Stealth mode: active line was printed. A stealth-mode warning never stops init: report it and continue.
If superpowers companion plugin was NOT detected (Step 3b), append this to the report:
Recommended companion: The Superpowers plugin by Jesse Vincent adds TDD discipline and systematic debugging skills that complement spex's spec-first workflow. spex absorbs superpowers' quality gates and anti-rationalization patterns, but does not bundle these standalone skills:
- test-driven-development: strict RED-GREEN-REFACTOR, no production code without failing test
- systematic-debugging: 4-phase root cause analysis with defense-in-depth
Install with:
/plugin install superpowers@claude-plugins-official(orclaude plugin install superpowers@claude-plugins-officialfrom the terminal)
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub rhuss/cc-spex --plugin spexOther plugins' skills for the same job