diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 3644ced..6460c49 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -1,7 +1,7 @@ { "$schema": "https://anthropic.com/claude-code/marketplace.schema.json", "name": "keboola-claude-kit", - "version": "1.6.0", + "version": "1.7.0", "metadata": { "description": "Comprehensive Claude Kit marketplace for Keboola workflows including developer tools, component development, and data app building with specialized agents and best practices" }, @@ -20,7 +20,7 @@ { "name": "developer", "description": "Developer toolkit with specialized agents for code review, security analysis, and GitHub PR review processing", - "version": "1.7.1", + "version": "1.8.0", "source": "./plugins/developer", "category": "development" }, diff --git a/plugins/developer/.claude-plugin/plugin.json b/plugins/developer/.claude-plugin/plugin.json index 34550ef..5746143 100644 --- a/plugins/developer/.claude-plugin/plugin.json +++ b/plugins/developer/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "developer", - "version": "1.7.1", + "version": "1.8.0", "description": "Developer toolkit with specialized agents for code review and security analysis", "author": { "name": "Keboola :(){:|:&};: s.r.o.", diff --git a/plugins/developer/README.md b/plugins/developer/README.md index 91715e5..1606d36 100644 --- a/plugins/developer/README.md +++ b/plugins/developer/README.md @@ -136,6 +136,31 @@ Analyzes your changes and creates a pull request with AI-generated title and des --- +### Worktree +**Command**: `/worktree [args]` + +Manage git worktrees using the [git-wt](https://github.com/vojtabiberle/git-wt) helper script, fetched from upstream at runtime. + +**Subcommands:** +- `add [source]` — Create a worktree for a branch +- `rm [branch]` — Remove a worktree +- `ls` — List all worktrees +- `help` — Show help + +**Usage:** +```bash +# Create worktree for a feature branch from master +/worktree add feature/login master + +# List all worktrees +/worktree ls + +# Remove a worktree +/worktree rm feature/login +``` + +--- + ### Handle Conflicts **Command**: `/handle-conflicts` @@ -375,14 +400,19 @@ plugins/developer/ ├── commands/ │ ├── add-task.md # Slash command for quick task creation │ ├── create-pr.md # Slash command for PR creation -│ └── handle-conflicts.md # Slash command for merge conflicts +│ ├── handle-conflicts.md # Slash command for merge conflicts +│ └── worktree.md # Slash command for git worktree management ├── scripts/ │ └── context-progressbar.sh # Composable context window progress bar ├── skills/ -│ └── gh-process-review/ # GitHub PR review processing skill +│ ├── gh-process-review/ # GitHub PR review processing skill +│ │ ├── SKILL.md +│ │ └── scripts/ +│ │ └── review.sh # Single CLI entry point (fetch/list/get/reply/mark) +│ └── git-worktree/ # Git worktree management skill (git-wt) │ ├── SKILL.md │ └── scripts/ -│ └── review.sh # Single CLI entry point (fetch/list/get/reply/mark) +│ └── ensure-git-wt.sh # Clones/pulls vojtabiberle/git-wt before use └── README.md # This file ``` @@ -427,6 +457,6 @@ To add or improve agents: --- -**Version**: 1.6.0 +**Version**: 1.8.0 **Maintainer**: Keboola :(){:|:&};: s.r.o. **License**: MIT diff --git a/plugins/developer/commands/worktree.md b/plugins/developer/commands/worktree.md new file mode 100644 index 0000000..d51829f --- /dev/null +++ b/plugins/developer/commands/worktree.md @@ -0,0 +1,53 @@ +--- +name: worktree +description: Manage git worktrees using git-wt. Usage - /worktree add [source], /worktree rm [branch], /worktree ls, /worktree help +allowed-tools: Bash, Read, Write +--- + +# Git Worktree Management + +Manage git worktrees using the [git-wt](https://github.com/vojtabiberle/git-wt) script, fetched from upstream. + +## Instructions + +1. Validate we are inside a git repository: + ```bash + git rev-parse --is-inside-work-tree + ``` + +2. Fetch or update the git-wt script directly from upstream: + ```bash + GIT_WT_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/git-wt" + if [[ -d "$GIT_WT_DIR/.git" ]]; then + git -C "$GIT_WT_DIR" fetch --quiet 2>/dev/null || true + else + git clone --quiet https://github.com/vojtabiberle/git-wt.git "$GIT_WT_DIR" + fi + GIT_WT="$GIT_WT_DIR/git-wt" + ``` + +3. Parse the user's arguments from `$ARGUMENTS`. Only accept known subcommands: + - `add [source]` — create a worktree + - `rm [branch]` — remove a worktree + - `ls` — list worktrees + - `help` — show help + +4. Run the git-wt script with `--non-interactive` flag, validating and safely passing arguments: + ```bash + # Parse arguments into positional parameters + set -- $ARGUMENTS + subcommand="$1" + shift || true + + case "$subcommand" in + add|rm|ls|help) + "$GIT_WT" --non-interactive "$subcommand" "$@" + ;; + *) + echo "Error: unknown subcommand: $subcommand" >&2 + echo "Usage: /worktree [args...]" >&2 + ;; + esac + ``` + +5. Report the result to the user. For `add`, highlight the worktree path (last line of output). diff --git a/plugins/developer/skills/git-worktree/SKILL.md b/plugins/developer/skills/git-worktree/SKILL.md new file mode 100644 index 0000000..a7eef1b --- /dev/null +++ b/plugins/developer/skills/git-worktree/SKILL.md @@ -0,0 +1,160 @@ +--- +name: git-worktree +description: Manage git worktrees using the git-wt helper script. Use when user asks to create, list, remove, or navigate worktrees, work in parallel on multiple branches, or set up isolated development environments. Triggers on phrases like "create worktree", "new worktree", "worktree for branch", "/worktree", "wt add", "wt rm", "wt ls". +--- + +# Git Worktree Management (git-wt) + +Manage git worktrees using the [git-wt](https://github.com/vojtabiberle/git-wt) helper script, fetched from upstream on each use. + +## Working Directory Context + +**CRITICAL: All commands MUST be run from the user's project root directory, NOT from the skill directory.** + +- The user will be in THEIR project directory when invoking this skill +- The setup script clones/pulls git-wt to `~/.local/share/git-wt` and prints the executable path +- **DO NOT `cd` into the skill directory** + +`SKILL_DIR` = directory containing this SKILL.md (automatically resolved by Claude) + +## Setup + +Before using git-wt, fetch or update it: + +```bash +GIT_WT="$("$SKILL_DIR/scripts/ensure-git-wt.sh")" +``` + +This clones `vojtabiberle/git-wt` to `~/.local/share/git-wt` (pinned to a known-good commit) or updates the existing clone. The script prints the path to the `git-wt` executable on stdout. If the network is unavailable, it falls back to the existing local version. + +All subsequent commands use `$GIT_WT`. Pass `--non-interactive` to suppress prompts for commands that may prompt (e.g. `add`, `rm`). Do **not** use `--non-interactive` with `init`, which requires interactive input. + +## Commands + +### Create a Worktree + +```bash +"$GIT_WT" --non-interactive add [source-branch] +``` + +- Creates a worktree for ``, optionally from `[source-branch]` +- If the branch exists locally, checks it out into a new worktree +- If it exists only on `origin`, uses the remote branch (auto-confirmed with `--non-interactive`) +- If it doesn't exist anywhere, creates a new branch from HEAD or `[source-branch]` +- Runs any configured setup commands from `worktree.conf` / `worktree.conf.local` + +**Examples:** +```bash +# Create worktree for existing branch +"$GIT_WT" --non-interactive add feature/login + +# Create worktree for new branch from master +"$GIT_WT" --non-interactive add feature/new-feature master + +# Create worktree for new branch from specific base +"$GIT_WT" --non-interactive add bugfix/fix-123 release/v2 +``` + +### List Worktrees + +```bash +"$GIT_WT" ls +``` + +Lists all worktrees (`git worktree list`). + +### Remove a Worktree + +```bash +"$GIT_WT" --non-interactive rm +"$GIT_WT" --non-interactive rm # Removes current worktree (auto-detected) +"$GIT_WT" --non-interactive rm --force # Force removal +``` + +- Runs any configured teardown commands before removal +- Without args, removes the current worktree if in one + +### Show Worktree Path + +```bash +"$GIT_WT" cd +``` + +Prints the filesystem path of the worktree for ``. Useful for scripting. + +### Initialize Configuration + +```bash +"$GIT_WT" init +``` + +Interactively creates `worktree.conf.local` in the repo root. **Note:** Do not use `--non-interactive` with this command — it requires user input to configure directories and setup commands. + +### Help + +```bash +"$GIT_WT" help +``` + +## Configuration + +The script uses two shell-sourceable config files in each project's repo root: + +**`worktree.conf`** (committed project defaults): +```bash +WORKTREE_DIR=".." +WORKTREE_PREFIX="myapp" +WORKTREE_SETUP=("./setup.sh") +WORKTREE_TEARDOWN=("./teardown.sh") +``` + +**`worktree.conf.local`** (personal overrides, gitignored): +```bash +WORKTREE_DIR="/home/me/worktrees" +WORKTREE_SETUP=("./setup.sh" "direnv allow") +WORKTREE_TEARDOWN=("docker compose down") +``` + +### Variables + +| Variable | Default | Description | +|---|---|---| +| `WORKTREE_DIR` | `..` | Base directory for worktrees (relative to repo root) | +| `WORKTREE_PREFIX` | repo name | Prefix for worktree directory names | +| `WORKTREE_SETUP` | `()` | Commands to run after creating a worktree | +| `WORKTREE_TEARDOWN` | `()` | Commands to run before removing a worktree | + +### Directory Naming + +Format: `/-` + +Branch `feature/login` with prefix `myapp` and base `..`: +``` +../myapp-feature-login +``` + +Sanitization: `/` becomes `-`, everything lowercased. + +## Typical Workflow + +1. **Fetch git-wt**: + ```bash + GIT_WT="$("$SKILL_DIR/scripts/ensure-git-wt.sh")" + ``` +2. **Create worktree** for a feature branch: + ```bash + "$GIT_WT" --non-interactive add feature/my-branch master + ``` +3. **Work in the worktree** directory (printed as the last line of output) +4. **List worktrees** to see all active ones: + ```bash + "$GIT_WT" ls + ``` +5. **Clean up** when done: + ```bash + "$GIT_WT" --non-interactive rm feature/my-branch + ``` + +## Source + +Fetched from [vojtabiberle/git-wt](https://github.com/vojtabiberle/git-wt) (MIT License). diff --git a/plugins/developer/skills/git-worktree/scripts/ensure-git-wt.sh b/plugins/developer/skills/git-worktree/scripts/ensure-git-wt.sh new file mode 100755 index 0000000..7335d51 --- /dev/null +++ b/plugins/developer/skills/git-worktree/scripts/ensure-git-wt.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -euo pipefail + +# ensure-git-wt.sh — Clone or update the git-wt repo, then print its path. +# Usage: GIT_WT="$(./ensure-git-wt.sh)" + +readonly GIT_WT_REPO="https://github.com/vojtabiberle/git-wt.git" +readonly GIT_WT_PINNED_COMMIT="f44fbfe042b6f454e0016d5e844d773073600074" +readonly GIT_WT_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/git-wt" + +if [[ -d "$GIT_WT_DIR/.git" ]]; then + # Try to update existing clone; on failure, warn and keep using current version. + if ! git -C "$GIT_WT_DIR" fetch --quiet >&2 || \ + ! git -C "$GIT_WT_DIR" checkout --quiet "$GIT_WT_PINNED_COMMIT" >&2; then + echo "Warning: Failed to update git-wt in '$GIT_WT_DIR'; using existing version." >&2 + fi +else + # Clone fresh; on failure, provide a helpful error and exit. + if ! git clone --quiet "$GIT_WT_REPO" "$GIT_WT_DIR" >&2; then + echo "Error: Failed to clone git-wt from '$GIT_WT_REPO' into '$GIT_WT_DIR'." >&2 + echo "Please check your network connection and repository access, then try again." >&2 + exit 1 + fi + git -C "$GIT_WT_DIR" checkout --quiet "$GIT_WT_PINNED_COMMIT" >&2 || true +fi + +# Verify the executable exists +if [[ ! -f "$GIT_WT_DIR/git-wt" ]]; then + echo "ensure-git-wt.sh: expected git-wt executable not found at '$GIT_WT_DIR/git-wt'" >&2 + exit 1 +fi + +# Print the path to the git-wt executable on stdout +echo "$GIT_WT_DIR/git-wt" diff --git a/plugins/developer/templates/settings.json b/plugins/developer/templates/settings.json index 74e6000..6ef3273 100644 --- a/plugins/developer/templates/settings.json +++ b/plugins/developer/templates/settings.json @@ -14,6 +14,7 @@ "Bash(git status:*)", "Bash(git remote:*)", "Bash(git tag:*)", + "Bash(git worktree:*)", "Bash(find:*)", "Bash(cat:*)", "Bash(ls:*)",