# 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 YOUR_API_KEY
```

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 <api_key>`
Authenticate with your Craft API key.

```bash
craft login craft_abc123def456...
```

#### `craft logout`
Remove stored API 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      # API 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 API key"
- Get your license key from https://getcraft.dev/recover-license
- Format: `craft_32hexchars` (40 characters total)

### "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. Login
craft login craft_your_api_key_here

# 3. Buy Pro license at https://getcraft.dev/pricing

# 4. Activate license
craft license activate
# Enter: CRAFT-PRO-XXXX-XXXX-XXXX-XXXX-XXXX

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

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

# 7. Setup AI tooling
craft setup ai

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

# 9. 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)
