aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <59291+fcuny@users.noreply.github.com>2025-02-24 19:24:13 -0800
committerFranck Cuny <59291+fcuny@users.noreply.github.com>2025-02-24 19:24:47 -0800
commitc4fecf6bfdaa846c5657b82325501047189aed5d (patch)
tree76ad80e14276d4a184b3c7a0b921641e1d78b7a4
parentadd ~/.local/bin to the path (diff)
downloadinfra-c4fecf6bfdaa846c5657b82325501047189aed5d.tar.gz
🤖 Add LLM tooling and prompts for Git workflow automation
- Add new section in README about LLM tooling installation - Create prompts directory with templates for commit and PR messages - Add new llm.nix module with: - Configuration for prompt file locations - Fish shell aliases for generating commit and PR messages using Claude 3.5 - Add `llm` recipe in justfile to install llm CLI tool and Anthropic provider - Integrate LLM module into home-manager configuration The changes introduce automation for generating high-quality commit messages and PR descriptions using AI, while keeping the prompts configurable and version controlled.
Diffstat (limited to '')
-rw-r--r--README.md4
-rw-r--r--configs/prompts/commit-system-prompt.txt20
-rw-r--r--configs/prompts/pr-prompt.txt12
-rw-r--r--justfile5
-rw-r--r--nix/users/fcuny/home-manager.nix1
-rw-r--r--nix/users/fcuny/llm.nix16
6 files changed, 58 insertions, 0 deletions
diff --git a/README.md b/README.md
index b46de11..444fd15 100644
--- a/README.md
+++ b/README.md
@@ -27,3 +27,7 @@ nix run nix-darwin -- switch --flake .#hostname
Finally, switch the default shell via `chsh`, and set it to `/run/current-system/sw/bin/fish`.
Best to reboot to complete the installation.
+
+## LLM
+
+For now I'm going to install some tooling manually. Run `just llm` to get the toolchain installed.
diff --git a/configs/prompts/commit-system-prompt.txt b/configs/prompts/commit-system-prompt.txt
new file mode 100644
index 0000000..8ddc434
--- /dev/null
+++ b/configs/prompts/commit-system-prompt.txt
@@ -0,0 +1,20 @@
+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
new file mode 100644
index 0000000..625c893
--- /dev/null
+++ b/configs/prompts/pr-prompt.txt
@@ -0,0 +1,12 @@
+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 f99e6c5..84c7a00 100644
--- a/justfile
+++ b/justfile
@@ -109,3 +109,8 @@ vm-copy:
--exclude='.direnv/' \
--rsync-path="sudo rsync" \
$(dirname justfile)/ {{ nixaddr }}:/nix-config
+
+[group('llm')]
+llm:
+ uv tool install llm
+ llm install llm-anthropic
diff --git a/nix/users/fcuny/home-manager.nix b/nix/users/fcuny/home-manager.nix
index 9fd2983..0a3f6fc 100644
--- a/nix/users/fcuny/home-manager.nix
+++ b/nix/users/fcuny/home-manager.nix
@@ -11,6 +11,7 @@
./shell.nix
./ssh.nix
./git.nix
+ ./llm.nix
]
++ lib.optionals darwin [
./1password.nix
diff --git a/nix/users/fcuny/llm.nix b/nix/users/fcuny/llm.nix
new file mode 100644
index 0000000..48604c3
--- /dev/null
+++ b/nix/users/fcuny/llm.nix
@@ -0,0 +1,16 @@
+{ ... }:
+{
+
+ home.file.".config/prompts/pr-prompt.txt".text =
+ builtins.readFile ../../../configs/prompts/pr-prompt.txt;
+
+ home.file.".config/prompts/commit-system-prompt.txt".text =
+ builtins.readFile ../../../configs/prompts/commit-system-prompt.txt;
+
+ 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)";
+ };
+ };
+}