Skip to content

Destynova2/cli-code-skills / cli-forge-chef

cli-forge-chef

Verified

Generate a multi-agent orchestrator for any project using the Brigade de Cuisine pattern: Chef (plans, decides), Sous-Chef (validates, merges), Commis (execute). Clients order via a Menu (PERT), the kitchen delivers Plats (merged features). Creates tmuxinator config, prompts, shared-state memory, quality gates, and permissions. Uses Claude Code Agent Teams (TeamCreate + SendMessage) with visible tmux panes. Use when the user wants to parallelize work across multiple Claude Code agents, orchestrate a multi-agent sprint, or says 'boss', 'multi-agent', 'orchestrate', 'parallelize agents', 'team of claudes', 'sprint multi-agent', 'brigade', 'chef'. Also triggers on 'swarm', 'agent team', 'parallel workers', 'PERT multi-agent'.

references/brigade-setup-worktrees.sh

View on GitHub
#!/usr/bin/env bash
# brigade-setup-worktrees.sh — idempotent worktree + permissions setup
#
# Generated by cli-forge-chef skill. Template — the skill writes this to
# {project}/scripts/brigade-setup-worktrees.sh at Phase 2 and the tmuxinator
# `on_project_start` hook calls it.
#
# Usage:
#   brigade-setup-worktrees.sh <project_root> <session_name>
#
# What it does:
#   1. For each role (gate, maitre, apply, vote-scope, vote-secu, vote-qualite,
#      commis-<name>) — idempotently create the worktree on its own branch.
#   2. Copy the matching .claude/settings.local.json from
#      {project}/.claude/permissions-brigade/<role>/ into the worktree.
#   3. Recover from orphan state (dir exists but git doesn't know).
#
# Why not inline in the tmuxinator YAML (G35):
#   The previous pattern `git worktree add ... 2>&1 | head -1` under `set -o pipefail`
#   triggered SIGPIPE on git AFTER head -1 closed its stdin. Git received SIGPIPE,
#   aborted, and the worktree was not created. Orphan dirs accumulated across reruns.
#   Here we redirect to /dev/null and report with a plain echo — no pipe to close early.
#
# Why one branch per commis (G36):
#   `git worktree add <path> <branch>` fails if <branch> is already checked out in
#   another worktree. Sharing a branch across N commis means N-1 failures (silent
#   under `|| true`). Each commis gets a unique branch; the Sous-Chef Merge consolidates
#   them onto the integration branch at merge time.

set -eu  # NOT pipefail — see G35

ROOT="${1:?Usage: $0 <project_root> <session>}"
SESSION="${2:?Usage: $0 <project_root> <session>}"

cd "${ROOT}"

echo "=== Brigade worktrees setup (${SESSION}) ==="

# add_worktree <path> <branch>
#   - If path exists as a registered worktree → skip
#   - If path exists as orphan dir → prune + remove
#   - If branch exists → attach; else create branch
add_worktree() {
  local wt_path="$1"
  local branch="$2"

  if git worktree list --porcelain 2>/dev/null | grep -q "^worktree ${wt_path}$"; then
    echo "  = ${wt_path} (already registered)"
    return 0
  fi

  # Orphan: dir exists but not in git's worktree list
  if [[ -d "${wt_path}" ]]; then
    echo "  ! orphan dir ${wt_path} — removing"
    rm -rf "${wt_path}"
    git worktree prune >/dev/null 2>&1 || true
  fi

  if git show-ref --verify --quiet "refs/heads/${branch}"; then
    git worktree add "${wt_path}" "${branch}" >/dev/null 2>&1 \
      && echo "  + ${wt_path} → ${branch}" \
      || echo "  ! FAILED ${wt_path} → ${branch}" >&2
  else
    git worktree add "${wt_path}" -b "${branch}" >/dev/null 2>&1 \
      && echo "  + ${wt_path} → ${branch} (new branch)" \
      || echo "  ! FAILED ${wt_path} -b ${branch}" >&2
  fi
}

# copy_perms <role> <wt_path>
#   Copy the per-role settings.local.json into the worktree, non-destructively.
copy_perms() {
  local role="$1"
  local wt_path="$2"
  local src="${ROOT}/.claude/permissions-brigade/${role}/settings.local.json"
  local dst="${wt_path}/.claude/settings.local.json"

  if [[ ! -f "${src}" ]]; then
    echo "  ! MISSING permissions file: ${src}" >&2
    return 1
  fi

  mkdir -p "${wt_path}/.claude"
  if [[ ! -f "${dst}" ]]; then
    cp "${src}" "${dst}"
    echo "  + perms copied to ${dst}"
  else
    echo "  = perms already at ${dst}"
  fi
}

# --- Standalone role worktrees ---
for role in gate maitre apply vote-scope vote-secu vote-qualite; do
  add_worktree "${ROOT}-wt-${role}" "wt/${role}"
  copy_perms "${role}" "${ROOT}-wt-${role}" || true
done

# --- Apply pane is optional (only if infra present) ---
# Skip silently if the permissions file is absent — the generator omits it for
# projects without infra tooling.
if [[ ! -f "${ROOT}/.claude/permissions-brigade/apply/settings.local.json" ]]; then
  echo "  ~ apply pane skipped (no infra detected)"
fi

# --- Commis worktrees ---
# The list of commis is injected by the generator via COMMIS_LIST env var
# (space-separated role names: "bootstrap scaleway k8s-day1 docs em").
# Each commis gets its own branch: {base_branch}-{commis_name}
BASE_BRANCH="${BASE_BRANCH:-chore/phase-a-${SESSION}}"
COMMIS_LIST="${COMMIS_LIST:-}"

if [[ -z "${COMMIS_LIST}" ]]; then
  echo "  ! COMMIS_LIST env var is empty — no commis worktrees to set up" >&2
else
  for commis in ${COMMIS_LIST}; do
    add_worktree "${ROOT}-wt-commis-${commis}" "${BASE_BRANCH}-${commis}"
    copy_perms "commis-${commis}" "${ROOT}-wt-commis-${commis}" || true
  done

  # Integration branch (Sous-Chef Merge consolidates the per-commis branches onto this one)
  if ! git show-ref --verify --quiet "refs/heads/${BASE_BRANCH}"; then
    git branch "${BASE_BRANCH}" >/dev/null 2>&1 \
      && echo "  + integration branch ${BASE_BRANCH}" \
      || echo "  ! FAILED to create integration branch ${BASE_BRANCH}" >&2
  fi
fi

echo "=== Done ==="
git worktree list | sed 's/^/  /'
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 319kUpdated Claude CodeCodexVerifiedInstall