# Production Readiness Skill

**Description**: Comprehensive pre-release validation workflow covering all repos with incremental fixes and commits.

## When to Use

- Before any release to production
- Before major feature deployments
- As part of regular release cadence
- When preparing for demos or important presentations

## Prerequisites

- All repos cloned and up to date
- Appropriate development tools installed (Node.js, Python, etc.)
- Access to build environments

## Phase 1: Common Platform (learning_ai_common_plat)

```bash
cd $HOME/code/mygh/learning_ai_common_plat

# 1. Install dependencies and build
pnpm install
pnpm build

# 2. Type-check all packages and services
pnpm typecheck
# If fails: fix, then git add . && git commit -m "fix(common): type-check fixes" && git push

# 3. ESLint check
pnpm lint
# If fails: fix, then git add . && git commit -m "fix(common): lint fixes" && git push

# 4. Unit tests with coverage (80% threshold)
pnpm test:coverage
# If fails: fix, then git add . && git commit -m "test(common): fix failing tests" && git push

# 5. Security audit
pnpm audit
# If fails: fix, then git add . && git commit -m "fix(common): security updates" && git push

# 6. Code formatting check
pnpm format:check
# If fails: run pnpm format, then git add . && git commit -m "style(common): format fixes" && git push

# 7. Verify package exports
for pkg in packages/*/dist; do node -e "require('./$pkg/index.js')" 2>/dev/null && echo "✓ $pkg OK" || echo "✗ $pkg FAIL"; done
# If fails: fix build/exports, commit push
```

## Phase 2: Voice Agent (learning_voice_ai_agent)

### Dashboard Setup

```bash
cd $HOME/code/mygh/learning_voice_ai_agent

# Install dashboards (requires common_plat built)
cd admin-dashboard-web && npm install
cd ../user-dashboard-web && npm install
cd ../tracker-dashboard-web && npm install
```

### Dashboard Validation

```bash
# For each dashboard (admin, user, tracker):
npx tsc --noEmit                    # Type-check
npm run lint                         # Lint
npm run format:check                 # Format check
npm run test:coverage                # Unit tests
npm run build && npm run build:analyze  # Build + bundle analysis
npm run size:check                   # Bundle size limits
npm audit --audit-level moderate     # Security audit
npm run test:e2e                     # E2E tests

# If any fail: fix, then git add . && git commit -m "fix(<dashboard>): <issue>" && git push
```

### Python Validation

```bash
cd $HOME/code/mygh/learning_voice_ai_agent

# Type checking
pyright
# If fails: fix, then git add . && git commit -m "fix(python): type-check fixes" && git push

# Lint and format
make lint
# If fails: fix, then git add . && git commit -m "fix(python): lint/format fixes" && git push

# Tests (568 total: 45 desktop + 10 backend)
python -m pytest tests/ backend/tests/ -v --tb=short
# If fails: fix, then git add . && git commit -m "test(python): fix failing tests" && git push

# Security audit
make audit
# If fails: fix, then git add . && git commit -m "fix(python): security updates" && git push
```

### Backend API Specific

```bash
cd backend

# FastAPI type check
python -m pyright src/
# If fails: fix, then git add . && git commit -m "fix(backend): type-check fixes" && git push

# Backend lint
python -m ruff check src/ tests/
# If fails: fix, then git add . && git commit -m "fix(backend): lint fixes" && git push
```

### Desktop App (Optional)

```bash
cd $HOME/code/mygh/learning_voice_ai_agent

# Build verification (resource-intensive)
bash scripts/build.sh
# If fails: fix, then git add . && git commit -m "fix(desktop): build fixes" && git push
```

## Phase 3: MindLyst (learning_multimodal_memory_agents)

```bash
cd $HOME/code/mygh/learning_multimodal_memory_agents/mindlyst-native

# 1. Install and build
./gradlew build
# If fails: fix, then git add . && git commit -m "fix(mindlyst): build fixes" && git push

# 2. KMP compile check
./gradlew :shared:compileKotlinIosSimulatorArm64
# If fails: fix, then git add . && git commit -m "fix(mindlyst): KMP compile fixes" && git push

# 3. Android compile (if SDK available)
# ./gradlew :androidApp:compileDebugKotlin
# If fails: fix, commit push

# 4. Web lint and build
cd web && npm install && npm run lint
# If fails: fix, then git add . && git commit -m "fix(mindlyst): web lint fixes" && git push
npm run build
# If fails: fix, then git add . && git commit -m "fix(mindlyst): web build fixes" && git push

# 5. Unit tests
cd .. && ./gradlew :shared:test
# If fails: fix, commit push
```

## Phase 4: Integration Smoke Test

```bash
cd $HOME/code/mygh/learning_voice_ai_agent

# 1. Start all services with Docker
docker compose up -d
sleep 10
docker compose ps
# If any service fails: fix, commit push in appropriate repo

# 2. Health check
cd $HOME/code/mygh/learning_ai_common_plat
npx tsx services/monitoring/health-check.ts
# If fails: fix, commit push in common_plat or voice_agent

# 3. Manual dashboard check
# Open:
# - http://localhost:3001 (admin)
# - http://localhost:3002 (user)
# - http://localhost:3003 (tracker)
# If any fails: fix, commit push in voice_agent

# 4. Stop services
cd $HOME/code/mygh/learning_voice_ai_agent
docker compose down
```

## Coverage Summary

| Component                | Type-Check | Lint | Format | Unit Tests | Coverage | Build | Bundle | E2E | Security |
| ------------------------ | ---------- | ---- | ------ | ---------- | -------- | ----- | ------ | --- | -------- |
| **common_plat packages** | ✅         | ✅   | ✅     | ✅         | ✅       | ✅    | ❌     | ❌  | ✅       |
| **common_plat services** | ✅         | ✅   | ✅     | ✅         | ✅       | ✅    | ❌     | ❌  | ✅       |
| **admin-dashboard**      | ✅         | ✅   | ✅     | ✅         | ✅       | ✅    | ✅     | ✅  | ✅       |
| **user-dashboard**       | ✅         | ✅   | ✅     | ✅         | ✅       | ✅    | ✅     | ✅  | ✅       |
| **tracker-dashboard**    | ✅         | ✅   | ✅     | ✅         | ✅       | ✅    | ✅     | ✅  | ✅       |
| **desktop app**          | ✅         | ✅   | ❌     | ✅         | ❌       | ✅    | ❌     | ❌  | ✅       |
| **backend API**          | ✅         | ✅   | ❌     | ✅         | ❌       | ❌    | ❌     | ❌  | ✅       |
| **mindlyst shared**      | ✅         | 📱   | 📱     | ✅         | ❌       | ✅    | ❌     | ❌  | ❌       |
| **mindlyst web**         | ❌         | ✅   | ✅     | ❌         | ❌       | ✅    | ❌     | ❌  | ❌       |
| **mindlyst android**     | ✅         | 📱   | 📱     | ❌         | ❌       | ✅    | ❌     | ❌  | ❌       |
| **mindlyst ios**         | ❌         | 📱   | 📱     | ❌         | ❌       | ❌    | ❌     | ❌  | ❌       |

📱 = Available via dedicated mobile workflow

## Commit Message Patterns

```bash
fix(scope): type-check fixes
test(scope): fix failing tests
fix(python): lint/format fixes
fix(mindlyst): KMP compile fixes
fix(common): security updates
style(dashboard): format fixes
fix(backend): build fixes
```

## Notes

- **Push after each fix** to keep history clean and avoid merge conflicts
- **common_plat first** because dashboards depend on its built packages
- **Coverage reports** generated in `coverage/` directory
- **Bundle analysis** opens in browser when `ANALYZE=true`
- **Incremental approach** - fix and commit after each phase to track progress

## Related Skills

- [Debug Service](./debug-service.md) - When something fails
- [Local Development Setup](./local-development.md) - Running services locally
- [Docker Compose](./docker-compose.md) - Full stack containerization
