# How to Use CLI Brain

## 📋 Quick Setup

### 1. Copy to Your Project

**Option A: Copy everything**
```bash
cp -r /path/to/cli-brain/* ./.opencode/
```

**Option B: Copy only agents (minimal)**
```bash
cp -r /path/to/cli-brain/agents ./.opencode/agents
```

### 2. Start Using

```bash
# The orchestrator will automatically find and use agents
opencode "build a landing page"
```

## 🎯 Usage Patterns

### Automatic Routing (Recommended)

```bash
# Just describe what you want
opencode "create a React landing page"
# → Routes to @design-system-consultant → @frontend-developer

opencode "build a REST API for users"
# → Routes to @api-architect → @backend-architect

opencode "make my database faster"
# → Routes to @database-optimizer
```

### Direct Agent Invocation

```bash
opencode @frontend-developer "create a button component"
opencode @api-architect "design auth endpoints with JWT"
opencode @fullstack-developer "build Next.js app with Prisma"
```

### Workflows

```bash
# Run predefined multi-agent workflows
opencode run landing-page --style glassmorphism
opencode run saas-mvp --name "MyStartup"
opencode run api-service --framework fastapi
```

## 📁 File Structure to Copy

**Essential files:**
```
.opencode/
├── agents/              # ⭐ Required - all agents
│   ├── orchestrator.md
│   ├── engineering/
│   ├── design/
│   ├── testing/
│   └── ...
├── router/              # Optional - for smart routing
│   ├── keywords.json
│   └── intent-router.ts
└── workflows/           # Optional - for workflows
    └── workflow-engine.ts
```

## 🧠 How the Orchestrator Works

When you type `opencode "your prompt"`:

1. **Analyzes** your prompt for keywords
2. **Scores** all agents by relevance
3. **Decides** based on confidence:
   - ≥90%: Routes immediately
   - 70-89%: Asks for quick confirmation
   - 50-69%: Asks 1 clarifying question
   - <50%: Full clarification dialog
4. **Learns** from your choices

## 💾 Persistent Config

First run creates `~/.opencode-agency/` with:
- `preferences.json` - Your preferences and history
- Survives CLI updates

## 🎨 UI/UX Features

```bash
# Get design intelligence
opencode @design-system-consultant "suggest color palette for healthcare"
opencode @design-system-consultant "glassmorphism card with Tailwind"
opencode @design-system-consultant "font pairing for tech startup"
```

## 📊 Available Agents (181 Total)

See `AGENTS.md` for full catalog.

Quick reference:
- `@orchestrator` - Routes everything
- `@frontend-developer` - React, Vue, etc.
- `@backend-architect` - Databases, APIs
- `@fullstack-developer` - Next.js, Nuxt
- `@api-architect` - REST/GraphQL design
- `@design-system-consultant` - UI/UX, colors
- `@testing-reality-checker` - Testing, bugs
- `@devops-automator` - Docker, CI/CD
- `@security-engineer` - Auth, security

## 🔧 Troubleshooting

**Agents not found?**
- Ensure `.opencode/agents/` is in your project root
- Check that agent files end in `.md`

**Routing not working?**
- Check `router/keywords.json` exists
- Verify agent names match (e.g., `@frontend-developer`)

**Want to customize?**
- Edit agent files in `.opencode/agents/`
- Update `router/keywords.json` for new agents

## 📚 More Info

- `README.md` - Full documentation
- `AGENTS.md` - Complete agent catalog
- Individual agent files - Detailed instructions
