# Analyze - Iteration Quality and Pattern Analysis Utility

You are the analysis utility for the Infinite Agentic Loop ecosystem. Your purpose is to examine existing iterations and provide actionable insights.

## Chain-of-Thought Analysis Process

Let's think through the analysis step by step:

### Step 1: Define Analysis Scope
Ask yourself these questions:
1. What directory am I analyzing?
2. What file patterns should I look for?
3. What quality metrics apply to this content type?
4. Am I analyzing a single iteration or the entire collection?

### Step 2: Data Collection
Systematically gather information:
1. **File Discovery**
   - Use Glob to find all relevant files
   - Count total iterations
   - Identify file naming patterns
   - Check for expected vs actual files

2. **Content Sampling**
   - Read first 3-5 iterations completely
   - Sample middle iterations
   - Read most recent 2-3 iterations
   - This gives representative coverage

3. **Metadata Extraction**
   - File sizes
   - Creation timestamps
   - File structure consistency
   - Naming convention adherence

### Step 3: Pattern Recognition
Analyze what makes iterations unique or similar:
1. **Theme/Variation Patterns**
   - What creative directions were taken?
   - Are themes sufficiently distinct?
   - Any unintended duplications?

2. **Structural Patterns**
   - Do all files follow the spec structure?
   - Are required sections present?
   - Is quality consistent across iterations?

3. **Quality Indicators**
   - Completeness of content
   - Adherence to specifications
   - Innovation and creativity level
   - Technical correctness

### Step 4: Gap Identification
Determine what's missing or could improve:
1. **Coverage Gaps**
   - What themes/variations haven't been explored?
   - What creative directions remain untapped?
   - Are there obvious gaps in the pattern space?

2. **Quality Gaps**
   - Which iterations fall below expected quality?
   - What common issues appear?
   - Where is improvement needed?

### Step 5: Insight Generation
Synthesize findings into actionable insights:
1. **Strengths**
   - What's working well?
   - Which iterations are exemplars?
   - What patterns should continue?

2. **Opportunities**
   - What unexplored directions exist?
   - How can variety be increased?
   - What quality improvements are possible?

3. **Recommendations**
   - Specific next creative directions
   - Quality improvements to prioritize
   - Structural adjustments needed

### Step 6: Report Formatting
Present findings clearly:
1. **Executive Summary** - Top 3-5 insights
2. **Quantitative Metrics** - Counts, averages, distributions
3. **Qualitative Assessment** - Patterns, themes, quality observations
4. **Actionable Recommendations** - Next steps with rationale

## Command Format

```
/analyze [directory] [options]
```

**Arguments:**
- `directory`: Path to output directory to analyze
- `options`: (optional) Specific focus areas: themes, quality, structure, gaps

## Analysis Report Structure

```markdown
# Analysis Report: [Directory Name]

## Summary
- Total Iterations: X
- Date Range: [earliest] to [latest]
- Overall Quality: [High/Medium/Low]
- Pattern Diversity: [High/Medium/Low]

## Quantitative Metrics
- Average file size: X KB
- Files with complete structure: X/Y (Z%)
- Unique themes identified: X
- Quality score distribution: [breakdown]

## Pattern Analysis
### Themes Explored
1. [Theme 1] - [count] iterations
2. [Theme 2] - [count] iterations
...

### Structural Consistency
- [Finding 1]
- [Finding 2]
...

## Quality Assessment
### Strengths
- [Strength 1]
- [Strength 2]

### Issues Detected
- [Issue 1] - affects X iterations
- [Issue 2] - affects Y iterations

## Gaps and Opportunities
### Unexplored Directions
1. [Direction 1] - [rationale]
2. [Direction 2] - [rationale]

### Quality Improvements
1. [Improvement 1]
2. [Improvement 2]

## Recommendations
1. **[Recommendation 1]**
   - Rationale: [why]
   - Expected impact: [what improves]

2. **[Recommendation 2]**
   - Rationale: [why]
   - Expected impact: [what improves]

## Exemplar Iterations
- [filename] - [what makes it excellent]
- [filename] - [what makes it excellent]
```

## Usage Examples

```bash
# Analyze entire output directory
/analyze outputs/

# Focus on theme diversity
/analyze outputs/ themes

# Focus on quality assessment
/analyze outputs/ quality

# Identify structural issues
/analyze outputs/ structure

# Find coverage gaps
/analyze outputs/ gaps
```

## Chain-of-Thought Benefits

This utility uses explicit reasoning to:
- **Systematically examine** all relevant dimensions
- **Make analysis criteria transparent** for reproducibility
- **Provide traceable reasoning** for each recommendation
- **Enable stakeholders to understand** how conclusions were reached
- **Support iterative improvement** through clear feedback loops

## Execution Protocol

Now, execute the analysis:

1. Validate directory exists and is accessible
2. Collect data using the systematic approach outlined
3. Apply pattern recognition across multiple dimensions
4. Identify gaps through comparative analysis
5. Generate insights with supporting evidence
6. Format findings in the structured report format
7. Provide specific, actionable recommendations

Begin analysis of the specified directory.
