---
name: bigstack-ship
version: 0.1.0
description: |
  Automated shipping pipeline. Runs tests, performs code review,
  creates a version bump, generates changelog entry, and opens a PR.
allowed-tools:
  - Bash
  - Read
  - Glob
  - Grep
  - Edit
  - Write
  - AskUserQuestion
---
<!-- Auto-generated from SKILL.md.tmpl by bigstack. DO NOT EDIT. -->
<!-- Regenerate: npm run gen:skill-docs -->

<!-- bigstack v0.1.0 | skill: bigstack-ship -->

> **bigstack v0.1.0** — skills for Bigscreen development.

Before starting, run this setup block silently:

```bash
# Session context
BIGSTACK_VERSION="0.1.0"
BIGSTACK_DIR="C:/Users/GGPC/Documents/Github/bigstack"
REPO_NAME=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")
BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
echo "bigstack v$BIGSTACK_VERSION | repo: $REPO_NAME | branch: $BRANCH"
```

**Guidelines:**
- When asking the user a question, use AskUserQuestion (not inline text questions)
- When uncertain about a change, state your confidence level before proceeding
- Prefer modifying existing code over creating new files
- This is an existing codebase — understand before changing

# /bigstack-ship — Automated Shipping Pipeline

Ship the current changes: test, review, version bump, changelog, and PR.

## Base Branch Detection

```bash
# Detect the base branch for PR targeting
BASE_BRANCH=$(gh pr view --json baseRefName -q .baseRefName 2>/dev/null || echo "")
if [ -z "$BASE_BRANCH" ]; then
  if git show-ref --verify --quiet refs/heads/main 2>/dev/null; then
    BASE_BRANCH="main"
  elif git show-ref --verify --quiet refs/heads/master 2>/dev/null; then
    BASE_BRANCH="master"
  else
    BASE_BRANCH=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}' || echo "main")
  fi
fi
echo "Base branch: $BASE_BRANCH"
```

## Test Framework Detection

Detect the existing test setup silently:

```bash
TEST_CMD=""
TEST_FRAMEWORK=""

# Node.js / JavaScript / TypeScript
if [ -f "vitest.config.ts" ] || [ -f "vitest.config.js" ]; then
  TEST_FRAMEWORK="vitest"
  TEST_CMD="npx vitest run"
elif [ -f "jest.config.ts" ] || [ -f "jest.config.js" ] || [ -f "jest.config.mjs" ]; then
  TEST_FRAMEWORK="jest"
  TEST_CMD="npx jest"
elif grep -q '"test"' package.json 2>/dev/null; then
  TEST_FRAMEWORK="npm-script"
  TEST_CMD="npm test"
fi

# Python
if [ -f "pytest.ini" ] || [ -f "pyproject.toml" ] && grep -q "pytest" pyproject.toml 2>/dev/null; then
  TEST_FRAMEWORK="pytest"
  TEST_CMD="pytest"
elif [ -f "setup.cfg" ] && grep -q "tool:pytest" setup.cfg 2>/dev/null; then
  TEST_FRAMEWORK="pytest"
  TEST_CMD="pytest"
fi

# Go
if [ -f "go.mod" ]; then
  TEST_FRAMEWORK="go-test"
  TEST_CMD="go test ./..."
fi

# Rust
if [ -f "Cargo.toml" ]; then
  TEST_FRAMEWORK="cargo-test"
  TEST_CMD="cargo test"
fi

# .NET
if ls *.csproj &>/dev/null || ls *.sln &>/dev/null; then
  TEST_FRAMEWORK="dotnet-test"
  TEST_CMD="dotnet test"
fi

if [ -n "$TEST_FRAMEWORK" ]; then
  echo "Detected test framework: $TEST_FRAMEWORK"
  echo "Test command: $TEST_CMD"
else
  echo "WARNING: No test framework detected. Ask the user how to run tests."
fi
```

## Workflow

### Step 1: Pre-flight Checks

```bash
# Ensure clean working tree (all changes committed)
if [ -n "$(git status --porcelain)" ]; then
  echo "ERROR: Uncommitted changes. Commit or stash before shipping."
  exit 1
fi

# Ensure we're not on the base branch
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" = "$BASE_BRANCH" ]; then
  echo "ERROR: Cannot ship from $BASE_BRANCH. Create a feature branch first."
  exit 1
fi
```

### Step 2: Run Tests

If a test framework was detected, run the full test suite:

```bash
if [ -n "$TEST_CMD" ]; then
  echo "Running: $TEST_CMD"
  $TEST_CMD
fi
```

If tests fail, stop and fix. Do not proceed with failing tests.

### Step 3: Code Review

Perform the `/bigstack-review` workflow. If critical issues are found, stop and fix them before proceeding.

### Step 4: Review Dashboard

## Review Readiness Dashboard

Before shipping, assess readiness:

```bash
echo "=== Review Readiness ==="

# Uncommitted changes
DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
echo "Uncommitted changes: $DIRTY"

# Commits ahead of base
AHEAD=$(git rev-list --count $BASE_BRANCH..HEAD 2>/dev/null || echo "?")
echo "Commits ahead of $BASE_BRANCH: $AHEAD"

# Test status (if available)
if [ -n "$TEST_CMD" ]; then
  echo "Test command: $TEST_CMD"
else
  echo "Test command: not detected"
fi

# PR status
PR_STATE=$(gh pr view --json state -q .state 2>/dev/null || echo "none")
echo "PR state: $PR_STATE"

echo "========================"
```

**Readiness gates:**
- All changes committed (DIRTY = 0)
- Tests pass
- At least 1 commit ahead of base branch

If any readiness gate fails, stop and address it.

### Step 5: Create PR

```bash
# Check if PR already exists
EXISTING_PR=$(gh pr view --json number -q .number 2>/dev/null || echo "")
if [ -n "$EXISTING_PR" ]; then
  echo "PR #$EXISTING_PR already exists. Updating..."
  gh pr edit "$EXISTING_PR" --title "$(git log --format=%s $BASE_BRANCH..HEAD | tail -1)"
else
  echo "Creating new PR..."
fi
```

If creating a new PR:
1. Generate a PR title from the commit history
2. Generate a PR body summarizing changes
3. Use `gh pr create --base $BASE_BRANCH`

### Step 6: Report

Tell the user:
- PR URL
- Test results summary
- Review summary (critical/informational counts)
- Any remaining action items

## Confidence Calibration

Before completing a major action, state your confidence:

| Level | Meaning | Action |
|-------|---------|--------|
| **High** | Well-understood change, clear test coverage, matches existing patterns | Proceed |
| **Medium** | Reasonable approach but some uncertainty — unfamiliar area, partial test coverage | Proceed but flag risks |
| **Low** | Significant unknowns, could break existing behavior, no test coverage | Stop and ask the user |

Format: **Confidence: [High/Medium/Low]** — [one-line rationale]
