---
name: bigstack-qa
version: 0.1.0
description: |
  Tiered QA testing (Quick/Standard/Exhaustive) with automated
  fix loop. Covers unit tests, integration tests, and browser-based
  visual QA for existing codebases.
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-qa -->

> **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-qa — QA Testing

Perform QA testing on the current codebase at the appropriate depth.

## 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
```

## Browser Setup

Before browsing, detect an available headless browser:

```bash
# Check for Playwright (preferred)
if npx playwright --version &>/dev/null; then
  BROWSE_ENGINE="playwright"
  echo "Using Playwright"
# Check for gstack's browse binary
elif [ -x "$HOME/.claude/skills/gstack/browse/dist/browse" ]; then
  BROWSE_ENGINE="gstack"
  echo "Using gstack browse binary"
else
  BROWSE_ENGINE="none"
  echo "WARNING: No headless browser found."
  echo "Install with: npx playwright install chromium"
fi
```

If `BROWSE_ENGINE` is `none`, inform the user and offer to install Playwright:
`npx playwright install chromium`

## Tiers

Ask the user which tier, or auto-select based on context:

| Tier | When | What |
|------|------|------|
| **Quick** | Small change, single file | Run related tests only |
| **Standard** | Feature branch, multiple files | Full test suite + targeted visual QA |
| **Exhaustive** | Pre-release, critical path | Full suite + browser QA + edge cases |

## Workflow

### Step 1: Assess Scope

```bash
# Count changed files to help select tier
CHANGED=$(git diff --name-only $BASE_BRANCH...HEAD 2>/dev/null | wc -l | tr -d ' ')
echo "Changed files: $CHANGED"
```

- 1-3 files → suggest Quick
- 4-15 files → suggest Standard
- 15+ files or user requests it → Exhaustive

### Step 2: Run Tests

**Quick:**
```bash
# Run only tests related to changed files
CHANGED_FILES=$(git diff --name-only $BASE_BRANCH...HEAD 2>/dev/null)
# Map changed files to their test files and run them
```

**Standard / Exhaustive:**
```bash
if [ -n "$TEST_CMD" ]; then
  $TEST_CMD
fi
```

### Step 3: Fix Loop (max 50 iterations)

For each failing test:
1. Read the test and the code it tests
2. Determine if the failure is a real bug or a test that needs updating
3. Fix the issue
4. Re-run the failing test
5. Repeat until green or max iterations reached

**WTF-likelihood heuristic**: If a fix seems surprising or non-obvious, flag it to the user before applying.

### Step 4: Visual QA (Standard + Exhaustive only)

If `BROWSE_ENGINE` is available and the project has a web UI:
1. Start the dev server if not running
2. Navigate to affected pages
3. Check for visual regressions, broken layouts, console errors
4. Screenshot key states

### Step 5: Report

| Category | Result |
|----------|--------|
| Tests run | N |
| Tests passed | N |
| Tests fixed | N |
| Visual checks | N (if applicable) |

## 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]
