openspec-init
Initialize or repair OpenSpec in the current repo for the /la:pr flow. Ensures the openspec CLI is available (global install, npx fallback), scaffolds openspec/ with `openspec init --tools none` (corpus only, no /opsx:* commands), and verifies. Invoked by /la:pr when openspec/ is
Install
npx skills add https://github.com/MotleyAI/living-architecture/tree/main/plugin/la/skills/openspec-init
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install motleyai-living-architecture@llmmart
git clone https://github.com/MotleyAI/living-architecture.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole motleyai/living-architecture collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Preflight: run la-doctor --plugin <this skill's base directory> once per session before using any la-* or trmv-* command; if it fails, stop and show the user its output — unless the only failure is the private-store finding (the one naming /la:openspec-init), which Step 1b fixes. If la-doctor is not found, or reports the la tools older than the plugin, stop and give the user the install command at this plugin's version (in its .claude-plugin/plugin.json): uv tool install living-architecture==<version> --with-executables-from type-rename-move in a Python repo, npm install -g living-architecture@<version> type-rename-move@<version> in a TS/JS repo.
Bring the current repo to a valid OpenSpec state: the openspec CLI resolvable
and an openspec/ corpus (specs/ + changes/) present and healthy. Corpus
only — no /opsx:* slash commands or AGENTS wiring, because the /la:pr flow
replaces propose/apply.
Step 1 — Resolve the CLI (set OPENSPEC_CMD)
- If
command -v openspecsucceeds →OPENSPEC_CMD=openspec. - Else install globally:
npm i -g @fission-ai/openspec(no sudo where the npm global prefix is user-writable — nvm/fnm/~/.local-style node). Re-checkcommand -v openspec. - If the global install fails (non-writable prefix, no permission, or offline):
fall back to
OPENSPEC_CMD="npx -y @fission-ai/openspec@1.11.0"(bump the pin as needed). If even npx can't fetch, STOP and tell me — do not proceed.
Use $OPENSPEC_CMD for every openspec call below and hand it back to the caller.
Step 1b — Stealth mode: the private store
If la-config get stealth prints true and git ls-tree -r --name-only HEAD -- openspec/ prints nothing, never
write openspec/ into the repo; set up the private store instead and skip Steps 2–5:
- If
$OPENSPEC_CMD store --helpfails, STOP and tell me this OpenSpec CLI has no stores, so stealth mode needs a newer one. - Run
$OPENSPEC_CMD store setup $(la-config get openspec_store) --path <C>/living-architecture/openspec --init-git, where<C>isgit rev-parse --path-format=absolute --git-common-dir. - Verify:
la-doctorreports no private-store finding, and$OPENSPEC_CMD list --store $(la-config get openspec_store)succeeds. - Stage and commit nothing in the repo. Hand back
--store $(la-config get openspec_store)for every lateropenspeccall.
Step 2 — Check repo state
Run from the repo root (init writes openspec/ into the cwd). Classify:
- Absent — no
openspec/config.yaml→ Step 3. - Healthy —
openspec/config.yamlexists and$OPENSPEC_CMD listruns cleanly → nothing to do; report and return. (A healthy repo may have nospecs/orchanges/yet — see Step 3 — so their absence is NOT invalid.) - Invalid —
openspec/exists but has noconfig.yaml, orlist/doctorerrors → Step 4.
Step 3 — Initialize (absent)
$OPENSPEC_CMD init --tools none --no-animation
Add --force only if it complains about legacy files. This creates just
openspec/config.yaml (schema: spec-driven); --tools none keeps it
corpus-only (no /opsx:* commands or AGENTS wiring — /la:pr gets its authoring
format from openspec instructions). Note: changes/<id>/ is created later by
openspec new change, and specs/ by the first openspec archive — init alone
lays down only config.yaml.
Step 4 — Repair (invalid)
- Version / instruction staleness →
$OPENSPEC_CMD update. - Structurally broken (missing
specs/|changes/, unparseable corpus) → report the exactdoctor/listerror and ask how to proceed. Never guess-fix a corrupted corpus.
Step 5 — Verify and stage
- Confirm health:
$OPENSPEC_CMD listmust succeed (and$OPENSPEC_CMD validate --strictif any specs/changes already exist). - Stage with a SPECIFIC path —
git add openspec/plus any other newly created files — nevergit add -A. Do NOT commit; leave that to me. - Worktree caveat:
openspec/lives on the branch, so init on the mainline (then merge) if you want every future branch/worktree to inherit it — don't init per-worktree.
Return to the caller (e.g. /la:pr) with OpenSpec now valid.
Files (living-architecture)
-
SKILL.md 4.5 KB
--- name: openspec-init description: Initialize or repair OpenSpec in the current repo for the /la:pr flow. Ensures the openspec CLI is available (global install, npx fallback), scaffolds openspec/ with `openspec init --tools none` (corpus only, no /opsx:* commands), and verifies. Invoked by /la:pr when openspec/ is absent or invalid, or run directly. --- **Preflight:** run `la-doctor --plugin <this skill's base directory>` once per session before using any `la-*` or `trmv-*` command; if it fails, stop and show the user its output — unless the only failure is the private-store finding (the one naming `/la:openspec-init`), which Step 1b fixes. If `la-doctor` is not found, or reports the la tools older than the plugin, stop and give the user the install command at this plugin's `version` (in its `.claude-plugin/plugin.json`): `uv tool install living-architecture==<version> --with-executables-from type-rename-move` in a Python repo, `npm install -g living-architecture@<version> type-rename-move@<version>` in a TS/JS repo. Bring the current repo to a valid OpenSpec state: the `openspec` CLI resolvable and an `openspec/` corpus (`specs/` + `changes/`) present and healthy. Corpus only — no `/opsx:*` slash commands or AGENTS wiring, because the `/la:pr` flow replaces propose/apply. ## Step 1 — Resolve the CLI (set `OPENSPEC_CMD`) 1. If `command -v openspec` succeeds → `OPENSPEC_CMD=openspec`. 2. Else install globally: `npm i -g @fission-ai/openspec` (no sudo where the npm global prefix is user-writable — nvm/fnm/`~/.local`-style node). Re-check `command -v openspec`. 3. If the global install fails (non-writable prefix, no permission, or offline): fall back to `OPENSPEC_CMD="npx -y @fission-ai/openspec@1.11.0"` (bump the pin as needed). If even npx can't fetch, STOP and tell me — do not proceed. Use `$OPENSPEC_CMD` for every openspec call below and hand it back to the caller. ## Step 1b — Stealth mode: the private store If `la-config get stealth` prints `true` and `git ls-tree -r --name-only HEAD -- openspec/` prints nothing, never write `openspec/` into the repo; set up the private store instead and skip Steps 2–5: 1. If `$OPENSPEC_CMD store --help` fails, STOP and tell me this OpenSpec CLI has no stores, so stealth mode needs a newer one. 2. Run `$OPENSPEC_CMD store setup $(la-config get openspec_store) --path <C>/living-architecture/openspec --init-git`, where `<C>` is `git rev-parse --path-format=absolute --git-common-dir`. 3. Verify: `la-doctor` reports no private-store finding, and `$OPENSPEC_CMD list --store $(la-config get openspec_store)` succeeds. 4. Stage and commit nothing in the repo. Hand back `--store $(la-config get openspec_store)` for every later `openspec` call. ## Step 2 — Check repo state Run from the repo root (`init` writes `openspec/` into the cwd). Classify: - **Absent** — no `openspec/config.yaml` → Step 3. - **Healthy** — `openspec/config.yaml` exists and `$OPENSPEC_CMD list` runs cleanly → nothing to do; report and return. (A healthy repo may have no `specs/` or `changes/` yet — see Step 3 — so their absence is NOT invalid.) - **Invalid** — `openspec/` exists but has no `config.yaml`, or `list`/`doctor` errors → Step 4. ## Step 3 — Initialize (absent) ``` $OPENSPEC_CMD init --tools none --no-animation ``` Add `--force` only if it complains about legacy files. This creates just `openspec/config.yaml` (`schema: spec-driven`); `--tools none` keeps it corpus-only (no `/opsx:*` commands or AGENTS wiring — `/la:pr` gets its authoring format from `openspec instructions`). Note: `changes/<id>/` is created later by `openspec new change`, and `specs/` by the first `openspec archive` — init alone lays down only `config.yaml`. ## Step 4 — Repair (invalid) - Version / instruction staleness → `$OPENSPEC_CMD update`. - Structurally broken (missing `specs/`|`changes/`, unparseable corpus) → report the exact `doctor`/`list` error and ask how to proceed. Never guess-fix a corrupted corpus. ## Step 5 — Verify and stage - Confirm health: `$OPENSPEC_CMD list` must succeed (and `$OPENSPEC_CMD validate --strict` if any specs/changes already exist). - Stage with a SPECIFIC path — `git add openspec/` plus any other newly created files — never `git add -A`. Do NOT commit; leave that to me. - Worktree caveat: `openspec/` lives on the branch, so init on the mainline (then merge) if you want every future branch/worktree to inherit it — don't init per-worktree. Return to the caller (e.g. `/la:pr`) with OpenSpec now valid.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.