# /forecast — Generate Pipeline Forecast & Projections

Generate weighted sales forecasts from pipeline data, set targets, and get revenue projections.

## Usage

```
/forecast                                 # Forecast from pipeline data
/forecast --period weekly|monthly|quarterly
/forecast --target <amount>               # Compare against quota
/forecast @<csv_file>                     # From exported data
```

## What This Command Does

### Step 1: Gather Pipeline Data
- Load all campaigns from `~/.lead_pipeline/data/`
- Parse lead statuses and progression history
- If CSV provided, parse external pipeline data

### Step 2: Calculate Weighted Forecast

Apply conversion probability by pipeline stage:

| Stage | Weight | Rationale |
|-------|--------|-----------|
| NEW (scraped) | 5% | Raw lead, unqualified |
| ENRICHED | 15% | Contact info found, shows potential |
| EMAIL_DRAFTED | 25% | Outreach prepared, engagement pending |
| SENT | 35% | Outreach delivered, awaiting response |
| Replied (positive) | 60% | Active engagement |
| Meeting booked | 75% | Qualified opportunity |
| Proposal sent | 85% | Near close |

### Step 3: Generate Forecast Output

```markdown
## Pipeline Forecast — [Period]

### Forecast Summary
| Metric | Value |
|--------|-------|
| Total pipeline value | [N leads × est. deal value] |
| Weighted forecast | [Sum of stage-weighted values] |
| Target / Quota | [If provided] |
| Gap to target | [Difference] |
| Coverage ratio | [Pipeline / Target] |

### Forecast by Stage
| Stage | Leads | Weight | Weighted Value |
|-------|-------|--------|---------------|
| NEW | [N] | 5% | [Value] |
| ENRICHED | [N] | 15% | [Value] |
| EMAIL_DRAFTED | [N] | 25% | [Value] |
| SENT | [N] | 35% | [Value] |
| Replied | [N] | 60% | [Value] |

### Trend Analysis
- **This period vs. last**: [Up/Down X%]
- **Pipeline velocity**: [Average days per stage]
- **Conversion rates**: [Stage-to-stage %]
- **Best source**: [Which registry/search engine produces best leads]

### Risk Scenarios
| Scenario | Probability | Projected Value |
|----------|------------|-----------------|
| Best case | 20% | [High estimate] |
| Most likely | 60% | [Weighted forecast] |
| Worst case | 20% | [Conservative] |

### Recommendations
1. [Action to improve forecast accuracy]
2. [Action to increase pipeline coverage]
3. [Action to accelerate stuck deals]
```

## Integration with Lead Pipeline
- Uses `CampaignResult.metrics` for actual counts
- Tracks `Lead.status` progression for velocity calculations
- Compares across campaigns for trend analysis
- Correlates `RegistrySource` with conversion rates

## Key Rules
- Be transparent about assumptions in weighting
- Always show the methodology, not just the number
- Flag insufficient data if pipeline is too small for reliable projections
- Recommend increasing pipeline if coverage ratio < 3x target
