# Craft CLI

Official command-line interface for **Craft** - The complete full-stack, clean code, AI-ready SaaS framework.

## Features

- 🚀 **Rapid project creation** - Clone production-ready templates in seconds
- 🎯 **Adaptive quality levels** - Rapid, Balanced, or Crafted (3 levels × 2 platforms = 6 templates)
- 🔑 **License management** - Activate Pro/Enterprise licenses with device tracking
- 🤖 **AI-ready** - Pre-configured MCP servers and Claude Skills
- 📦 **Complete stack** - Next.js + tRPC + Prisma + Supabase + React Native

## Installation

```bash
npm install -g @getcraft-dev/craft-cli
```

## Quick Start

### 1. Authenticate

```bash
craft login CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX
```

Get your license key: https://getcraft.dev/recover-license

### 2. Create a Project

```bash
craft new
# Choose template: Rapid, Balanced, or Crafted
# Choose platform: Web or Web+Mobile
```

### 3. Activate Pro License (Optional)

```bash
craft license activate
# Enter license key: CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX
```

## Commands

### Project Creation

#### `craft new`
Create a new Craft project.

```bash
craft new
```

**Available templates:**
- 🚀 **Rapid** (Web / Web+Mobile) - Ship fast, 1-2 devs, 0-100 users
- ⚖️ **Balanced** (Web / Web+Mobile) - Pragmatic quality, 3-10 devs, 100-10K users
- 🏆 **Crafted** (Web / Web+Mobile) - Software craftsmanship, 10-200+ devs, 10K-1M+ users

**Access by tier:**
- 🆓 **Community** (Free) - Rapid Web only
- 💎 **Pro** ($199 one-time) - All 5 templates (Rapid, Balanced, Crafted × Web/Mobile)
- 🏢 **Enterprise** (Custom) - All templates + custom features

---

### Authentication

#### `craft login <license_key>`
Activate your Pro license.

```bash
craft login CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX
```

#### `craft logout`
Remove stored license key.

```bash
craft logout
```

---

### License Management

#### `craft license activate`
Activate a Pro or Enterprise license key.

```bash
craft license activate
# Prompts for license key
```

#### `craft license status`
Check current license status and access.

```bash
craft license status
```

#### `craft license deactivate`
Deactivate license on current device.

```bash
craft license deactivate
```

---

### AI System Setup

#### `craft setup ai`
Setup complete AI tooling (MCP servers + Skills).

```bash
craft setup ai
```

#### `craft setup mcp`
Install MCP servers only.

```bash
craft setup mcp
```

**Installs MCP servers:**
- crafted-cli
- rules-validator
- architecture-guard
- development/typescript
- development/vitest
- orchestrator
- crafted-context
- chrome-devtools
- filesystem
- github

#### `craft setup skills`
Install Claude Code Skills only.

```bash
craft setup skills
```

**Installs skills:**
- **Level Skills** (3): /rapid, /balanced, /crafted
- **Workflow Skills** (4): /feature, /bugfix, /refactor, /security
- **Agent Skills** (4): /architect, /developer, /tester, /reviewer
- **Utility Skills** (3): /validate, /guard, /coverage

---

## License Tiers

| Tier | Price | Templates | Agents | Skills | MCP Servers |
|------|-------|-----------|--------|--------|-------------|
| 🆓 **Community** | Free | 1 (Rapid Web) | 2 | 0 | 4 |
| 💎 **Pro** | $199 (one-time) | 5 (All) | 4 | 17+ | 10 |
| 🏢 **Enterprise** | Custom | All + Custom | Custom | Custom | Custom |

### Device Limits

- **Community:** Unlimited devices
- **Pro:** 3 devices
- **Enterprise:** Custom

Deactivate devices anytime with `craft license deactivate`.

---

## Quality Levels Explained

### 🚀 Rapid
**Context:** MVP, market validation, solo/duo developers
- Max 100 lines/function
- Testing: Auth + Payment flows only
- Architecture: Flat (logic in routers)
- Ship fast, iterate quickly

### ⚖️ Balanced
**Context:** Growing product, small team, paying customers
- Max 50 lines/function, 3 params
- Testing: 70% coverage
- Architecture: 3-layer (Routers → Services → Repositories)
- Pragmatic quality, maintainable

### 🏆 Crafted
**Context:** Enterprise, long-term (5-10+ years), large team
- Max 20 lines/function, 2 params
- Testing: 100% coverage (domain), 80% (infrastructure)
- Architecture: Hexagonal (Domain → Application → Infrastructure)
- Software craftsmanship, highly scalable

---

## Environment Variables

Configure CLI behavior with environment variables:

```bash
# API endpoint (default: https://getcraft.dev)
export CRAFTED_API_URL=https://getcraft.dev

# For development
export CRAFTED_API_URL=http://localhost:3000
```

---

## File Locations

### Configuration
```
~/.craft/
├── config.json      # License key
└── license.json     # License info
```

### Project Files
```
your-project/
├── .craftrc.json  # Project config (level, platform)
├── .claude/
│   └── skills/      # Craft Skills
├── .ai/
│   └── mcp-servers/ # MCP servers
└── ...
```

---

## Troubleshooting

### "Invalid license key"
- Get your license key from https://getcraft.dev/recover-license
- Format: `CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX`

### "License validation failed"
- Check internet connection (requires online validation)
- Grace period: 7 days offline
- Contact support: contact@getcraft.dev

### "Max devices reached"
- Deactivate unused devices: `craft license deactivate`
- Pro tier: Max 3 devices

### "Template not found"
- Ensure templates are accessible
- Pro templates require Pro license
- Run: `craft license status` to check access

---

## Examples

### Complete Workflow

```bash
# 1. Install CLI
npm install -g @getcraft-dev/craft-cli

# 2. Buy Pro license at https://getcraft.dev

# 3. Activate license (received by email after purchase)
craft login CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX

# 4. Create project
craft new
# Select: Balanced - Web + Mobile

# 5. Setup project
cd my-saas-app
pnpm install
cp .env.example .env.local
# Edit .env.local with your keys

# 6. Setup AI tooling
craft setup ai

# 7. Run migrations
pnpm --filter @craft/database db:generate

# 8. Start development
pnpm dev
```

---

## Support

- **Documentation:** https://docs.getcraft.dev
- **Email:** contact@getcraft.dev
- **License Recovery:** https://getcraft.dev/recover-license

---

## License

MIT License - see [LICENSE](LICENSE) file for details.

---

**Made with ❤️ by the Craft Team**

[Website](https://getcraft.dev) · [Documentation](https://docs.getcraft.dev) · [Contact](mailto:contact@getcraft.dev)
