# ASA CLI — Architecture Stabilization Engine

> Scan. Stabilize. Verify. Ship with confidence.
>
> Detect structural chaos in AI-built apps. Stabilize architecture without rewriting.
> Install production-ready foundations. Verify compliance before every deploy.

## Install

```bash
pip install asa-standard
```

> The CLI command is `asa` (not `asa-standard`). Requires Python 3.10+.

## Quick Start

```bash
# Diagnose structural risk (always free)
asa scan .

# Stabilize an existing app (hero command)
asa stabilize --yes

# Or step by step:
asa spec infer .        # Infer architecture spec
asa plan                # Dry-run — see what changes
asa apply               # Install foundation
asa verify              # Check architecture compliance
asa repair              # Fix remaining drift
```

## Commands

### Diagnostic (Always Free)

| Command | Description |
|---|---|
| `asa scan [path]` | AI Chaos Index — structural risk score (0–100), 5 root causes, risk band |
| `asa scan [path] --json` | Machine-readable JSON output for CI pipelines |

### Stabilization Engine

| Command | Description |
|---|---|
| `asa stabilize [--yes] [--dry-run]` | Full flow: scan → infer → plan → apply → bridge → verify |
| `asa spec infer [path]` | Infer `.asa/spec.yaml` from existing codebase |
| `asa plan` | Dry-run — show what `asa apply` would do |
| `asa apply` | Install foundation architecture from spec |
| `asa verify [--ci]` | Verify architecture vs `.asa/spec.yaml` (CI-ready) |
| `asa repair [--auto]` | Detect drift and suggest/apply fixes |

### Foundation

| Command | Description |
|---|---|
| `asa init --name <name>` | Initialize new ASA project (Next.js App Router starter) |
| `asa install <module>` | Install foundation module (see below) |
| `asa lint [--strict]` | Boundary + contract + security + entitlement enforcement |
| `asa deploy [--check \| --staging \| --prod]` | Architecture-safe deployment (Vercel + Supabase) |

### Slice Management

| Command | Description |
|---|---|
| `asa slice new <domain/name>` | Create vertical slice (handler + schemas + UI + contract) |
| `asa slice update <domain/name>` | Regenerate after spec change (preserves user code) |
| `asa slice plan <spec>` | Propose slice architecture from functional spec |
| `asa slice split <name>` | Analyze oversized slice, propose split |
| `asa slice build <name>` | Internal build pipeline (contract → zod → skeleton) |
| `asa slice sync` | Validate all contracts across project |
| `asa slice analyze <name>` | Detailed slice analysis (LOC, imports, coupling) |

### UI Generation

| Command | Description |
|---|---|
| `asa ui generate <name>` | Regenerate frontend part of slice from contract |

## Foundation Modules

| Module | What it creates |
|---|---|
| `db-basic` | Supabase client (browser/server/admin), types, utils, seed, migrations framework |
| `auth-basic` | Login, register, logout, reset-password slices + middleware, session, guards, hooks, RLS policies |
| `payments-basic` | Subscribe, cancel, webhook (inbox pattern), check-limits slices + Stripe config, entitlements, reconciliation |
| `admin-basic` | Dashboard, users, roles, impersonation, audit-log slices + RBAC guards, immutable audit trail |

## How It Works

Your code never leaves your machine. The CLI runs locally, offline, using static analysis.

1. **Scan** — Measure structural risk with the AI Chaos Index (0–100)
2. **Stabilize** — Add architecture to existing apps without rewriting
3. **Build** — Create new features as isolated vertical slices
4. **Verify** — Check compliance before every deploy

## Links

- **ASA Standard:** [asastandard.org](https://asastandard.org) — open architecture specification
- **Website:** [vibecodiq.com](https://vibecodiq.com)
- **CLI docs:** [vibecodiq.com/scan/cli](https://vibecodiq.com/scan/cli)
- **GitHub:** [janvoldan/asa-cli](https://github.com/janvoldan/asa-cli)

---

*v2.1.0 — 2026-03-11*
