# Combined Optimization Strategies

### Strategy 1: Efficient Discovery
```
Goal: Find something across many files, minimize tokens

1. search(query, detail='minimal', limit=30)
   → Browse summaries (~3k tokens)

2. Filter top 5 by score (>0.7)

3. get_full_context(top_5_ids)
   → Deep dive selectively (~4k tokens)

Total: ~7k tokens (vs ~24k with detail='full' upfront)
Savings: ~70% token reduction
```

### Strategy 2: Precise Targeting
```
Goal: Get exactly what you need, fast

1. Identify store: list_stores()

2. search(precise_query,
         intent='find-implementation',
         detail='full',
         limit=3,
         stores=['target-store'])
   → Exact match with full code

Total: ~2.5k tokens
Result: Fastest path to answer
```

### Strategy 3: Comparative Analysis
```
Goal: Compare implementations across libraries

1. search(query,
         intent='find-implementation',
         detail='minimal',
         limit=20,
         stores=['lib1', 'lib2', 'lib3'])
   → Get summaries from multiple libraries

2. Review distribution:
   - lib1: 8 results
   - lib2: 7 results
   - lib3: 5 results

3. get_full_context(top_2_from_each_lib)
   → Compare implementations

Total: ~5k tokens
Result: Balanced cross-library comparison
```

---

# Token Usage Examples

Real token counts for different strategies:

```
# Inefficient approach
search("auth middleware", detail='full', limit=30)
→ 30 results × 800 tokens = 24,000 tokens
→ Most results not even relevant!

# Optimized approach
search("auth middleware", detail='minimal', limit=30)
→ 30 results × 100 tokens = 3,000 tokens
→ Identify top 3 (score > 0.8)

get_full_context([id1, id2, id3])
→ 3 results × 800 tokens = 2,400 tokens

Total: 5,400 tokens (78% reduction!)
```
