# Justfile Recipes - Quick Reference

## Authentication (auth.just)

```bash
# Login & Logout
just auth-login <user>              # Login to platform
just auth-logout                    # Logout current session
just whoami                         # Show current user status

# MFA Setup
just mfa-enroll-totp                # Enroll in TOTP MFA
just mfa-enroll-webauthn            # Enroll in WebAuthn MFA
just mfa-verify <code>              # Verify MFA code

# Sessions
just auth-sessions                  # List active sessions
just auth-revoke-session <id>       # Revoke specific session
just auth-revoke-all                # Revoke all other sessions

# Workflows
just auth-login-prod <user>         # Production login (MFA required)
just auth-quick                     # Quick re-authentication

# Help
just auth-help                      # Complete authentication guide
```

## KMS (kms.just)

```bash
# Encryption
just kms-encrypt <file>             # Encrypt file with RustyVault
just kms-decrypt <file>             # Decrypt file
just encrypt-config <file>          # Encrypt configuration file

# Backends
just kms-backends                   # List available backends
just kms-test-all                   # Test all backends
just kms-switch-backend <backend>   # Change default backend

# Key Management
just kms-generate-key               # Generate AES256 key
just kms-list-keys                  # List encryption keys
just kms-rotate-key <id>            # Rotate key

# Bulk Operations
just encrypt-env-files [dir]        # Encrypt all .env files
just encrypt-configs [dir]          # Encrypt all configs
just decrypt-all-files <dir>        # Decrypt all .enc files

# Workflows
just kms-setup                      # Setup KMS for project
just quick-encrypt <file>           # Fast encrypt
just quick-decrypt <file>           # Fast decrypt

# Help
just kms-help                       # Complete KMS guide
```

## Orchestrator (orchestrator.just)

```bash
# Status
just orch-status                    # Show orchestrator status
just orch-health                    # Health check
just orch-info                      # Detailed information

# Tasks
just orch-tasks                     # List all tasks
just orch-tasks-running             # Show running tasks
just orch-tasks-failed              # Show failed tasks
just orch-task-cancel <id>          # Cancel task
just orch-task-retry <id>           # Retry failed task

# Workflows
just workflow-list                  # List all workflows
just workflow-status <id>           # Show workflow status
just workflow-monitor <id>          # Monitor real-time
just workflow-logs <id>             # Show logs

# Batch Operations
just batch-submit <file>            # Submit batch workflow
just batch-monitor <id>             # Monitor batch progress
just batch-rollback <id>            # Rollback batch
just batch-cancel <id>              # Cancel batch

# Validation
just orch-validate <file>           # Validate KCL workflow
just workflow-dry-run <file>        # Simulate execution

# Cleanup
just workflow-cleanup               # Clean completed workflows
just workflow-cleanup-old <days>    # Clean old workflows
just workflow-cleanup-failed        # Clean failed workflows

# Quick Workflows
just quick-server-create <infra>    # Quick server creation
just quick-taskserv-install <t> <i> # Quick taskserv install
just quick-cluster-deploy <c> <i>   # Quick cluster deploy

# Help
just orch-help                      # Complete orchestrator guide
```

## Plugin Testing

```bash
just test-plugins                   # Test all plugins
just test-plugin-auth               # Test auth plugin
just test-plugin-kms                # Test KMS plugin
just test-plugin-orch               # Test orchestrator plugin
just list-plugins                   # List installed plugins
```

## Common Workflows

### Complete Authentication Setup

```bash
just auth-login alice
just mfa-enroll-totp
just auth-status
```

### Production Deployment Workflow

```bash
# Login with MFA
just auth-login-prod alice

# Encrypt sensitive configs
just encrypt-config prod/secrets.yaml
just encrypt-env-files ./config

# Submit batch workflow
just batch-submit workflows/deploy-prod.ncl
just batch-monitor <workflow-id>
```

### KMS Setup and Testing

```bash
# Setup KMS
just kms-setup

# Test all backends
just kms-test-all

# Encrypt project configs
just encrypt-configs config/
```

### Monitoring Operations

```bash
# Check orchestrator health
just orch-health

# Monitor running tasks
just orch-tasks-running

# View workflow logs
just workflow-logs <workflow-id>

# Check metrics
just orch-metrics
```

### Cleanup Operations

```bash
# Cleanup old workflows
just workflow-cleanup-old 30

# Cleanup failed workflows
just workflow-cleanup-failed

# Decrypt all files for migration
just decrypt-all-files ./encrypted
```

## Tips

1. **Help is Built-in**: Every module has a help recipe
   - `just auth-help`
   - `just kms-help`
   - `just orch-help`

2. **Tab Completion**: Use `just --list` to see all available recipes

3. **Dry-Run**: Use `just -n <recipe>` to see what would be executed

4. **Shortcuts**: Many recipes have short aliases
   - `just whoami` = `just auth-status`

5. **Error Handling**: Destructive operations require confirmation

6. **Composition**: Combine recipes for complex workflows

   ```bash
   just auth-login alice && just orch-health && just workflow-list
   ```

## Recipe Count

- **Auth**: 29 recipes
- **KMS**: 38 recipes
- **Orchestrator**: 56 recipes
- **Total**: 123 recipes

## Documentation

- Full authentication guide: `just auth-help`
- Full KMS guide: `just kms-help`
- Full orchestrator guide: `just orch-help`
- Security system: `docs/architecture/ADR-009-security-system-complete.md`

---

**Quick Start**: `just help` → `just auth-help` → `just auth-login <user>` → `just mfa-enroll-totp`
