How Fabric Patterns Are Organized: Directory Structure, Loading, and Customization

Fabric Patterns are organized as file-system directories under data/patterns/, where each pattern contains a required system.md file defining the LLM role and an optional user.md template, synchronized to ~/.config/fabric/patterns by the Patterns Loader and exposed via REST API for CLI and web UI consumption.

Fabric Patterns in the danielmiessler/fabric repository are reusable, prompt-driven building blocks that power the framework's command-line and web-interface operations. Their organization follows a strict directory-based convention that enables version control, easy customization, and seamless integration with the Go-based backend and Svelte frontend.

Directory Layout and File Structure

Fabric stores all official patterns in the data/patterns/ directory at the repository root. Each pattern lives in its own subfolder named after the pattern identifier.

The file structure follows this convention:

  • data/patterns/<pattern-name>/system.md — The system prompt that defines the LLM's role, instructions, and workflow logic.
  • data/patterns/<pattern-name>/user.md — An optional user prompt supplying default input templates or example data.
  • scripts/pattern_descriptions/pattern_descriptions.json — A JSON manifest storing human-readable descriptions and tags for UI filtering.

For example, the analyze_paper pattern resides at data/patterns/analyze_paper/system.md, with its optional user template at data/patterns/analyze_paper/user.md. The metadata entry in scripts/pattern_descriptions/pattern_descriptions.json provides the description and categorical tags that appear in the pattern selector.

Runtime Pattern Loading and Synchronization

When Fabric initializes, the Patterns Loader (internal/tools/patterns_loader.go) orchestrates the synchronization of patterns from the upstream repository to your local machine.

The PopulateDB method executes the following steps:

  1. Clones the upstream Fabric repository (or a custom Git URL) into a temporary workspace.
  2. Copies the data/patterns/ tree into the user's configuration directory at ~/.config/fabric/patterns.
  3. Merges any custom patterns found in ~/.config/fabric/custompatterns/ without overwriting them during updates.
  4. Generates unique_patterns.txt, an auxiliary file listing every available pattern name.

The loader persists patterns using a lightweight file-system database abstraction (fsdb.PatternsEntity). This storage layer maintains the pattern contents locally, enabling offline operation and fast retrieval.

API and Web UI Consumption

The Fabric server exposes loaded patterns via REST endpoints defined in internal/server/patterns.go. Key routes include:

  • GET /patterns/names — Returns the complete list of available pattern names.
  • GET /patterns/:name — Returns the raw system.md content for the specified pattern.

The web UI consumes these endpoints through the Svelte store located at web/src/lib/store/pattern-store.ts. This store fetches the JSON description manifest first, then retrieves individual system prompts via the API, merging both sources into a unified Pattern object:

{
  Name: string;          // Folder name identifier
  Description: string;   // Human-readable summary from JSON
  Pattern: string;       // Raw system prompt content
  tags: string[];        // Categories for UI filtering
}

The UI renders this data in the pattern selector and tag filter panels, injecting the selected pattern's system prompt into the chat interface when users initiate conversations.

Extending and Customizing Fabric Patterns

You can extend Fabric's pattern library through three primary methods:

Add a New Official Pattern Create a new directory under data/patterns/<my_pattern>/ containing a system.md file. Append an entry to scripts/pattern_descriptions/pattern_descriptions.json with the patternName, description, and tags array to register it in the UI catalog.

Create Local Custom Patterns Place pattern folders in ~/.config/fabric/custompatterns/. The loader's PersistPatterns method preserves these during updates, ensuring your custom workflows survive pattern cache refreshes.

Refresh the Pattern Cache After adding or modifying patterns, run fabric --updatepatterns or restart the Fabric server to trigger the loader and update the local database.


# List all available patterns

fabric --listpatterns

# Run a specific pattern against input data

fabric --pattern analyze_paper --input research_paper.pdf

# Add a custom pattern manually

mkdir -p ~/.config/fabric/custompatterns/writing_assistant
echo "# You are a technical editor..." > ~/.config/fabric/custompatterns/writing_assistant/system.md

fabric --updatepatterns
// Access patterns programmatically in Go
import (
    "github.com/danielmiessler/fabric/internal/plugins/db/fsdb"
)

func loadPatternContent(patternName string) (string, error) {
    patterns := fsdb.NewPatternsEntity("/home/user/.config/fabric/patterns")
    content, err := patterns.Load(patternName + "/system.md")
    return content, err
}
// Use patterns in the Svelte web UI
import { patternAPI, patterns } from '$lib/store/pattern-store';
import { get } from 'svelte/store';

// Initialize on app start
await patternAPI.loadPatterns();

// Find and apply a specific pattern
const flashcardPattern = get(patterns).find(p => p.Name === 'create_flash_cards');
if (flashcardPattern) {
    setSystemPrompt(flashcardPattern.Pattern);
}

Summary

Frequently Asked Questions

Where are Fabric Patterns stored on my local machine?

After running Fabric for the first time, patterns synchronize to ~/.config/fabric/patterns/ on your local file system. Custom patterns you create manually should be placed in ~/.config/fabric/custompatterns/, which the loader preserves during updates according to the source logic in internal/tools/patterns_loader.go.

What is the difference between system.md and user.md in Fabric Patterns?

The system.md file contains the system prompt that defines the LLM's role, behavioral constraints, and processing instructions—this file is required for every pattern. The user.md file is optional and provides a default user prompt template or example input structure that pre-populates the conversation context when the pattern loads.

How do I add a custom pattern to Fabric without modifying the upstream repository?

Create a new folder in ~/.config/fabric/custompatterns/<pattern_name>/ containing your system.md file. The Patterns Loader merges this directory during initialization without overwriting it when syncing upstream changes. Run fabric --updatepatterns to refresh the local database and make your pattern available via CLI and web UI.

How does the Fabric web UI know which descriptions and tags to display for each pattern?

The Svelte frontend loads scripts/pattern_descriptions/pattern_descriptions.json through the API, which maps pattern names to their descriptions and categorical tags. The pattern-store.ts file merges this metadata with the raw system prompt content retrieved from fsdb.PatternsEntity, creating a complete Pattern object used for rendering the selector interface and filter panels.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →