# How to List Available Patterns in Fabric: CLI Guide and Source Code Walkthrough

> Easily list available Fabric patterns using the CLI command fabric --listpatterns or fabric -l. Explore the source code and find patterns in ~/.config/fabric/patterns.

- Repository: [Daniel Miessler 🛡️/fabric](https://github.com/danielmiessler/fabric)
- Tags: how-to-guide
- Published: 2026-02-28

---

**Use the `fabric --listpatterns` (or `fabric -l`) command to display all available patterns stored in `~/.config/fabric/patterns`.**

Fabric, the open-source AI augmentation framework by **danielmiessler/fabric**, organizes reusable AI prompts as "patterns"—Markdown files containing system prompts and logic. Listing these patterns is the first step to leveraging Fabric's pre-built or custom AI workflows. This guide explains the CLI commands, the underlying Go implementation, and how to troubleshoot missing patterns.

## The Primary Method: Using the `--listpatterns` Flag

Fabric exposes pattern enumeration through a dedicated boolean flag defined in the CLI layer.

### Flag Declaration and CLI Structure

In [`internal/cli/flags.go`](https://github.com/danielmiessler/fabric/blob/main/internal/cli/flags.go), the `--listpatterns` flag (short form `-l`) is declared as part of the `Flags` struct at lines 41–42. This boolean flag signals the application to execute the listing workflow rather than processing input through a pattern.

When the CLI parses arguments, it routes control to `handleListingCommands` in [`internal/cli/listing.go`](https://github.com/danielmiessler/fabric/blob/main/internal/cli/listing.go) (lines 32–55). This dispatcher checks if `ListPatterns` is true and, if so, queries the pattern database for available names.

### Command Execution Examples

Run the following to see a formatted list of all patterns:

```bash
fabric --listpatterns

```

Or use the short flag:

```bash
fabric -l

```

For machine-readable output—useful in shell scripts or completion systems—add the `--shell-complete-list` flag:

```bash
fabric --listpatterns --shell-complete-list

```

This emits one pattern name per line without decorative headers.

## How Pattern Listing Works Under the Hood

The CLI does not scan the filesystem directly; it delegates to an abstraction layer that manages both built-in and user-defined patterns.

### The Database Query Layer

In [`internal/plugins/db/fsdb/patterns.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/db/fsdb/patterns.go), the `GetNames()` method (lines 195–210) implements the retrieval logic. This function:

1. Reads the built-in pattern directory bundled with Fabric.
2. Merges any custom patterns found in `~/.config/fabric/patterns` (or the directory specified by `$FABRIC_PATH`).
3. Returns a deduplicated slice of pattern names.

The `handleListingCommands` function in [`listing.go`](https://github.com/danielmiessler/fabric/blob/main/listing.go) then calls `ListNames()` to format and print these results to stdout.

### Output Formatting and Edge Cases

If no patterns are detected, the CLI prints a help block directing users to initialize the pattern library. As seen in [`listing.go`](https://github.com/danielmiessler/fabric/blob/main/listing.go) lines 39–52, the error handling suggests running:

```bash
fabric --setup

```

Or, if you have added custom Markdown files and need to refresh the index:

```bash
fabric --updatepatterns

```

## Troubleshooting: When No Patterns Appear

If `fabric --listpatterns` returns an empty list or a "patterns not found" message, the pattern database is likely uninitialized or misconfigured.

1. **Run setup**: Execute `fabric --setup` to download and install the default pattern collection from the repository.
2. **Check the path**: Verify that `$FABRIC_PATH` points to the correct directory (default is `~/.config/fabric`).
3. **Update the index**: After manually adding `.md` files to the patterns directory, run `fabric --updatepatterns` to re-index.

## Summary

- **Command**: Use `fabric --listpatterns` (or `-l`) to enumerate all available patterns.
- **Implementation**: The flag triggers `handleListingCommands` in [`internal/cli/listing.go`](https://github.com/danielmiessler/fabric/blob/main/internal/cli/listing.go), which queries `GetNames()` from [`internal/plugins/db/fsdb/patterns.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/db/fsdb/patterns.go).
- **Storage**: Patterns reside in `~/.config/fabric/patterns` as Markdown files, merged with built-in defaults.
- **Troubleshooting**: Run `fabric --setup` if no patterns appear, and `fabric --updatepatterns` after adding custom files.

## Frequently Asked Questions

### What is the difference between `-l` and `--listpatterns`?

There is no functional difference; `-l` is the short alias for `--listpatterns`. Both flags trigger the same boolean option in [`internal/cli/flags.go`](https://github.com/danielmiessler/fabric/blob/main/internal/cli/flags.go) and execute the pattern enumeration workflow in [`internal/cli/listing.go`](https://github.com/danielmiessler/fabric/blob/main/internal/cli/listing.go).

### Where does Fabric store pattern files?

By default, Fabric stores patterns in `~/.config/fabric/patterns`. This path can be overridden by setting the `$FABRIC_PATH` environment variable. The storage implementation in [`internal/plugins/db/fsdb/patterns.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/db/fsdb/patterns.go) reads both this directory and the built-in pattern directory bundled with the binary.

### How do I add custom patterns to the list?

Create a new Markdown file in `~/.config/fabric/patterns/` (or your custom `$FABRIC_PATH` directory). After adding the file, run `fabric --updatepatterns` to re-index the database. The next time you run `fabric --listpatterns`, your custom pattern will appear alongside the built-in ones.

### Can I filter the pattern list to show only specific patterns?

The standard `fabric --listpatterns` command does not support filtering by name or tag. However, you can pipe the output to standard Unix tools like `grep` or `fzf` for interactive filtering:

```bash
fabric --listpatterns | grep "summarize"

```

For programmatic use, the `--shell-complete-list` flag provides a plain list ideal for parsing with `awk`, `sed`, or shell completion scripts.