Seamlessly access and utilize the community-driven prompts from the Fabric project directly within Emacs using Gptel. Enhance your LLM interactions with a rich library of curated system prompts.
- **Sparse Checkout:** Efficiently fetches only the necessary `patterns` subdirectory from the Fabric repository using Git sparse checkout.
- **Pattern Filtering:** Automatically identifies and lists only patterns that have a valid `system.md` file.
- **Completing Read Integration:** Select patterns easily using Emacs’ built-in completion (like Vertico, Ivy, Helm, etc.).
- **Seamless Gptel Integration:** Applies the selected Fabric system prompt to your current Gptel conversation without modifying your default `gptel-system-message`.
- **Easy Syncing:** Provides a command to quickly update your local pattern cache from the Fabric upstream.
While installation via MELPA is the recommended method (once available), you can also install manually.
In your packages.el, after your gptel fetch:
(package! fabric-gpt.el
:recipe (:host github :repo "/rajp152k/fabric-gpt.el"))
In your config.el, after your gptel config:
(use-package! fabric-gpt.el
:after gptel
:config
;; Set the root directory where fabric patterns will be cached.
;; This should be outside your Emacs configuration directory.
(setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example path
(fabric-gpt.el-sync-patterns))
- Clone the repository:
git clone https://github.com/rajp152k/fabric-gpt.el.git ~/.emacs.d/site-lisp/fabric-gpt.el
(Replace `~/.emacs.d/site-lisp/` with your preferred location)
- Add the directory to your `load-path` and require the package in your Emacs config:
(add-to-list 'load-path "~/.emacs.d/site-lisp/fabric-gpt.el") ;; Adjust path (require 'fabric-gpt.el) ;; Configure the root directory for patterns (setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example path ;; Sync patterns on startup (optional, but recommended) (fabric-gpt.el-sync-patterns)
This is the primary command for applying a Fabric pattern to your Gptel interaction.
- Invoke `M-x fabric-gpt.el-send` (or your bound keybinding).
- A completing read prompt will appear, listing available Fabric patterns.
- Select the desired pattern.
- The system prompt from the selected pattern’s `system.md` file will be temporarily applied to the next Gptel request sent from the current buffer.
- Your existing buffer content (before the cursor) will be sent as the user message, preceded by the selected system prompt.
I would recommend you bind (fabric-gpt.el-send)
to something handy, I use “leader i g f f” as it is mnemonically aligned with what gptel exposes via “leader i g [hsm]”.
;; <– Add a path to a screenshot or GIF here
This command fetches the latest patterns from the upstream Fabric repository.
Invoke `M-x fabric-gpt.el-sync-patterns` (or your bound keybinding). This will:
- Clone or update the Fabric repository in the directory specified by `fabric-gpt.el-root`.
- Perform a sparse checkout to only retrieve the `patterns` subdirectory.
- Populate the list of available patterns by checking for `system.md` files.
I bind (fabric-gpt.el-sync-patterns)
to “leader i g f s” to fetch any new patterns from the fabric upstream.
These are pulled into your <fabric-gpt.el-root>/fabric
directory.
fabric-gpt.el-root
: **Required.** A string specifying the root directory where the Fabric repository will be cloned and patterns cached. Make sure this directory exists and is writable by Emacs.(setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example
Suggestions, ideas, bug reports, and PRs are welcome! I’m still refining this package and appreciate any feedback.
This project is licensed under the GNU General Public License Version 3.