git-worktree-runner copilot-instructions.md

Instructions for Git Worktree Runner, a command-line tool that creates and manages separate Git working folders for branches, with editor and AI integrations.

In plain words
What is it for?
They are for working on commands that create, open, list, remove, or resolve worktrees and connect them to editors or AI tools.
Why use it?
They explain how worktree paths, branch names, configuration, hooks, and integrations are resolved so changes behave consistently.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/coderabbitai/git-worktree-runner/copilot-instructions
Clone the repo
git clone --depth 1 https://github.com/coderabbitai/git-worktree-runner

Made for: GitHub Copilot.

Per session 1,250 This file is loaded in full into every session.
When invoked 1,250 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01250 $0.01250
Opus 5 $0.00625 $0.00625
Sonnet 5 $0.00250 $0.00250
Haiku 4.5 $0.00125 $0.00125

Measured yesterday against content hash c0ab9e097faf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

git-worktree-runner copilot-instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/copilot-instructions.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Copilot Instructions

Architecture & Flow

bin/gtr (961 lines) dispatches to cmd_* functions (case block lines 36‑77). Libraries sourced at startup:

  • lib/core.sh - create/list/remove/resolve worktrees
  • lib/config.sh - git config wrapper with precedence
  • lib/ui.sh - log_error/log_info/prompts
  • lib/copy.sh - glob pattern file copying
  • lib/hooks.sh - postCreate/postRemove execution
  • lib/platform.sh - OS detection + GUI helpers

Adapters in adapters/{editor,ai} each implement two functions with strict contracts (see below).

Key Concepts

  • Special ID 1 = main repo (usable in open, go, ai).
  • Folder naming = sanitized branch (feature/authfeature-auth).
  • Base dir resolution (resolve_base_dir): config gtr.worktrees.dir → env → default <repo>-worktrees; relative paths resolved from repo root; tilde expanded; warns if inside repo unignored.
  • Target resolution (resolve_target): ID 1 → current → sanitized path → scan directories; returns TSV: is_main\tpath\tbranch.
  • Config precedence (cfg_default): git config (local→global→system) → env → fallback. Multi-value keys merged & deduped (cfg_get_all).

Adapter Contract

Editor: editor_can_open, editor_open <path>; AI: ai_can_start, ai_start <path> [args...]. Must check tool availability (command -v), emit errors via log_error, never silently fail, and avoid side effects outside the target directory (AI uses subshell (cd ...)). Update README, help (cmd_help), completions.

Manual Testing (Essential Subset)

./bin/gtr new feature/x      # creates folder feature-x
./bin/gtr open feature/x     # loads configured editor
./bin/gtr ai feature/x       # starts configured AI tool
./bin/gtr list               # lists main + worktrees
./bin/gtr rm feature/x       # removes worktree
./bin/gtr go feature/x       # prints path (use in cd)

Advanced: --force --name backend (same branch multi-worktree); git config --add gtr.copy.include "**/.env.example"; hooks: git config --add gtr.hook.postCreate "npm install". Full matrix: see .github/instructions/testing.instructions.md.

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 84 lines · 1,250 tokens per session scan A c0ab9e097faf

Subscribe to this mod's changes

git-worktree-runner copilot-instructions.md is an instructions file published in the GitHub repository coderabbitai/git-worktree-runner (1,754 stars, last pushed 4d ago), licensed Apache-2.0. It adds 1,250 tokens to every session, about $0.0063 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.