# R-release-setup

> Set up commit standards and release automation — Commitizen, commitlint, semantic-release, Release Please, Lefthook/Husky. Triggers: "release setup" | "setup releases" | "commit standards" | "setup release automation".

- Skill: `roxabi/r-release-setup` (Agent Skill, multi-file: 6 files)
- Install (CLI): `npx skillmds@latest add roxabi/r-release-setup`
- Raw SKILL.md: https://api.skillmd.com/api/skills/roxabi/r-release-setup/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Roxabi (https://skillmd.com/u/roxabi)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/roxabi/r-release-setup

---


# Release Setup

Let:
  F    := `--force` flag present in `$ARGUMENTS`
  σ    := `.dev/stack.yml`
  D✅(label) := Display: `{label} ✅ Configured`
  D⏭(label)  := Display: `{label} ⏭ Already configured`
  D⚠(label)  := Display: `{label} ⚠️ Install failed — check network/lockfile`

Configure commit standards and release automation: Commitizen + commitlint, hook runner (Lefthook or Husky), and semantic-release or Release Please.

Can run standalone (`/R-release-setup`) or be called by `/init` after `/R-ci-setup`.

## Phase 0 — Pre-check (idempotency)

Check prerequisites and per-component state before any installation.

1. Verify σ exists:
   ```bash
   test -f .dev/stack.yml && echo "found" || echo "missing"
   ```
   found → Read σ; bind `runtime`, `package_manager`, `hooks.tool` from it before any phase — the cookbooks resolve `{package_manager}` from these.
   missing → warn: "stack.yml not found — release-setup reads runtime and hook runner from it."
   → present choice **Run `/R-env-setup` first** | **Proceed manually**
   Proceed manually → continue with defaults (runtime: node, package_manager: npm, hooks.tool: none).

2. Check per-component config file existence in parallel:
   ```bash
   test -f .lefthook.yml && echo "has_lefthook" || echo "no_lefthook"
   test -d .husky && echo "has_husky" || echo "no_husky"
   test -f .commitlintrc.cjs && echo "has_commits" || echo "no_commits"
   test -f release.config.cjs && echo "has_sr" || echo "no_sr"
   test -f release-please-config.json && echo "has_rp" || echo "no_rp"
   test -f .github/workflows/release-please.yml && echo "has_rp_wf" || echo "no_rp_wf"
   test -x tools/check_file_length.sh && test -x tools/check_folder_size.sh && test -f tools/check_lib.sh && echo "has_qg_scripts" || echo "no_qg"
   ```

3. Set booleans from results:
   - `has_hook_runner` := `has_lefthook` ∨ `has_husky`
   - `has_commits` := `.commitlintrc.cjs` ∃
   - `has_releases` := `release.config.cjs` ∃ ∨ (`release-please-config.json` ∃ ∧ `.github/workflows/release-please.yml` ∃). Release Please config without the workflow is **not** complete — Phase 4 will add the missing workflow.
   - `has_lefthook` := `.lefthook.yml` ∃
   - `has_qg_scripts` := `"has_qg_scripts"` ∈ output

4. F overrides all guards → treat all booleans as false (re-run all components).

## Phase 1 — Stack Detection

Read configuration and detect environment.

1. Read σ fields: `runtime`, `package_manager`, `hooks.tool`, `commands.lint`, `commands.typecheck`, `quality_gates`.
   Defaults if σ missing: runtime=`node`, package_manager=`npm`, hooks.tool=`none`, commands.lint=`npm run lint`, commands.typecheck=`npm run typecheck`.
   Set `has_qg_scripts_section` := `quality_gates` key ∃ ∈ σ. Default when σ absent: `has_qg_scripts_section = false`.

2. Detect existing hook runner via file checks:
   ```bash
   test -f .lefthook.yml && echo "lefthook" || (test -d .husky && echo "husky" || echo "none")
   ```

3. Detect branches:
   ```bash
   git branch -r | grep -E 'staging|develop|main|master'
   ```
   Store as `branch_list`. Default to `['main']` if only one or none detected.

## Dispatch

Phase 2 — Hook Runner → Read `${CLAUDE_SKILL_DIR}/cookbooks/hook-runner.md`, execute.
Phase 3 — Commit Standards → Read `${CLAUDE_SKILL_DIR}/cookbooks/commit-standards.md`, execute.
Phase 4 — Release Automation → Read `${CLAUDE_SKILL_DIR}/cookbooks/release-automation.md`, execute.
Phase 4.5 — Quality gates → Read `${CLAUDE_SKILL_DIR}/cookbooks/quality-gates.md`, execute.
Phase 5 — Summary (below).

## Phase 5 — Summary (no auto-commit)

Display results and generated files. Do NOT run `git add` or `git commit`.

1. Display summary table:

   ```
   Release Setup Complete
   ======================

     Hook runner         ✅ Configured / ⏭ Already configured / ⏭ Skipped
     Commit standards    ✅ Configured / ⏭ Already configured / ⏭ Python not supported / ⏭ Skipped
     Release automation  ✅ Configured / ⏭ Already configured / ⏭ Skipped
     Quality gates       ✅ Configured / ⏭ Already configured / ⏭ Not applicable / ⏭ Skipped
   ```

2. List generated files (only those actually written):

   ```
   Generated files:
     .lefthook.yml
     .pre-commit-config.yaml       (Python only)
     .husky/pre-commit             (Husky only)
     .husky/commit-msg             (Husky + Commitizen)
     .commitlintrc.cjs             (Commitizen chosen)
     release.config.cjs            (semantic-release chosen)
     release-please-config.json    (Release Please chosen)
     .release-please-manifest.json (Release Please chosen)
     .github/workflows/release-please.yml  (Release Please chosen)
     tools/check_file_length.sh          (python + quality_gates only)
     tools/check_folder_size.sh          (python + quality_gates only)
     tools/check_lib.sh                  (python + quality_gates only — sourced by both check scripts)
     tools/file_exemptions.txt           (python + quality_gates only)
     tools/folder_exemptions.txt         (python + quality_gates only)
     tools/qg.conf                       (python + quality_gates only — regenerated from stack.yml)
     .importlinter                       (python + import_layers only)
   ```

3. Display suggested commit command:
   ```
   Suggested commit:
     git add <generated-files>
     git commit -m "chore: add release setup"
   ```

## Safety Rules

1. **Never push to remote** without user confirmation
2. **Always present choices and wait for user reply** before installing packages or writing config files
3. **Idempotent** — skip already-configured components unless F
4. **No auto-commit** — sub-skill pattern: display files, let user review and commit

$ARGUMENTS

