What Prompt Strategies Does Fabric Support? A Complete Guide to LLM Reasoning Templates
Fabric supports nine built-in prompt strategies including Chain-of-Thought (CoT), Tree-of-Thought (ToT), and Self-Refinement, each stored as JSON files in data/strategies/ and loaded dynamically by the StrategiesManager.
Fabric, the open-source AI framework maintained by Daniel Miessler, implements a prompt strategies system that controls how large language models approach reasoning tasks. These strategies are predefined prompt templates stored as JSON files, which the system discovers and injects at runtime without requiring code changes. The architecture allows users to switch between reasoning paradigmsâfrom direct answering to complex multi-path explorationâby simply specifying a strategy name.
How Fabric's Strategy System Works
At the core of the system lies the StrategiesManager defined in internal/plugins/strategy/strategy.go. This manager handles discovery, loading, and runtime injection of prompt templates.
Strategy Discovery and Loading
The LoadAllFiles() method walks the strategies directory (default $HOME/.config/fabric/strategies) and calls LoadStrategy() for every .json file encountered. Each file unmarshals into a Strategy struct containing Name, Description, and Prompt fields, populating a map[string]Strategy registry.
During initialization, PopulateDB() clones the repository's data/strategies/ folder into the user's local configuration directory, ensuring the built-in templates are available immediately after installation. You can customize the search path via the strategies_git_repo_folder_question configuration variable.
Runtime Injection in Chat Processing
When a chat request includes a strategyName parameter, the server logic in internal/server/chat.go retrieves the matching Strategy object and prepends its Prompt content to the LLM request. This happens before the request is sent to the underlying model, effectively wrapping the user's query with the selected reasoning framework.
The Nine Built-In Prompt Strategies
Fabric ships with nine strategies covering major academic prompting techniques. Each strategy is a standalone JSON file in the data/strategies/ directory.
-
standard (
standard.json): Direct answering without explanation.
Prompt:Answer the question directly without any explanation or reasoning. -
cot (
cot.json): ChainâofâThought reasoning.
Prompt:Think step by step to answer the question. Return the final answer in the required format. -
aot (
aot.json): AtomâofâThought decomposition.
Prompt:To solve this problem, break it down into the smallest independent 'atomic' subâproblems. ⌠Return the final answer in the required format. -
ltm (
ltm.json): LeastâtoâMost ordering.
Prompt:Break down the problem into simpler subâproblems from easiest to hardest; answer concisely at each step. -
tot (
tot.json): TreeâofâThought exploration.
Prompt:Generate multiple reasoning paths briefly and select the best one. -
cod (
cod.json): ChainâofâDraft minimal reasoning.
Prompt:Think step by step, keeping a minimal draft (5 words max) for each step. Return the final answer in the required format. -
selfârefine (
self-refine.json): Iterative selfâcorrection.
Prompt:Provide an initial concise answer, critique it briefly, and refine if necessary. -
selfâconsistent (
self-consistent.json): Multiâpath consistency checking.
Prompt:Provide multiple reasoning paths and select the most consistent answer. -
reflexion (
reflexion.json): Answer with integrated critique.
Prompt:Answer concisely, critique your reasoning briefly, and provide a refined answer.
Listing Available Strategies
To see which strategies are currently loaded in your Fabric installation, use the CLI flag --liststrategies:
fabric --liststrategies
This command invokes StrategiesManager.ListStrategies() from internal/plugins/strategy/strategy.go, which iterates the strategy map and prints each entry's Name and Description. You can also use fabric --liststrategies=true for the same output in scripting contexts.
Creating Custom Prompt Strategies
Fabric's architecture supports hot-loading of custom strategies without recompilation. Any valid JSON file placed in the strategies directory becomes immediately available after restart.
Strategy File Format
Create a new file at $HOME/.config/fabric/strategies/my-strategy.json with the following structure:
{
"Name": "my-strategy",
"Description": "Custom reasoning pattern for specific tasks",
"Prompt": "Analyze the input using the specific framework: 1) Identify entities, 2) Map relationships, 3) Return structured JSON."
}
The Name field must match the filename (without extension) for the StrategiesManager to locate it correctly via LoadStrategy().
Loading Custom Strategies
After placing the JSON file in the directory, restart the Fabric server. The next invocation of fabric --liststrategies will display your custom entry alongside the nine built-in options. When specified via strategyName, your custom prompt template is injected into the chat flow exactly like the native strategies defined in data/strategies/.
Summary
- Fabric implements nine built-in prompt strategies ranging from direct answering (standard) to complex reasoning trees (ToT) and self-correction loops (reflexion).
- The
StrategiesManagerininternal/plugins/strategy/strategy.gohandles discovery viaLoadAllFiles()and runtime injection ininternal/server/chat.go. - Strategies are stored as JSON files in
data/strategies/(repository) and$HOME/.config/fabric/strategies(user config), following theStrategy{Name, Description, Prompt}schema. - Users can list strategies with
fabric --liststrategiesand add custom ones by dropping new JSON files into the local strategies folder.
Frequently Asked Questions
How do I switch between prompt strategies in Fabric?
Pass the strategy name via the strategyName parameter in your API request or CLI command. The system calls StrategiesManager to load the corresponding JSON file and injects its Prompt field into the LLM context before processing your query.
Can I modify the built-in prompt strategies?
While you should not edit files in the repository's data/strategies/ directly, you can override behavior by creating a JSON file with the same name in $HOME/.config/fabric/strategies/. Fabric prioritizes user configuration directories, so your version will shadow the built-in template.
What is the difference between CoT and CoD strategies in Fabric?
Chain-of-Thought (cot) encourages detailed step-by-step reasoning with full explanations, while Chain-of-Draft (cod) forces the model to condense each reasoning step to a maximum of five words, reducing token usage and latency while maintaining accuracy.
Do custom strategies require restarting the Fabric server?
Yes. Although LoadAllFiles() scans the directory at startup, the current implementation in internal/plugins/strategy/strategy.go does not support hot-reloading without a restart. Place your new JSON file in $HOME/.config/fabric/strategies/ and restart the service to register the strategy.
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 â