How to List Available Patterns in Fabric: CLI Guide and Source Code Walkthrough
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, 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 (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:
fabric --listpatterns
Or use the short flag:
fabric -l
For machine-readable output—useful in shell scripts or completion systems—add the --shell-complete-list flag:
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, the GetNames() method (lines 195–210) implements the retrieval logic. This function:
- Reads the built-in pattern directory bundled with Fabric.
- Merges any custom patterns found in
~/.config/fabric/patterns(or the directory specified by$FABRIC_PATH). - Returns a deduplicated slice of pattern names.
The handleListingCommands function in 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 lines 39–52, the error handling suggests running:
fabric --setup
Or, if you have added custom Markdown files and need to refresh the index:
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.
- Run setup: Execute
fabric --setupto download and install the default pattern collection from the repository. - Check the path: Verify that
$FABRIC_PATHpoints to the correct directory (default is~/.config/fabric). - Update the index: After manually adding
.mdfiles to the patterns directory, runfabric --updatepatternsto re-index.
Summary
- Command: Use
fabric --listpatterns(or-l) to enumerate all available patterns. - Implementation: The flag triggers
handleListingCommandsininternal/cli/listing.go, which queriesGetNames()frominternal/plugins/db/fsdb/patterns.go. - Storage: Patterns reside in
~/.config/fabric/patternsas Markdown files, merged with built-in defaults. - Troubleshooting: Run
fabric --setupif no patterns appear, andfabric --updatepatternsafter 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 and execute the pattern enumeration workflow in 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 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:
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.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →