5.9 KiB
title, author, state, date_completed, model, input_tokens, output_tokens
| title | author | state | date_completed | model | input_tokens | output_tokens |
|---|---|---|---|---|---|---|
| Implement prompt log commands | Janik von Rotz <login@janikvonrotz.ch> | completed | 2026-09-25 | moonshotai/Kimi-K2.6 | 2667000 | 25500 |
Implement prompt log commands
Note: @Clanker refers to the "ai agent" (you) who is working on this prompt file.
@Clanker when working on this prompt file, make sure to:
- Read context and task section first
- Prepare a list of todos
- Update the todo list while working on task
Context
@Clanker Read the AGENTS.md and README.md to get an understanding of the project.
Task
Read bin/create-prompt and bin/list-prompts. The commands help manage prompt instruction. I would like to introduce new commands and a new system to manage prompt files.
Instead of storing the prompts in the prompts folder I would like to store them on a separated branch called prompt-log.
Design decisions
- Worktree lifecycle: every command assumes the
prompt-loggit worktree exists and creates it on demand (same logic asinit-prompt-log) if it doesn't — don't require the user to runinit-prompt-logfirst every time. - Clipboard copy: the clipboard-copy step in the current
create-promptis dropped entirely, not carried over. repo-pathargument: wherever[repo-path]appears below, it means "operate on a different git repository" (worktree, branch, andprompt.mdresolved relative to that path) — applied consistently, not just where spelled out undercreate-prompt.prompt.md.template: remove the${PROMPT_ID}placeholder (no more numbering) and stopcreate-promptfrom exportingPROMPT_ID.- Session token/model capture: out of scope for this task —
model,input_tokens,output_tokensstay manually filled in.
Commands
init-prompt-log
Ensures the current folder has a .git folder. Creates the prompt-log branch as an orphan branch (no shared history with main) via the dedicated git worktree. Idempotent — safe to run again if the branch/worktree already exists.
create-prompt <title> [repo-path]
Instead of creating an entry in the prompts folder this command creates the prompt.md file (always overwriting any existing one). The file name no longer matters. If repo-path is given, operates against that repository instead of the current directory.
prompt-with-pi [path]
Runs the pi command and pipes the content of prompt.md as query. The harness follows the instructions and updates the prompt.md file.
By default it uses the prompt.md of the current directory. It can also take a path to a prompt file.
commit-prompt [repo-path]
Reads the current commit hash (git rev-parse --short HEAD) of the project and the content of prompt.md. Creates a file named <commit-hash>-<title-with-dashes-and-lowercase>.md in the prompt-log worktree, storing the content. Commits it with message title feat: add prompt file and the filename in the message body. Pushes prompt-log to the remote, warning (not failing) if the push doesn't succeed.
list-prompts [repo-path]
Outputs a table with headers:
- date: first-commit date of the file on
prompt-log - title: frontmatter attribute
titlein file - state: frontmatter attribute
statein file - commit: short hash of commit from filename
Rows are sorted by date.
edit-prompt [commit] [repo-path]
If commit is not given, shows an fzf dialog of all files in the prompt-log branch, listing the frontmatter title. Selecting a file opens it directly in $EDITOR within the tmp/prompt-log worktree. If commit is given, opens that target file directly in $EDITOR. After the editor closes, the change is committed with feat: update prompt file and pushed (warning on failure). The file is edited in place; prompt.md is not involved.
show-prompt [commit] [repo-path]
Similar to edit-prompt but outputs the prompt content directly to stdout instead of opening in $EDITOR. Accepts an optional commit prefix or shows an fzf dialog when no commit is given.
convert-prompts-folder-to-prompt-log [repo-path]
Converts an existing prompts folder to the new format. For each file, looks up the commit on which it was first added (git log --follow --diff-filter=A) and commits it as <commit-hash>-<title-with-dashes-and-lowercase>.md in the prompt-log branch, using the same commit-message convention as commit-prompt. Files with no discoverable creation commit are reported and skipped. On success, deletes the old prompts/ folder and its files.
Alias
Add an alias to each command:
init-prompt-log→iplcreate-prompt→crp(existing)prompt-with-pi→pwpcommit-prompt→coplist-prompts→lp(existing)edit-prompt→epshow-prompt→shpconvert-prompts-folder-to-prompt-log→cpfpl
Docs
Update library.md with the commands in the LLM section. Register the help row in the task.template file.
Worklog
- Created new bin scripts:
init-prompt-log,prompt-with-pi,commit-prompt,edit-prompt,show-prompt,convert-prompts-folder-to-prompt-log - Rewrote
bin/create-promptto outputprompt.mddirectly withauthorfrom git log - Rewrote
bin/list-promptsto read fromtmp/prompt-logworktree - Updated
prompt.md.templatewithauthorfield - Added aliases and verified no collisions with existing aliases
- Tested full workflow: init → create → store → list → edit → show → convert
- Updated
library.mdandtask.templatewith all new commands - Added
delete-promptcommand (dpalias) with fzf selection and commit/push support commit_refis injected bycommit-promptonly, not bycreate-promptcommit-promptnow errors if worktree is missing instead of auto-creating it- Added comment documenting the empty-tree hash in
init-prompt-log - Sorted fzf dialogs by date (newest first) in
edit-prompt,show-prompt, anddelete-prompt