# Agent: Solve

Multi-agent problem solving with orchestration across multiple tools and approaches.

## Usage

```
/agent-solve "Optimize database queries for slow dashboard loading"
```

## Description

The `/agent-solve` skill tackles complex problems by coordinating multiple agents:
1. Every Code's `/solve` command for orchestration
2. Prometheus for deep code analysis
3. Multiple solution attempts with validation
4. Best solution selection based on metrics

## Examples

### Solve performance issue
```
/agent-solve "Dashboard takes 10 seconds to load with 1000 items"
```

### Solve architecture problem
```
/agent-solve "Refactor monolithic payment service into microservices
Constraints: Must maintain backward compatibility"
```

### Solve integration challenge
```
/agent-solve "Integrate Stripe webhooks with existing payment system
Context: Using Express.js, PostgreSQL, Redis"
```

## Backends

- **Primary**: Every Code (/solve multi-agent orchestration)
- **Analysis**: Prometheus (knowledge graph, AST analysis)
- **Validation**: Both platforms (testing, review)

## Workflow

### 1. Problem Decomposition
- Break down complex problem into sub-tasks
- Identify dependencies and constraints
- Determine success criteria

### 2. Parallel Solution Attempts
- Agent 1: Analyze current implementation
- Agent 2: Research best practices
- Agent 3: Generate solution candidates
- Agent 4: Validate solutions

### 3. Solution Synthesis
- Compare solution approaches
- Merge best aspects from each
- Create unified solution

### 4. Implementation & Testing
- Apply selected solution
- Run comprehensive tests
- Measure improvement metrics

## Output

```
# Problem: Dashboard loading optimization

## Analysis
- Current load time: 10.2s
- Bottleneck identified: N+1 queries in item fetching
- Database queries: 1,247 per page load

## Solution Candidates
1. Query batching with DataLoader: 2.1s (79% improvement)
2. Caching layer with Redis: 1.8s (82% improvement)
3. Combined approach: 0.9s (91% improvement)

## Selected Solution
- Implemented DataLoader for batch queries
- Added Redis caching for hot data
- Optimized database indexes

## Results
✓ Load time: 10.2s → 0.9s (91% improvement)
✓ Queries: 1,247 → 47 per page load
✓ All tests passing: 127/127
✓ No regressions detected

Files modified:
- src/services/dashboard.ts
- src/api/items.ts
- src/cache/redis.ts
- prisma/schema.prisma
```

## Follow-up

After solving:
- `/agent-review` - Review implementation quality
- `/agent-test` - Validate with tests
- `/agent-context` - Understand solution architecture
