---
name: verification-loop
description: Systematic verification of code quality before deployment. Run build checks, type checks, lint, tests, security scan, and diff review. Use after implementing features, before deployment, after refactoring, or when quality gates need to pass. Triggers on 'verify', 'check quality', 'is this ready', 'pre-deploy check'.
---

# Verification Loop

Systematic multi-phase verification to catch issues before they reach production.

## When to Use

- After implementing a feature
- Before deployment or PR
- After refactoring
- When quality gates must pass
- Periodically during long sessions

## Verification Phases

### Phase 1: Build Verification

Confirm the project builds without errors:
```bash
# Python
python -m py_compile main.py
# Node
npm run build
# Docker
docker build .
```

If build fails, STOP and fix before continuing.

### Phase 2: Type/Lint Check

```bash
# Python
ruff check .
mypy . --ignore-missing-imports

# JavaScript/TypeScript
npx tsc --noEmit
npm run lint
```

Report all errors. Fix critical ones before continuing.

### Phase 3: Test Suite

```bash
# Python
pytest --cov=src --cov-report=term-missing

# Node
npm test -- --coverage
```

Report: total tests, passed, failed, coverage percentage. Target: 80% minimum.

### Phase 4: Security Scan

```bash
# Check for hardcoded secrets
grep -rn "sk-\|api_key\|password\s*=" --include="*.py" . | grep -v test
grep -rn "sk-\|api_key\|password\s*=" --include="*.js" --include="*.ts" .

# Check for debug statements
grep -rn "print(\|console.log\|debugger" --include="*.py" --include="*.js" src/

# Python dependency audit
pip-audit

# Node dependency audit
npm audit --audit-level=high
```

### Phase 5: Diff Review

```bash
git diff --stat
git diff HEAD~1 --name-only
```

Review each changed file for: unintended changes, missing error handling, potential edge cases.

## Output Format

```
VERIFICATION REPORT
==================
Build:     [PASS/FAIL]
Types:     [PASS/FAIL] (X errors)
Lint:      [PASS/FAIL] (X warnings)
Tests:     [PASS/FAIL] (X/Y passed, Z% coverage)
Security:  [PASS/FAIL] (X issues)
Diff:      [X files changed]

Overall:   [READY/NOT READY]

Issues to Fix:
1. ...
2. ...
```

## Continuous Mode

For long sessions, run verification:
- After completing each function or component
- Before moving to next task
- Every 15 minutes during active development

## Severity Guide

| Issue | Severity | Action |
|-------|----------|--------|
| Build failure | CRITICAL | Fix immediately |
| Security vulnerability | CRITICAL | Fix immediately |
| Test failure | HIGH | Fix before merge |
| Type error | HIGH | Fix before merge |
| Lint warning | MEDIUM | Fix if easy |
| Missing test | MEDIUM | Add before merge |
| Style issue | LOW | Optional |
