# Built-in Patterns Reference

## Purpose and Scope

This reference catalogs all built-in patterns shipped with Fabric, organized into functional categories. Each pattern entry includes its name, description, and primary tags. This page serves as a discovery tool to help users find the appropriate pattern for their specific use case.

The pattern catalog is automatically generated from the filesystem using `scripts/pattern_descriptions/extract_patterns.py` and stored in two JSON metadata files:

- `scripts/pattern_descriptions/pattern_descriptions.json` - Contains descriptions and tags.
- `scripts/pattern_descriptions/pattern_extracts.json` - Contains the first 500 words of each pattern's `system.md` file.

## Pattern Organization System

Patterns are organized into 24 primary categories based on their functional purpose. The category taxonomy is defined in the `suggest_pattern` system prompt.

### Pattern Taxonomy and Distribution

The following diagram illustrates the functional grouping of Fabric's pattern library:

```
Specialized Patterns

GAMING
3 patterns

BILL
2 patterns

CREATIVITY
2 patterns

OTHER
1 pattern

Utility Patterns

CONVERSION
11 patterns

VISUALIZE
13 patterns

CLASSIFICATION
1 pattern

Personal & Learning

LEARNING
16 patterns

SELF
23 patterns

WISDOM
9 patterns

WELLNESS
7 patterns

Business & Strategy

BUSINESS
20 patterns

STRATEGY
10 patterns

REVIEW
12 patterns

AI & Meta Patterns

AI
13 patterns

CR_THINKING
20 patterns

RESEARCH
20 patterns

Technical Patterns

DEVELOPMENT
41 patterns

SECURITY
31 patterns

DEVOPS
1 pattern

Content Patterns

ANALYSIS
73 patterns

EXTRACT
50 patterns

SUMMARIZE
18 patterns

WRITING
51 patterns
```

## Pattern Discovery with suggest_pattern

The `suggest_pattern` pattern serves as an intelligent pattern recommender that analyzes user requests and suggests appropriate patterns. It maps natural language intent to specific code-level pattern identifiers.

### Natural Language to Pattern Mapping

```
User Request
(Natural Language)

suggest_pattern
(system.md)

Category
Matching Logic

pattern_descriptions.json
pattern_extracts.json

1-3 Pattern
Recommendations

fabric --pattern [patternName]
```

## Pattern Metadata Structure

Pattern metadata is managed by `extract_patterns.py`. Each pattern entry in `pattern_descriptions.json` follows a structured format:

```json
{
  "patternName": "analyze_claims",
  "description": "Evaluate truth claims by analyzing evidence and logical fallacies.",
  "tags": ["ANALYSIS", "RESEARCH", "CR THINKING"]
}
```

## Core Pattern Categories

### AI Patterns (13 patterns)

Patterns for AI system guidance, prompt engineering, and output evaluation.

| Pattern Name | Description |
| --- | --- |
| `ai` | Provide concise, insightful answers in brief bullets focused on core concepts |
| `create_art_prompt` | Transform concepts into detailed AI art prompts with style references |
| `create_pattern` | Design structured patterns for AI prompts with identity, purpose, steps, output |
| `create_prediction_block` | Format predictions for tracking/verification in markdown prediction logs |
| `extract_mcp_servers` | Identify and extract detailed information about Model Context Protocol servers |
| `generate_code_rules` | Compile best-practice coding rules and guardrails for AI-assisted development |
| `improve_prompt` | Enhance AI prompts by refining clarity and specificity |
| `judge_output` | Evaluate AI outputs for quality and accuracy |
| `suggest_pattern` | Recommend Fabric patterns based on user requirements |

### ANALYSIS Patterns (73 patterns)

Patterns for evaluating content, data, and logical structures.

| Pattern Name | Description | Primary Use Case |
| --- | --- | --- |
| `analyze_claims` | Evaluate truth claims by analyzing evidence and logical fallacies | Fact-checking |
| `analyze_debate` | Analyze debates identifying arguments and emotional intensity | Debate evaluation |
| `analyze_paper` | Analyze scientific papers to identify findings and assess rigor | Research review |
| `analyze_prose` | Evaluate writing quality by rating novelty, clarity, and style | Writing assessment |
| `analyze_sales_call` | Evaluate sales calls analyzing pitch and customer interaction | Sales review |
| `compare_and_contrast` | Create comparisons table highlighting differences and similarities | Comparative analysis |

### DEVELOPMENT Patterns (41 patterns)

Patterns for software development, code review, and technical documentation.

| Pattern Name | Description |
| --- | --- |
| `agility_story` | Generate agile user stories and acceptance criteria in JSON |
| `create_coding_project` | Design coding projects with clear architecture and best practices |
| `ask_uncle_duke` | Expert software dev guidance focusing on Java, Spring, and frontend |
| `create_git_diff_commit` | Generate clear git commit messages and commands for code changes |
| `coding_master` | Explain coding concepts and languages for beginners |

### SECURITY Patterns (31 patterns)

Patterns for cybersecurity analysis, threat modeling, and incident response.

| Pattern Name | Description | Use Case |
| --- | --- | --- |
| `analyze_malware` | Extract indicators, techniques, and detection strategies from malware details | Malware analysis |
| `analyze_email_headers` | Analyze email authentication headers (SPF, DKIM, DMARC) for security | Email security |
| `create_cyber_summary` | Summarize incidents and vulnerabilities into intelligence briefings | Threat Intel |
| `analyze_incident` | Extract key details (attack type, target, remediation) from breach articles | Incident response |
| `create_command` | Generate precise CLI commands for penetration testing tools | Offensive security |

### BUSINESS Patterns (20 patterns)

Patterns for business strategy, financial analysis, and professional communication.

| Pattern Name | Description |
| --- | --- |
| `concall_summary` | Analyze earnings call transcripts for management insights and financial metrics |
| `create_hormozi_offer` | Create business offers using Alex Hormozi's methodology |
| `check_agreement` | Review contracts to identify stipulations and potential issues |
| `create_formal_email` | Compose professional emails with proper tone and structure |

## Pattern Catalog Generation Logic

The pattern catalog is maintained by `extract_patterns.py`

1. **Discovery**: Scans `data/patterns/` or `~/.config/fabric/patterns/`
2. **Extraction**: Reads the `system.md` file and takes the first 500 words
3. **Incremental Update**: Compares found patterns against `pattern_descriptions.json` and `pattern_extracts.json`. If a pattern is new, it appends a new entry with `[Description pending]` and empty tags  
4. **Persistence**: Saves the updated JSON files to the `scripts/pattern_descriptions/` directory

## Usage Syntax

Patterns are invoked via the `fabric` CLI using the `--pattern` or `-p` flag

```
# Standard usage
cat input.txt | fabric --pattern summarize

# Streaming results
fabric --pattern extract_wisdom --stream

# Using specific models
fabric --pattern analyze_claims --model gpt-4-turbo

# Discovering patterns
echo "I need to analyze a server log" | fabric --pattern suggest_pattern
```
