# Agent Best Practices

Guidelines for creating effective AI agents in CodeCrew.

## Agent Specialization

Each agent should have a clear, focused purpose:

- **@claude** - Complex reasoning, architecture decisions
- **@copilot** - Code implementation, best practices
- **@gemini** - Performance optimization, data analysis

## System Prompt Design

### Be Specific

Good:
```yaml
system_prompt: |
  You are a TypeScript expert specializing in NestJS applications.
  Focus on type safety, dependency injection, and testing.
```

Bad:
```yaml
system_prompt: |
  You are a helpful assistant.
```

### Provide Context

Include relevant documentation, coding standards, or project-specific guidelines in your system prompt.

### Use Document References

Reference documents instead of duplicating content:

```yaml
system_prompt: |
  You are a senior developer.
  
  <coding-standards>
  {{{documents.coding-standards.content}}}
  </coding-standards>
```

## Model Selection

Choose the right model for your task:

- `sonnet` - Balanced performance (recommended)
- `opus` - Complex reasoning tasks
- `haiku` - Fast, simple tasks

Specify the model in your query:
```bash
codecrew q "@claude:opus design this architecture"
```

## Parallel Execution

Leverage parallel execution for independent tasks:

```bash
# Good - parallel analysis
codecrew q "@claude @copilot @gemini review this code"

# Bad - sequential when parallel is possible
codecrew q "@claude review this code"
codecrew q "@copilot review this code"
codecrew q "@gemini review this code"
```

## Task Breakdown

Break complex tasks into agent-specific subtasks:

```bash
# Architecture
codecrew q "@claude design user authentication system"

# Implementation  
codecrew x "@copilot implement JWT middleware"

# Optimization
codecrew q "@gemini optimize authentication performance"
```

## Error Handling

Check task logs when things go wrong:

```bash
codecrew logs [taskId]
```

Review agent responses for warnings or suggestions.
