repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

refactor(pi): split vcs prompt details into skills

1547e4d79d416fd0b31f02eaad6b4be41bc4dec8

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (6)

pi/agent/prompts/ci.md

Modified
6 6 # Commit current git/jj changes
8 -Commit current repo changes.
9 -Hint:
10 -$ARGUMENTS
8 +Hint: $ARGUMENTS
12 -If `jj root` succeeds, use jj; otherwise use git.
10 +Detect VCS:
14 -1. Inspect:
15 - - jj:
16 - `jj status`, `jj diff --stat && jj diff`
17 - - git:
18 - `git status --short --branch`, `git diff --stat && git diff`, `git diff
19 - --cached --stat && git diff --cached` if staged
20 - - read untracked files before committing/staging
21 -2. Stop if clean.
22 -3. Exclude generated/cache/secret files.
23 - Ask only if ambiguous.
24 -4. Split unrelated changes into focused commits when safe; otherwise ask.
25 -5. Run obvious fast checks if available.
26 - Skip expensive/unclear checks with reason.
27 -6. Commit:
28 - - jj:
29 - `jj commit -m "subject"` (no staging)
30 - - git:
31 - stage relevant files, then commit.
32 - If hooks change files, inspect, restage, retry once.
33 -7. Do not push.
34 -8. Report hash/change id, subject, checks.
12 +- If `jj root` succeeds, read `pi/agent/skills/jj-workflow/SKILL.md` and execute its **Commit (`ci`)** flow.
13 +- Otherwise read `pi/agent/skills/git-workflow/SKILL.md` and execute its **Commit (`ci`)** flow.
36 -Message style:
38 -- Short, concrete subject.
39 - Subject-only OK.
40 -- Prefer `add`, `fix`, `update`, `remove`, `replace`, `track`, `show`, `rework`.
41 -- Use `type(scope):
42 - summary` when natural:
43 - `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `perf`, `build`, `ci`.
44 -- Use domain prefix when clearer:
45 - `ui:
46 - ...`, `db:
47 - ...`, `cli:
48 - ...`, `docs:
49 - ...`.
50 -- Lowercase after prefix.
51 - No final period.
52 -- Body only when useful:
53 - bullets, rationale, tests.
54 -- Preserve issue IDs.
55 - If exactly one issue is referenced in conversation history or branch name, include `closes #<N>` in the message.
56 - Multiple issues → stop and ask which to close. None → omit.
57 -- No AI attribution/trailers.
15 +The skill is source of truth. Do not invent alternate VCS behavior.

pi/agent/prompts/ff.md

Modified
2 -description: Rebase current branch onto default branch and push fast-forward
2 +description: Rebase current branch/bookmark onto default branch and push fast-forward
3 3 argument-hint: "[target-branch] [test-command]"
6 6 # Rebase onto default branch and push fast-forward
8 -One flow. Works the same for git and jj.
9 -Linear history only. No merge commits. No force-push.
8 +Args: $ARGUMENTS
11 -## Args
10 +Detect VCS:
13 -- `$1` → target branch if it names an existing local/remote ref. Remainder → test command.
14 -- No arg → auto-detect default branch, no tests.
12 +- If `jj root` succeeds, read `pi/agent/skills/jj-workflow/SKILL.md` and execute its **Fast-forward bookmark (`ff`)** flow.
13 +- Otherwise read `pi/agent/skills/git-workflow/SKILL.md` and execute its **Fast-forward branch (`ff`)** flow.
16 -## Detect default branch
18 -Never assume a name. Detect dynamically:
20 -**Git:**
21 -`git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/[^/]*/||'`
22 -Empty → `git remote set-head origin --auto` → retry.
23 -Fallback: `trunk` → `main` → `master` → `develop` (first existing local or remote ref wins).
24 -All fail → stop, ask user.
26 -**jj:**
27 -`jj bookmark list 'trunk()'` — uses configured trunk revset.
28 -Empty → try `trunk@origin` → `main@origin` → `master@origin`.
29 -All fail → stop, ask user.
31 ----
33 -## Flow
35 -Decide git or jj: `jj root` succeeds → jj, else git.
37 -1. **Preflight**
38 - - Git: `git status --short --branch`. Stop if dirty tree or ongoing merge/rebase.
39 - `git branch --show-current`. Stop if detached HEAD (empty output).
40 - - Jj: `jj status`. Stop on conflicts.
41 - - Record: current branch/bookmark, remote (default `origin`).
43 -2. **Fetch**
44 - - Git: `git fetch --prune --tags <remote>`.
45 - - Jj: `jj git fetch --remote <remote>`.
47 -3. **Rebase onto target**
48 - - Before: record commit count on branch (`git rev-list --count <remote>/<target>..HEAD` / `jj log -r '<target>..@ --template ''` + count).
49 - If >50 → warn, proceed.
50 - - Git: `git rebase <remote>/<target>`.
51 - - Jj: `jj rebase -b @ -o <target>`.
52 - - After: compare commit count. Fewer → warn (empty commits dropped).
53 - - Conflicts → stop; show files, status, next commands.
54 - - Already up-to-date → skip, note in report.
56 -4. **Test**
57 - Run given command, or infer cheap checks from project files.
58 - Failure → stop, no push.
60 -5. **Push**
61 - - Git: `git push <remote> <branch>`.
62 - - Jj: `jj bookmark move <bookmark> --to @` (if behind), then `jj git push --bookmark <bookmark>`.
63 - - Rejected → fetch, rebase once, retest, retry **once**.
64 - - Retry also rejected → stop. Report error (likely branch protection or remote history rewrite).
65 - - Never force-push.
67 ----
69 -## Report
71 -branch, target, remote, rebase yes/no, tests, pushed SHA, follow-up.
15 +The skill is source of truth. Do not invent alternate VCS behavior.

pi/agent/prompts/lm.md

Modified
2 -description: Land local feature branch into default branch via fast-forward
2 +description: Land local feature branch/bookmark into default branch via fast-forward
3 3 argument-hint: "[target-branch] [test-command]"
6 -# Land local branch into default branch via fast-forward
6 +# Land local branch/bookmark into default branch via fast-forward
8 -Fast-forward the default branch to your branch tip, then push.
9 -Linear history only. No merge commits. No force-push.
8 +Args: $ARGUMENTS
11 -## Args
10 +Detect VCS:
13 -- `$1` → target branch if it names an existing local/remote ref. Remainder → test command.
14 -- No arg → auto-detect default branch, no tests.
12 +- If `jj root` succeeds, read `pi/agent/skills/jj-workflow/SKILL.md` and execute its **Land bookmark (`lm`)** flow.
13 +- Otherwise read `pi/agent/skills/git-workflow/SKILL.md` and execute its **Land branch (`lm`)** flow.
16 -## Detect default branch
18 -Same as `ff`:
19 -**Git:** `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/[^/]*/||'`
20 -Empty → `git remote set-head origin --auto` → retry.
21 -Fallback: `trunk` → `main` → `master` → `develop`.
22 -All fail → stop, ask user.
24 -**jj:** `jj bookmark list 'trunk()'`. Empty → `trunk@origin` → `main@origin` → `master@origin`.
25 -All fail → stop, ask user.
27 ----
29 -## Flow
31 -Decide git or jj: `jj root` succeeds → jj, else git.
33 -1. **Preflight**
34 - - Git: `git status --short --branch`. Stop if dirty tree or ongoing merge/rebase.
35 - `git branch --show-current`. Stop if detached HEAD.
36 - - Jj: `jj status`. Stop on conflicts.
37 - - Must be on a branch that is **not** the target branch. Already on target → tell user to use `ff` instead.
38 - - Record: branch, target, remote (default `origin`).
40 -2. **Fetch**
41 - - Git: `git fetch --prune --tags <remote>`.
42 - - Jj: `jj git fetch --remote <remote>`.
44 -3. **Verify ancestor**
45 - - Git: `git merge-base --is-ancestor <remote>/<target> HEAD`. Fail → target has commits not in your branch. Tell user to `ff` first (rebase onto target), then retry `lm`.
46 - - Jj: `jj rebase -b @ -o <target> --dry-run`. Fail → same guidance.
47 - - Check commit messages on branch for `closes #<N>`. If none found and conversation mentions an issue → warn: landing won't auto-close the issue.
49 -4. **Test**
50 - Run given command, or infer cheap checks from project files.
51 - Failure → stop, no land.
53 -5. **Fast-forward target**
54 - - Git: `git update-ref refs/heads/<target> HEAD <old-target-sha>`.
55 - - Jj: `jj bookmark move <target> --to @` (never `--allow-backwards`).
57 -6. **Push**
58 - - Git: `git push <remote> <target>`.
59 - - Jj: `jj git push --bookmark <target>`.
60 - - Rejected → fetch, verify ancestor still holds, retry **once**.
61 - - Retry also rejected → stop. Report error (likely branch protection or concurrent push).
63 -7. **Cleanup** (optional)
64 - - Git: offer to delete landed branch.
65 - - Jj: offer to abandon landed commits / remove bookmark.
67 ----
69 -## Report
71 -branch → target, remote, old/new target SHA, tests, pushed SHA, follow-up.
15 +The skill is source of truth. Do not invent alternate VCS behavior.

pi/agent/prompts/pr.md

Modified
6 6 # Review, checkout, test, and prepare PR merge
8 -Review PR end-to-end and prepare merge.
9 -Do **not** merge until explicit user OK.
10 -If `jj root` succeeds, use jj; otherwise use git.
8 +Args: $ARGUMENTS
12 -**PR**: $1
13 -**Test command**: ${@:2}
10 +Detect VCS:
15 -## Forge CLI detection
12 +- If `jj root` succeeds, read `pi/agent/skills/jj-workflow/SKILL.md` and execute its **PR review (`pr`)** flow.
13 +- Otherwise read `pi/agent/skills/git-workflow/SKILL.md` and execute its **PR review (`pr`)** flow.
17 -Detect from git remote URL:
19 -- `github.com` → `gh`
20 -- `codeberg.org` or any Forgejo instance → `fj`
21 -- bare git server → no forge CLI, generic git only
22 -- If forge CLI binary missing → fall back to generic git
24 -0. **Resolve PR**
25 - - If `$1` is set, use it.
26 - - Else scan conversation history for a previously discussed PR (URL, number, branch).
27 - - If none found → stop, ask user to specify.
29 -1. **Identify**
30 - - Detect VCS: `jj root` → jj, else git.
31 - - Detect forge CLI (above).
32 - - Resolve PR metadata: title, author, base, head, URL, status, CI, labels.
33 - - Fetch latest base/head: `jj git fetch` / `git fetch`.
35 -2. **Protect local work**
36 - - `jj status` or `git status --short`.
37 - - Dirty unrelated work → do not overwrite. Prefer isolated jj workspace or git worktree.
38 - - Detect repo style: `jj workspace list` / `git worktree list`.
40 -3. **Checkout**
41 - - jj: prefer `jj workspace add <path> -r <head-rev>`. Otherwise `jj new <head-rev>` when safe.
42 - - git: prefer worktree when dirty or isolation needed. Otherwise branch checkout when clean.
43 - - Forge CLI path: use for metadata/merge only. Use VCS-native fetch/checkout for files.
44 - - Generic path: fetch PR head ref or remote branch, then create branch/worktree/workspace.
46 -4. **Review diff**
47 - - jj: `jj diff --from <base> --to <head>`. git: `git diff <base>...<head>`.
48 - - Read relevant files, tests, docs, configs.
49 - - Check correctness, security, perf, API compat, migrations, UX, error handling.
50 - - Verify PR matches issue/description.
52 -5. **Test**
53 - - If test command provided, run it.
54 - - Else infer from project files (README, package files, CI, justfile, Makefile).
55 - - Focused tests first, broader suite if reasonable.
56 - - Include lint/typecheck/build when conventional.
58 -6. **Report**
59 - - PR summary
60 - - Checkout location + base/head SHAs/change IDs
61 - - Review findings: blockers / warnings / notes with file:line refs
62 - - Tests run: command → pass/fail
63 - - Merge readiness: READY | NOT READY
64 - - Exact merge plan/command to run after OK
65 - - If not ready, list minimal required fixes.
67 -7. **Wait**
68 - - Stop after report. Ask for explicit OK to merge only if READY.
69 - - On OK: re-fetch, verify PR still current/mergeable, run critical checks,
70 - then merge using forge CLI or VCS-native (fast-forward preferred).
71 - Report final status.
72 - - After merge: offer to remove jj workspace or git worktree/branch.
15 +The skill is source of truth. Do not merge until explicit user OK.

pi/agent/skills/git-workflow/SKILL.md

Added
new file mode 100644
1 +---
2 +name: git-workflow
3 +description: Use for Git repository workflows: committing changes, rebasing/pushing fast-forward, landing branches, or reviewing PRs. Load when a prompt says git workflow or when jj is not active.
4 +---
6 +# Git Workflow
8 +Use Git only after `jj root` fails. Preserve unrelated dirty work. Never force-push.
10 +## Common rules
12 +- Inspect before mutating: `git status --short --branch`.
13 +- Stop on merge/rebase/cherry-pick conflicts unless the user explicitly asks to continue.
14 +- Read untracked files before staging them.
15 +- Exclude generated/cache/secret files. Ask only if ambiguous.
16 +- Run obvious fast checks when available; skip expensive/unclear checks with reason.
17 +- No AI attribution/trailers.
19 +## Default branch
21 +Detect dynamically:
23 +```sh
24 +git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/[^/]*/||'
25 +```
27 +If empty: `git remote set-head origin --auto`, retry. Fallback: first existing local or remote ref from `trunk`, `main`, `master`, `develop`. If none: stop and ask.
29 +## Commit (`ci`)
31 +1. Inspect: `git status --short --branch`, `git diff --stat && git diff`, and if staged `git diff --cached --stat && git diff --cached`.
32 +2. Stop if clean.
33 +3. Split unrelated changes into focused commits when safe; otherwise ask.
34 +4. Stage relevant files only.
35 +5. Commit. If hooks change files, inspect, restage, retry once.
36 +6. Do not push.
37 +7. Report hash, subject, checks.
39 +### Commit message
41 +- Short, concrete subject. Subject-only OK.
42 +- Prefer `add`, `fix`, `update`, `remove`, `replace`, `track`, `show`, `rework`.
43 +- Use `type(scope): summary` when natural: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `perf`, `build`, `ci`.
44 +- Use domain prefix when clearer: `ui: ...`, `db: ...`, `cli: ...`, `docs: ...`.
45 +- Lowercase after prefix. No final period.
46 +- Body only when useful: bullets, rationale, tests.
47 +- Preserve issue IDs. If exactly one issue is referenced in conversation history or branch name, include `closes #<N>`. Multiple issues → ask which. None → omit.
49 +## Fast-forward branch (`ff`)
51 +Goal: rebase current branch onto target/default branch and push current branch. Linear history only.
53 +Args: `$1` may be target branch if it names an existing local/remote ref. Remainder is test command.
55 +1. Preflight: clean tree, no ongoing operation, not detached HEAD. Record branch and remote (`origin`).
56 +2. Fetch: `git fetch --prune --tags <remote>`.
57 +3. Rebase onto target: record `git rev-list --count <remote>/<target>..HEAD`; warn if >50; run `git rebase <remote>/<target>`; compare count after and warn if fewer commits.
58 +4. Conflicts → stop; show files, status, next commands.
59 +5. Test: run provided command or infer cheap checks.
60 +6. Push: `git push <remote> <branch>`. If rejected: fetch, rebase once, retest, retry once. Never force-push.
61 +7. Report branch, target, remote, rebase yes/no, tests, pushed SHA, follow-up.
63 +## Land branch (`lm`)
65 +Goal: fast-forward target/default branch to current branch tip and push target.
67 +1. Preflight: clean tree, no ongoing operation, on a branch that is not target. Already on target → tell user to use `ff`.
68 +2. Fetch: `git fetch --prune --tags <remote>`.
69 +3. Verify ancestor: `git merge-base --is-ancestor <remote>/<target> HEAD`. Fail → target has commits not in current branch; tell user to run `ff` first.
70 +4. Warn if branch commits lack `closes #<N>` but conversation mentions an issue.
71 +5. Test: run provided command or infer cheap checks.
72 +6. Fast-forward target: `git update-ref refs/heads/<target> HEAD <old-target-sha>`.
73 +7. Push: `git push <remote> <target>`. If rejected: fetch, verify ancestor, retry once.
74 +8. Offer to delete landed branch.
75 +9. Report branch → target, old/new target SHA, tests, pushed SHA, follow-up.
77 +## PR review (`pr`)
79 +Do not merge until explicit user OK.
81 +1. Resolve PR from argument or conversation. If none: ask.
82 +2. Detect forge CLI from remote URL: `github.com` → `gh`; `codeberg.org` or Forgejo → `fj`; bare git server → generic Git. Missing CLI → generic Git.
83 +3. Resolve metadata: title, author, base, head, URL, status, CI, labels.
84 +4. Protect local work: dirty unrelated work → prefer isolated `git worktree`.
85 +5. Fetch latest base/head.
86 +6. Checkout via worktree when dirty or isolation needed; otherwise branch checkout when clean. Use forge CLI for metadata/merge only; use Git-native fetch/checkout for files.
87 +7. Review diff: `git diff <base>...<head>`. Read relevant files, tests, docs, configs. Check correctness, security, perf, API compat, migrations, UX, error handling, issue match.
88 +8. Test provided command or infer from project files.
89 +9. Report summary, checkout location, base/head SHAs, blockers/warnings/notes with file:line refs, tests, readiness `READY|NOT READY`, exact merge plan.
90 +10. Wait. On explicit OK: re-fetch, verify current/mergeable, run critical checks, merge via forge CLI or Git-native fast-forward preferred, report final status. Offer cleanup.

pi/agent/skills/jj-workflow/SKILL.md

Added
new file mode 100644
1 +---
2 +name: jj-workflow
3 +description: Use for Jujutsu/jj repository workflows: committing changes, rebasing/pushing bookmarks, landing bookmarks, or reviewing PRs/workspaces. Load when `jj root` succeeds or a prompt says jj workflow.
4 +---
6 +# Jj Workflow
8 +Use Jujutsu when `jj root` succeeds. Prefer jj-native commands. Do not use Git stash/log/status to protect or inspect jj workspaces. Never force-push.
10 +## Common rules
12 +- Inspect before mutating: `jj status`.
13 +- Stop on conflicts unless the user explicitly asks to continue.
14 +- Preserve unrelated dirty work; prefer isolated jj workspaces for PR review.
15 +- Read untracked files before committing decisions involving them.
16 +- Exclude generated/cache/secret files. Ask only if ambiguous.
17 +- Run obvious fast checks when available; skip expensive/unclear checks with reason.
18 +- No AI attribution/trailers.
20 +## Default branch
22 +Detect dynamically:
24 +```sh
25 +jj bookmark list 'trunk()'
26 +```
28 +If empty, try `trunk@origin`, `main@origin`, `master@origin`. If all fail: stop and ask.
30 +## Commit (`ci`)
32 +1. Inspect: `jj status`, `jj diff --stat && jj diff`.
33 +2. Stop if clean.
34 +3. Split unrelated changes into focused commits when safe; otherwise ask.
35 +4. Commit current change: `jj commit -m "subject"`.
36 +5. Do not push.
37 +6. Report change id, subject, checks.
39 +### Commit message
41 +- Short, concrete subject. Subject-only OK.
42 +- Prefer `add`, `fix`, `update`, `remove`, `replace`, `track`, `show`, `rework`.
43 +- Use `type(scope): summary` when natural: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`, `perf`, `build`, `ci`.
44 +- Use domain prefix when clearer: `ui: ...`, `db: ...`, `cli: ...`, `docs: ...`.
45 +- Lowercase after prefix. No final period.
46 +- Body only when useful: bullets, rationale, tests.
47 +- Preserve issue IDs. If exactly one issue is referenced in conversation history or bookmark name, include `closes #<N>`. Multiple issues → ask which. None → omit.
49 +## Fast-forward bookmark (`ff`)
51 +Goal: rebase current change stack onto target/default branch and push bookmark. Linear history only.
53 +Args: `$1` may be target branch/bookmark if it names an existing ref. Remainder is test command.
55 +1. Preflight: `jj status`; stop on conflicts. Record current bookmark/change and remote (`origin`).
56 +2. Fetch: `jj git fetch --remote <remote>`.
57 +3. Rebase onto target: warn if stack is large; run `jj rebase -b @ -o <target>`.
58 +4. Conflicts → stop; show files, status, next commands.
59 +5. Test: run provided command or infer cheap checks.
60 +6. Push: move bookmark to `@` if needed with `jj bookmark move <bookmark> --to @`, then `jj git push --bookmark <bookmark>`.
61 +7. If rejected: fetch, rebase once, retest, retry once. Never force-push.
62 +8. Report bookmark, target, remote, rebase yes/no, tests, pushed change/commit, follow-up.
64 +## Land bookmark (`lm`)
66 +Goal: fast-forward target/default bookmark to current change and push target. No merge commits. No backwards moves.
68 +1. Preflight: `jj status`; stop on conflicts. Must not already be on target; if on target, tell user to use `ff`.
69 +2. Fetch: `jj git fetch --remote <remote>`.
70 +3. Verify current stack can rebase onto target: `jj rebase -b @ -o <target> --dry-run`. Fail → target has commits not in current stack; tell user to run `ff` first.
71 +4. Warn if stack commits lack `closes #<N>` but conversation mentions an issue.
72 +5. Test: run provided command or infer cheap checks.
73 +6. Fast-forward target: `jj bookmark move <target> --to @` (never `--allow-backwards`).
74 +7. Push: `jj git push --bookmark <target>`. If rejected: fetch, verify ancestor/rebase condition, retry once.
75 +8. Offer to abandon landed commits/remove feature bookmark when safe.
76 +9. Report bookmark → target, tests, pushed change/commit, follow-up.
78 +## PR review (`pr`)
80 +Do not merge until explicit user OK.
82 +1. Resolve PR from argument or conversation. If none: ask.
83 +2. Detect forge CLI from Git remote URL: `github.com` → `gh`; `codeberg.org` or Forgejo → `fj`; bare git server → generic jj/git only. Missing CLI → generic path.
84 +3. Resolve metadata: title, author, base, head, URL, status, CI, labels.
85 +4. Protect local work: prefer `jj workspace add <path> -r <head-rev>`; otherwise `jj new <head-rev>` only when safe.
86 +5. Fetch latest base/head: `jj git fetch`.
87 +6. Review diff: `jj diff --from <base> --to <head>`. Read relevant files, tests, docs, configs. Check correctness, security, perf, API compat, migrations, UX, error handling, issue match.
88 +7. Test provided command or infer from project files.
89 +8. Report summary, workspace location, base/head change IDs or commits, blockers/warnings/notes with file:line refs, tests, readiness `READY|NOT READY`, exact merge plan.
90 +9. Wait. On explicit OK: re-fetch, verify current/mergeable, run critical checks, merge via forge CLI or jj-native fast-forward preferred, report final status. Offer workspace cleanup.