# What Is the Fabric AI Framework? A Developer's Guide to the Open-Source Go CLI

> Discover the Fabric AI framework an open-source Go CLI and REST API. Treat AI prompts as reusable Patterns and integrate with OpenAI Anthropic and Ollama seamlessly.

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

---

**The Fabric AI framework is an open-source Go-based CLI and REST API that treats AI prompts as reusable Patterns, enabling users to augment workflows across multiple AI vendors including OpenAI, Anthropic, and local Ollama instances.**

The Fabric AI framework, maintained by Daniel Miessler at `danielmiessler/fabric`, provides a modular architecture for integrating large language models into automated workflows. Unlike standard chat interfaces, Fabric structures interactions through version-controlled Markdown Patterns and JSON strategies, offering both a command-line tool and a programmable HTTP API for cognitive task automation.

## Core Architecture of the Fabric AI Framework

### CLI and Command Dispatch

The entry point resides in [`cmd/fabric/main.go`](https://github.com/danielmiessler/fabric/blob/main/cmd/fabric/main.go), which initializes the command-line interface and dispatches execution to `cli.Cli()`. This layer parses input flags, loads configuration from `~/.config/fabric`, and constructs a `domain.ChatRequest` that drives the processing pipeline.

### Core Engine and Chat Session Management

The central orchestration logic lives in [`internal/core/chatter.go`](https://github.com/danielmiessler/fabric/blob/main/internal/core/chatter.go), implementing the `core.Chatter` struct. This component builds chat sessions by aggregating system messages loaded from Patterns, prepending strategy modifiers, and managing response streaming to the terminal. According to the source code, the engine also handles special file-change patches when Patterns are configured to modify code files automatically.

### Plugin System and Vendor Abstraction

Fabric abstracts AI providers through a uniform `Vendor` interface defined in [`internal/plugins/ai/vendor.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendor.go), which specifies methods `Send`, `SendStream`, and `ListModels`. The vendor manager in [`internal/plugins/ai/vendors.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendors.go) handles registration, model discovery, and case-insensitive lookups for providers including OpenAI, Anthropic, Gemini, Azure, Bedrock, and Ollama. This plug-in architecture enables swapping AI backends without modifying application logic.

### Pattern Store and Prompt Strategies

Patterns are Markdown files stored in `data/patterns/`, each containing a [`system.md`](https://github.com/danielmiessler/fabric/blob/main/system.md) file (and optionally [`user.md`](https://github.com/danielmiessler/fabric/blob/main/user.md)) that defines AI behavior. Users extend functionality by adding custom patterns to `~/.config/fabric/patterns`, which persist across updates. Additionally, JSON-defined strategies in `data/strategies/`—such as [`cot.json`](https://github.com/danielmiessler/fabric/blob/main/cot.json) for chain-of-thought or [`tot.json`](https://github.com/danielmiessler/fabric/blob/main/tot.json) for tree-of-thought—prepend reasoning instructions to system prompts, enhancing output quality without altering base Patterns.

### REST API Server

The framework exposes all CLI capabilities via HTTP through [`internal/server/serve.go`](https://github.com/danielmiessler/fabric/blob/main/internal/server/serve.go), which implements a Gin-based server. This REST layer enables integration into existing applications through endpoints for chat completion, pattern CRUD operations, model listing, and YouTube extraction.

## Key Source Files and Implementation Details

Understanding the codebase requires familiarity with these critical files:

- **[`cmd/fabric/main.go`](https://github.com/danielmiessler/fabric/blob/main/cmd/fabric/main.go)** – Entry point that initializes the CLI environment and calls `cli.Cli()`.
- **[`internal/core/chatter.go`](https://github.com/danielmiessler/fabric/blob/main/internal/core/chatter.go)** – Central request processing, streaming logic, and file-change patch application.
- **[`internal/plugins/ai/vendor.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendor.go)** – Defines the `Vendor` interface contract for all AI providers.
- **[`internal/plugins/ai/vendors.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendors.go)** – Manager handling vendor registration and model name resolution.
- **[`internal/plugins/template/template.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/template/template.go)** – Template engine supporting variables (`{{variable}}`) and plugin filters (`{{plugin:text:upper:hello}}`).
- **[`internal/server/serve.go`](https://github.com/danielmiessler/fabric/blob/main/internal/server/serve.go)** – Gin server setup exposing REST endpoints at `/api/v1/chat`.
- **`data/patterns/`** – Built-in Markdown Patterns defining default AI behaviors.
- **`data/strategies/`** – JSON strategy files containing prompt modifiers for reasoning techniques.

## Practical Usage Examples

### Running Built-in Patterns from the CLI

```bash

# Summarize clipboard content (macOS example)

pbpaste | fabric -p summarize

```

The CLI loads [`data/patterns/summarize/system.md`](https://github.com/danielmiessler/fabric/blob/main/data/patterns/summarize/system.md), sends the piped content to the configured default model, and streams the summary output to stdout.

### Applying Chain-of-Thought Strategies

```bash

# Apply chain-of-thought reasoning while summarizing

pbpaste | fabric --strategy cot -p summarize

```

The [`cot.json`](https://github.com/danielmiessler/fabric/blob/main/cot.json) strategy file prepends step-by-step reasoning instructions to the system prompt, forcing the model to articulate its thought process before generating the final summary.

### Using Template Variables and Plugins

```bash

# Pass variables to a pattern template

fabric -p my-pattern -v name=alice -v project=fabric

```

Within the Pattern, the template engine processes expressions like `{{plugin:text:upper:{{name}}}}` through the `text` plugin implemented in [`template.go`](https://github.com/danielmiessler/fabric/blob/main/template.go), transforming "alice" into "ALICE" before sending to the AI vendor.

### Calling the REST API

```bash

# Start the server (default port 8080)

fabric --serve

# Post a chat request via curl

curl -X POST http://localhost:8080/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{"pattern":"summarize","message":"Quarterly earnings report..."}'

```

The Gin router in [`serve.go`](https://github.com/danielmiessler/fabric/blob/main/serve.go) handles the request via `NewChatHandler`, returning JSON responses that mirror the CLI output format.

### Creating Custom Patterns

```bash
mkdir -p ~/.config/fabric/patterns/my-report
cat > ~/.config/fabric/patterns/my-report/system.md <<'EOF'
You are a concise technical writer.
Write a one-paragraph report about the following:
{{input}}
EOF

```

Custom patterns stored in the user configuration directory remain independent of repository updates, ensuring portability across Fabric versions.

## Summary

- **Fabric AI framework** structures AI interactions through reusable Markdown Patterns and JSON-defined Strategies rather than ad-hoc prompts.
- The architecture centers on [`internal/core/chatter.go`](https://github.com/danielmiessler/fabric/blob/main/internal/core/chatter.go) for session orchestration and [`internal/plugins/ai/vendor.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendor.go) for provider abstraction.
- Users interact via the CLI entry point at [`cmd/fabric/main.go`](https://github.com/danielmiessler/fabric/blob/main/cmd/fabric/main.go) or the REST API defined in [`internal/server/serve.go`](https://github.com/danielmiessler/fabric/blob/main/internal/server/serve.go).
- Advanced templating in [`internal/plugins/template/template.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/template/template.go) supports variable substitution and text transformation plugins.
- The framework supports multiple AI vendors—OpenAI, Anthropic, Gemini, Azure, Bedrock, and Ollama—through a unified interface.

## Frequently Asked Questions

### What programming language is Fabric written in?

Fabric is implemented entirely in Go (Golang), providing a statically-linked binary with no runtime dependencies. The codebase leverages Go's concurrency primitives to handle streaming AI responses and concurrent plugin operations efficiently.

### How does Fabric handle different AI providers?

The framework uses a `Vendor` interface defined in [`internal/plugins/ai/vendor.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendor.go) to normalize provider-specific implementations. The vendor manager in [`internal/plugins/ai/vendors.go`](https://github.com/danielmiessler/fabric/blob/main/internal/plugins/ai/vendors.go) supports case-insensitive model name resolution across OpenAI, Anthropic, Gemini, Azure, Bedrock, and local Ollama instances, allowing users to switch models via the `--model` flag without changing workflow definitions.

### Where are custom user patterns stored?

User-created patterns reside in `~/.config/fabric/patterns/` as self-contained directories containing [`system.md`](https://github.com/danielmiessler/fabric/blob/main/system.md) and optional [`user.md`](https://github.com/danielmiessler/fabric/blob/main/user.md) files. This filesystem-based storage separates user customizations from the core installation, preventing package updates from overwriting personal workflows.

### Can Fabric modify code files automatically?

Yes. The `core.Chatter` implementation in [`internal/core/chatter.go`](https://github.com/danielmiessler/fabric/blob/main/internal/core/chatter.go) includes specialized logic to parse and apply file-change patches when using Patterns designed for code generation or refactoring. This enables automated codebase modifications directly through the CLI or REST API by processing the AI's structured response into concrete file system changes.