aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <59291+fcuny@users.noreply.github.com>2025-02-28 19:19:53 -0800
committerFranck Cuny <59291+fcuny@users.noreply.github.com>2025-02-28 19:19:53 -0800
commitb9b5aaea288ad81de679cae9eacacbac73e87cff (patch)
tree5e32d667d05182f98eff54665b1f48f5d6c025c2
parent🤖 Add LLM tooling and prompts for Git workflow automation (diff)
downloadinfra-b9b5aaea288ad81de679cae9eacacbac73e87cff.tar.gz
🚀 Refactor LLM config: Move to standardized templates and improve setup
- Migrated prompts from text files to YAML templates in `.config/llm/templates/` directory - Updated fish shell aliases to use the new template system with `-t` flag instead of reading files - Enhanced justfile's `llm` target with proper Claude model setup and 1Password integration - Added `LLM_USER_PATH` environment variable for consistent configuration path - Fixed PR prompt format to better organize content and remove issue resolution section - Updated Nix configuration to support the new file structure The changes standardize our LLM prompt system and make it more maintainable, while improving the setup experience for new users. 🧰
-rw-r--r--configs/llm/templates/commit-prompt.yaml23
-rw-r--r--configs/llm/templates/pr-prompt.yaml14
-rw-r--r--configs/prompts/commit-system-prompt.txt20
-rw-r--r--configs/prompts/pr-prompt.txt12
-rw-r--r--justfile7
-rw-r--r--nix/users/fcuny/llm.nix18
6 files changed, 54 insertions, 40 deletions
diff --git a/configs/llm/templates/commit-prompt.yaml b/configs/llm/templates/commit-prompt.yaml
new file mode 100644
index 0000000..780375e
--- /dev/null
+++ b/configs/llm/templates/commit-prompt.yaml
@@ -0,0 +1,23 @@
+prompt: >
+ Write a concise, informative commit message for these changes:
+ - Review the whole context of the diff carefully to see what effect the change would have on the rest of the code and explain that. Be specific about the effect.
+ - Do not guess about intent.
+ - The goal of this commit message is that someone familiar with the codebase, but not with these changes would understand why the changes were made and what was changed.
+ - The first line should be a short summary of the changes
+ - Explain the 'why' behind changes
+ - Use bullet points for multiple changes
+ - Tone: Use some emojis, be funny, expressive, but stay professional
+ - If there are no changes, or the input is blank - then return a blank string
+
+ Think carefully about what would be most helpful to someone trying to understand the intent of this commit before you write your commit message. Your commit message will be used as an example to train other team members about the content of a good commit message.
+
+ The output format should be:
+
+ Summary of changes
+ - changes
+ - changes
+ and so on
+
+ What you write will be passed directly to git commit -m "[message]"
+
+ Text to use for the commit message: $input
diff --git a/configs/llm/templates/pr-prompt.yaml b/configs/llm/templates/pr-prompt.yaml
new file mode 100644
index 0000000..4c13c0d
--- /dev/null
+++ b/configs/llm/templates/pr-prompt.yaml
@@ -0,0 +1,14 @@
+prompt: >
+ Write a clear, informative pull request message in markdown:
+
+ * Start with a summary
+ * Remember to mention the files that were changed, and what was changed
+ * Explain the 'why' behind changes
+ * Include a bulleted list to outline all of the changes
+ * If there are no changes, or the input is blank - then return a blank string
+
+ Think carefully before you write your pull request body.
+
+ What you write will be passed to create a github pull request
+
+ Text to use for the pull request message: $input
diff --git a/configs/prompts/commit-system-prompt.txt b/configs/prompts/commit-system-prompt.txt
deleted file mode 100644
index 8ddc434..0000000
--- a/configs/prompts/commit-system-prompt.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-Write a concise, informative commit message for these changes:
-- Review the whole context of the diff carefully to see what effect the change would have on the rest of the code and explain that. Be specific about the effect.
-- Do not guess about intent.
-- The goal of this commit message is that someone familiar with the codebase, but not with these changes would understand why the changes were made and what was changed.
-- The first line should be a short summary of the changes
-- Explain the 'why' behind changes
-- Use bullet points for multiple changes
-- Tone: Use some emojis, be funny, expressive, but stay professional
-- If there are no changes, or the input is blank - then return a blank string
-
-Think carefully about what would be most helpful to someone trying to understand the intent of this commit before you write your commit message. Your commit message will be used as an example to train other team members about the content of a good commit message.
-
-The output format should be:
-
-Summary of changes
-- changes
-- changes
-and so on
-
-What you write will be passed directly to git commit -m "[message]"
diff --git a/configs/prompts/pr-prompt.txt b/configs/prompts/pr-prompt.txt
deleted file mode 100644
index 625c893..0000000
--- a/configs/prompts/pr-prompt.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Write a clear, informative pull request message in markdown:
-
-* Remember to mention the files that were changed, and what was changed
-* Start with a summary
-* Explain the 'why' behind changes
-* Include a bulleted list to outline all of the changes
-* If there are changes that resolve specified issues add the issues to a list of closed issues
-* If there are no changes, or the input is blank - then return a blank string
-
-Think carefully before you write your pull request body.
-
-What you write will be passed to create a github pull request
diff --git a/justfile b/justfile
index 84c7a00..e378239 100644
--- a/justfile
+++ b/justfile
@@ -112,5 +112,8 @@ vm-copy:
[group('llm')]
llm:
- uv tool install llm
- llm install llm-anthropic
+ #!/usr/bin/env fish
+ uv tool install llm -U
+ llm install -U llm-anthropic
+ llm models default anthropic/claude-3-7-sonnet-20250219
+ llm keys set anthropic --value (op read --account my.1password.com "op://Private/anthropic llm/credential")
diff --git a/nix/users/fcuny/llm.nix b/nix/users/fcuny/llm.nix
index 48604c3..407cead 100644
--- a/nix/users/fcuny/llm.nix
+++ b/nix/users/fcuny/llm.nix
@@ -1,16 +1,22 @@
{ ... }:
{
- home.file.".config/prompts/pr-prompt.txt".text =
- builtins.readFile ../../../configs/prompts/pr-prompt.txt;
+ # we need this path to be created.
+ home.file.".configs/llm/templates/.keep".text = "# Managed by Home Manager";
+ home.file.".config/llm/templates/pr-prompt.yaml".text =
+ builtins.readFile ../../../configs/llm/templates/pr-prompt.yaml;
- home.file.".config/prompts/commit-system-prompt.txt".text =
- builtins.readFile ../../../configs/prompts/commit-system-prompt.txt;
+ home.file.".config/llm/templates/commit-prompt.yaml".text =
+ builtins.readFile ../../../configs/llm/templates/commit-prompt.yaml;
programs.fish = {
shellAliases = {
- commit-msg = "git diff HEAD | llm -m claude-3.5-sonnet -s (cat ~/.config/prompts/commit-system-prompt.txt |psub)";
- pr-msg = "git diff HEAD | llm -m claude-3.5-sonnet -s (cat ~/.config/prompts/pr-prompt.txt |psub)";
+ commit-msg = "git diff --cached | llm -t commit-prompt";
+ pr-msg = "git diff HEAD | llm -t pr-prompt";
};
};
+
+ home.sessionVariables = {
+ LLM_USER_PATH = "$HOME/.config/llm";
+ };
}