---
name: quality-gate
description: Run typecheck, lint, and tests. Reports pass/fail per check. Use after building or modifying code to verify quality before proceeding.
user-invocable: true
---

# /quality-gate — Automated Quality Checks

Run all available quality checks for the project and report pass/fail for each. This skill auto-detects which tools are available.

## Steps

### 1. Detect Available Tools

Check what quality tools exist in the project:

```bash
# TypeScript check
[ -f tsconfig.json ] && echo "TypeScript: available" || echo "TypeScript: not configured"

# ESLint
[ -f .eslintrc* ] || [ -f eslint.config.* ] && echo "ESLint: available" || echo "ESLint: not configured"

# Prettier
[ -f .prettierrc* ] || [ -f prettier.config.* ] && echo "Prettier: available" || echo "Prettier: not configured"

# Test runner
[ -f jest.config.* ] || [ -f vitest.config.* ] || grep -q '"test"' package.json 2>/dev/null && echo "Tests: available" || echo "Tests: not configured"

# Python linting
[ -f pyproject.toml ] || [ -f setup.cfg ] || [ -f .flake8 ] && echo "Python lint: available" || echo "Python lint: not configured"
```

### 2. Run Each Available Check

Run each check in order and capture results:

**TypeScript (if tsconfig.json exists):**
```bash
npx tsc --noEmit 2>&1
```

**ESLint (if configured):**
```bash
npx eslint . --max-warnings=0 2>&1
```

**Prettier (if configured):**
```bash
npx prettier --check . 2>&1
```

**Tests (if configured):**
```bash
npm test 2>&1
# or: npx jest 2>&1
# or: npx vitest run 2>&1
```

**Python (if configured):**
```bash
python3 -m flake8 . 2>&1
# or: ruff check . 2>&1
```

### 3. Report Results

```
QUALITY GATE REPORT
===================

TypeScript:  PASS / FAIL (X errors)  [or: N/A — not configured]
ESLint:      PASS / FAIL (X errors, Y warnings)  [or: N/A]
Prettier:    PASS / FAIL (X files need formatting)  [or: N/A]
Tests:       PASS / FAIL (X passed, Y failed)  [or: N/A]
Python lint: PASS / FAIL (X issues)  [or: N/A]

Overall: PASS / FAIL

[If FAIL, list specific errors grouped by check:]

TypeScript Errors:
- [file:line] [error message]
- ...

ESLint Errors:
- [file:line] [rule] [message]
- ...

Test Failures:
- [test name]: [failure reason]
- ...
```

### 4. Auto-Fix (Optional)

If the user passes `--fix` as an argument, attempt auto-fixes:

```bash
# ESLint auto-fix
npx eslint . --fix

# Prettier auto-format
npx prettier --write .
```

Re-run checks after auto-fix and report the updated results.

## Rules

- Only run tools that are actually configured in the project
- Report exact error messages and file locations
- Do NOT fix issues unless `--fix` is passed — just report them
- If a tool is not installed but is configured (e.g., tsconfig.json exists but tsc fails), report as "TOOL ERROR" with the installation command
- Exit with status 0 even if checks fail — the report communicates the status
