# Spec Generator Meta-Prompt

**Purpose:** Abstract framework for auto-generating specifications from discovered patterns using meta-prompting principles.

**Last Updated:** 2025-10-10
**Version:** 1.0.0

## Overview

This meta-prompt provides the structural framework used by `/generate-spec` to create new specification files from analyzed patterns. It focuses on extracting abstract, generalizable patterns rather than copying specific examples.

## Meta-Prompting Principles Applied

### 1. Structure Over Content

Specs should define **HOW to think**, not **WHAT to create**:

```
AVOID: "Create a blue button with rounded corners"
PREFER: "Apply visual hierarchy principle with [PATTERN]"

AVOID: "Use this specific code structure"
PREFER: "Follow architectural pattern [FRAMEWORK]"

AVOID: "Make it look like example X"
PREFER: "Apply design principle [ABSTRACTION]"
```

### 2. Pattern-Based Generation

Extract patterns from multiple sources, not single examples:

```
Pattern Discovery Process:
1. Analyze N iterations (N ≥ 10)
2. Identify recurring structural elements
3. Abstract commonalities into patterns
4. Validate pattern generalizability
5. Document pattern with framework
```

### 3. Generalizable Frameworks

Create specs that work across contexts:

```
Good Spec Characteristics:
✓ Works for multiple domains
✓ Based on principles, not examples
✓ Provides frameworks, not templates
✓ Enables creativity through constraints
✓ Can evolve and improve
```

## Specification Generation Framework

### Phase 1: Pattern Discovery

**Source Analysis:**

```
For source_type in [patterns, logs, existing_specs, all]:
  Load source materials
  Extract structural elements
  Identify recurring patterns
  Abstract to principles
  Validate generalizability
```

**Pattern Extraction Template:**

```markdown
## Discovered Pattern: [Name]

**Frequency:** [X/Y iterations use this]
**Contexts:** [Where it appears]
**Structure:**
```
[Abstract template of the pattern]
```

**Why It Works:**
[Principle-based explanation]

**Generalizability:** [High|Medium|Low]
**Quality Correlation:** [Impact on quality metrics]
```

**Meta-Level Insights:**

```
What makes successful iterations successful?
  - Structural characteristics
  - Pattern applications
  - Abstract frameworks used
  - Meta-awareness level

What makes unsuccessful iterations fail?
  - Missing patterns
  - Structural issues
  - Over-specification
  - Under-abstraction
```

### Phase 2: Specification Synthesis

**Generation Focus Strategies:**

**Novel Mode:**
```
Goal: Create entirely new specification type

Process:
1. Identify unexplored problem spaces
2. Combine successful patterns in new ways
3. Introduce novel quality dimensions
4. Define fresh creative constraints
5. Ensure pattern generalizability

Validation:
- Is this genuinely novel?
- Are patterns still applicable?
- Is quality measurable?
```

**Variant Mode:**
```
Goal: Create variation of existing spec

Process:
1. Select best-performing source spec
2. Modify key parameters (complexity, domain, constraints)
3. Maintain proven structural patterns
4. Add 2-3 innovative elements
5. Keep evolution path clear

Validation:
- Different enough from source?
- Maintains quality potential?
- Has clear advantages?
```

**Evolution Mode:**
```
Goal: Evolve specs based on learnings

Process:
1. Start with baseline spec
2. Apply improvement log insights
3. Enhance quality criteria based on metrics
4. Refine constraints for better results
5. Add meta-level capabilities

Validation:
- Measurably better than baseline?
- Learnings properly integrated?
- Evolution is traceable?
```

**Hybrid Mode:**
```
Goal: Combine multiple successful patterns

Process:
1. Merge structural elements from top specs
2. Create multi-dimensional quality criteria
3. Balance constraints from different domains
4. Synthesize meta-insights into unified spec
5. Ensure coherence despite diversity

Validation:
- Patterns work together?
- Not just concatenation?
- Synergies identified and leveraged?
```

### Phase 3: Spec Structure Design

**Standard Specification Template:**

```markdown
# [Spec Title]

**Type:** [Category]
**Generated From:** [Source analysis]
**Meta-Patterns Applied:** [List key patterns]
**Created:** [Timestamp]

## Overview
[Abstract description focusing on structure and patterns]

## Structural Framework
[High-level architecture - the "skeleton"]

```
[ASCII art or template showing structure]
```

## Generation Patterns

### Pattern 1: [Name]

**Abstract Structure:**
```
[Generalizable template]
```

**Reasoning Flow:**
1. [Principle-based step 1]
2. [Principle-based step 2]
3. [Principle-based step 3]

**Quality Criteria:**
- [Measurable criterion 1]
- [Measurable criterion 2]

**Why This Pattern:**
[Explanation of effectiveness]

[Repeat for each pattern]

## Quality Dimensions

### 1. [Dimension Name] (0-10)
- What it measures
- How to evaluate
- Why it matters
- Target threshold

[Repeat for each dimension]

### Meta-Awareness (always include)
- Self-referential understanding
- Reflection capability
- Evolution potential
- Target: ≥ 7.0

### Generalizability (always include)
- Pattern applicability
- Minimal example-dependency
- Principle-driven design
- Target: ≥ 7.5

## Creative Constraints

**Must include:**
- [Constraint that enables uniqueness]
- [Constraint that ensures quality]
- [Constraint that promotes meta-awareness]

**Should apply:**
- [Structural guideline]
- [Abstract principle]
- [Meta-capability requirement]

**Cannot:**
- [Anti-pattern to avoid]
- [Quality-reducing approach]
- [Over-specification]

## Naming Convention
[Pattern-based naming system]

## File Structure
[Expected organization with meta-annotations]

## Success Criteria
[How to evaluate generated output]

## Meta-Instructions for Generators

[Structure-oriented guidance for sub-agents]

When generating content for this spec:
1. Think structure first
2. Apply abstract frameworks
3. Maintain meta-awareness
4. Reflect and improve

## Evolution Hooks

[How this spec can evolve further]
- Complexity progression path
- Domain variation options
- Pattern extension possibilities
- Meta-enhancement opportunities
```

### Phase 4: Quality Dimension Extraction

**Dimension Discovery Process:**

```
Analyze successful iterations:
  What qualities make them excellent?

Extract dimensions:
  - Structural integrity
  - Pattern adherence
  - Innovation level
  - Meta-awareness
  - [Domain-specific dimensions]

Make measurable:
  - Define 0-10 scale
  - Provide evaluation criteria
  - Set target thresholds
  - Explain why it matters

Validate:
  - Is it actually measurable?
  - Does it correlate with success?
  - Is it generalizable?
```

**Standard Dimensions (always include):**

1. **Structural Clarity** (0-10)
   - Pattern visibility
   - Organization logic
   - Abstraction appropriateness

2. **Meta-Awareness** (0-10)
   - Self-reflection presence
   - Improvement hook quality
   - Evolution potential

3. **Generalizability** (0-10)
   - Pattern applicability
   - Principle-based design
   - Minimal example-dependency

4. **Innovation** (0-10)
   - Novel pattern combinations
   - Creative constraint application
   - Unexpected coherence

### Phase 5: Constraint Design

**Constraint Framework:**

Constraints should **enable** creativity, not limit it:

```
Good Constraint Pattern:
  Type: [Structural|Qualitative|Meta]
  Statement: "Must [requirement]"
  Enables: [What creativity it unlocks]
  Prevents: [What anti-pattern it avoids]
  Measurable: [How to verify compliance]
```

**Constraint Categories:**

**Must Include (Required):**
- Core structural elements
- Meta-awareness markers
- Quality baseline requirements

**Should Apply (Recommended):**
- Best practice patterns
- Proven frameworks
- Meta-level capabilities

**Cannot (Prohibited):**
- Known anti-patterns
- Quality-reducing approaches
- Over-specific implementations

### Phase 6: Meta-Instructions

**Generator Guidance Template:**

```markdown
## Meta-Instructions for Generators

When creating content for this spec:

### 1. Structure-First Thinking
- Identify pattern to apply: [WHICH?]
- Understand framework: [HOW?]
- Plan abstraction level: [WHAT LEVEL?]

### 2. Pattern Application
- Use [PATTERN_1] for [ASPECT_1]
- Apply [FRAMEWORK_2] to [ASPECT_2]
- Integrate [PRINCIPLE_3] throughout

### 3. Meta-Awareness Integration
- Reflect on your generation process
- Note which patterns you're applying
- Identify improvement opportunities
- Document evolution potential

### 4. Quality Self-Assessment
- Evaluate against each quality dimension
- Provide scores with justification
- Suggest specific improvements
- Document generalizability

### 5. Evolution Enablement
- Add hooks for future enhancement
- Document design rationale
- Acknowledge trade-offs
- Provide upgrade paths
```

## Pattern Library Integration

**Successful Patterns Catalog:**

```markdown
### Pattern: [Name]

**Abstract Structure:**
```
[Generalizable template]
```

**Applications:** [Where it works well]
**Characteristics:** [Key features]
**Quality Impact:** [Effect on metrics]
**Generalizability:** [High|Medium|Low]

**Meta-Note:** [Why this pattern is effective]
```

**Pattern Evolution:**

Patterns can evolve:
- Simple → Complex (elaboration)
- Specific → General (abstraction)
- Single → Composite (combination)
- First-order → Meta (recursion)

## Validation Framework

**Spec Validation Checklist:**

```
Structure:
  ✓ Clear overview with abstract description
  ✓ Defined structural framework
  ✓ Multiple generation patterns
  ✓ Measurable quality dimensions
  ✓ Creative constraints that enable
  ✓ Meta-instructions for generators
  ✓ Evolution hooks

Quality:
  ✓ Patterns are generalizable
  ✓ Minimal example dependency
  ✓ Principle-based reasoning
  ✓ Meta-awareness required
  ✓ Success criteria objective

Meta-Prompting:
  ✓ Structure-oriented throughout
  ✓ Abstract frameworks defined
  ✓ Efficient reasoning enabled
  ✓ Self-improvement capable

Usability:
  ✓ Can generate with /infinite-meta
  ✓ Produces measurably good results
  ✓ Enables uniqueness and quality
  ✓ Can evolve further
```

**Test Generation:**

```
After creating spec:
1. Generate 3-5 test iterations
2. Measure quality dimensions
3. Validate pattern effectiveness
4. Refine spec if needed
5. Document actual vs expected
```

## Example Pattern Extraction

### From Iterations → To Pattern

**Input: 15 iterations analyzed**

Observation:
- 12/15 use clear phase separation
- 13/15 include meta-reflection
- 10/15 apply specific architectural pattern
- 11/15 self-assess quality

**Extracted Pattern:**

```markdown
### Pattern: Meta-Aware Phased Generation

**Structure:**
```
Component:
  Phase 1: [Preparation]
  Phase 2: [Implementation]
  Phase 3: [Reflection]
  Meta: [Self-assessment]
```

**Quality Correlation:**
- Iterations using this: avg quality 8.3
- Iterations not using this: avg quality 6.7
- Impact: +24% quality

**Generalizability:** High
- Works across domains
- Principle-based
- Adaptable structure
```

## Usage in /generate-spec

This meta-prompt is used by `/generate-spec`:

1. Analyze sources using pattern extraction
2. Synthesize spec using generation framework
3. Design quality dimensions from analysis
4. Create constraints that enable creativity
5. Write meta-instructions for generators
6. Validate against checklist
7. Test with small generation batch
8. Refine and finalize

## Evolution of This Meta-Prompt

**Current Capabilities:**
- Pattern discovery framework
- Multi-mode generation strategies
- Quality dimension extraction
- Constraint design principles

**Future Enhancements:**
- ML-based pattern recognition
- Cross-domain pattern transfer
- Automated validation testing
- Meta-spec generation (specs for specs)

## Meta-Note

This meta-prompt is itself a specification for generating specifications - a meta-spec! It can be improved using the same principles it defines, enabling recursive enhancement of the spec generation process.

---

**Maintained By:** /generate-spec command
**Used By:** /generate-spec when creating new specs
**Evolution:** Updated when new pattern discovery techniques are found
