Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created July 3, 2025 17:19
Show Gist options
  • Save anaisbetts/b140edf123d445139f971fe3030c9736 to your computer and use it in GitHub Desktop.
Save anaisbetts/b140edf123d445139f971fe3030c9736 to your computer and use it in GitHub Desktop.
Scripts for vibe coding
#!/bin/bash
## Run latest Claude Code but with all the security prompts disabled
set -euo pipefail
NPX="npx"
if command -v bunx >/dev/null 2>&1; then
NPX="bunx"
fi
exec /bin/env ENABLE_BACKGROUND_TASKS=1 FORCE_AUTO_BACKGROUND_TASKS=1 CLAUBBIT=1 "$NPX" @anthropic-ai/claude --dangerously-skip-permissions "$@"
#!/bin/bash
# Git subcommand to remove a worktree and its directory
# Usage: git worktree-clean <branch-name>
set -ueo pipefail
if [ $# -ne 1 ]; then
echo "Usage: git worktree-clean <branch-name>"
echo "Example: git worktree-clean feature-branch"
exit 1
fi
BRANCH_NAME="$1"
REPO_ROOT=$(git rev-parse --show-toplevel)
ORIGINAL_DIR_NAME=$(basename "$REPO_ROOT")
PARENT_DIR=$(dirname "$REPO_ROOT")
WORKTREE_PATH="$PARENT_DIR/$ORIGINAL_DIR_NAME-$BRANCH_NAME"
# Check if worktree exists in git's worktree list
if git worktree list | grep -q "$WORKTREE_PATH" || false; then
echo "Removing git worktree with branch '$BRANCH_NAME'..."
pushd "$WORKTREE_PATH"
git clean -xdf
popd
git worktree remove "$WORKTREE_PATH" --force
echo "Worktree with branch '$BRANCH_NAME' removed successfully!"
else
echo "Error: Worktree with branch '$BRANCH_NAME' not found in git worktree list"
echo "Available worktrees:"
git worktree list
exit 1
fi
#!/bin/bash
# Git subcommand to create a new worktree in a sibling directory
# Usage: git worktree-create <branch-name>
set -ueo pipefail
if [ $# -ne 1 ]; then
echo "Usage: git worktree-create <branch-name>"
echo "Example: git worktree-create feature-branch"
exit 1
fi
BRANCH_NAME="$1"
REPO_ROOT=$(git rev-parse --show-toplevel)
ORIGINAL_DIR_NAME=$(basename "$REPO_ROOT")
PARENT_DIR=$(dirname "$REPO_ROOT")
WORKTREE_PATH="$PARENT_DIR/$ORIGINAL_DIR_NAME-$BRANCH_NAME"
echo "Creating worktree with branch '$BRANCH_NAME' at '$WORKTREE_PATH'..."
# Create the worktree and new branch
git worktree add -b "$BRANCH_NAME" "$WORKTREE_PATH" HEAD
# Copy environment files
echo "Copying environment files..."
if [ -f "$REPO_ROOT/.env.local" ]; then
cp "$REPO_ROOT/.env.local" "$WORKTREE_PATH/.env.local"
echo "Copied .env.local"
fi
if [ -f "$REPO_ROOT/.env.example" ]; then
cp "$REPO_ROOT/.env.example" "$WORKTREE_PATH/.env.example"
echo "Copied .env.example"
fi
# Change to worktree directory and install dependencies
echo "Installing dependencies..."
cd "$WORKTREE_PATH"
# Detect package manager based on lock files
if [ -f "bun.lockb" ] || [ -f "bun.lock" ]; then
echo "Detected Bun (found bun.lockb or bun.lock)"
bun install
elif [ -f "package-lock.json" ]; then
echo "Detected npm (found package-lock.json)"
npm install
elif [ -f "yarn.lock" ]; then
echo "Detected Yarn (found yarn.lock)"
yarn install
elif [ -f "pnpm-lock.yaml" ]; then
echo "Detected pnpm (found pnpm-lock.yaml)"
pnpm install
else
echo "No lock file detected, defaulting to npm install"
npm install
fi
echo "Worktree with branch '$BRANCH_NAME' created successfully!"
echo "Directory: $WORKTREE_PATH"
echo "To switch to the worktree: cd $WORKTREE_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment