npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aurbano/twig

v1.4.0

Published

CLI tool to manage multiple Git worktrees and isolated dev containers for LLM-friendly concurrent feature development.

Readme

🌿 Twig

NPM Version

Lightweight CLI to manage multiple Git worktrees with optional VSCode Dev Container integration. Perfect for concurrent feature development with LLM coding assistants.

Why?

twig makes it effortless to work on multiple branches of the same repo at the same time in isolated folders that are mapped to git branches.

This can be useful for traditional development, where you might need to do a quick bug fix without leaving the branch you were working on. And it can be even more useful for LLM-assisted coding, allowing you to have multiple parallel instances working independently.

Installation

npm install -g @aurbano/twig

# Optional: Enable tab completion
twig completion --setup

Usage

Run from the root of the repo you want to work with.

# Switch to a branch worktree (creates it if it doesn't exist)
twig branch <branch-or-path>
twig b <branch-or-path>  # short alias

# List all worktrees
twig list
twig ls  # short alias

# Delete a worktree
twig delete <branch-or-path>
twig d <branch-or-path>  # short alias

# Remove orphaned worktrees (branches that no longer exist)
twig prune
twig p  # short alias

# Initialize dev container configuration
twig init-devcontainer [options]
twig i [options]  # short alias

# Enable shell completion (bash/zsh)
twig completion --setup

Options

branch

  • --base <base> - Base branch for new worktrees (auto-detects main or master if not specified)
  • -d, --dir <dir> - Target directory for new worktrees (default: ../<repo>-<branch>)
  • --in-container - Start dev container before opening
  • -y, --yes - Skip confirmation prompts when creating new worktrees

delete

  • --keep-branch - Keep the git branch after removing worktree
  • -y, --yes - Skip confirmation prompts

prune

  • -y, --yes - Skip confirmation prompts

init-devcontainer

  • --image <img> - Base Docker image
  • --packages <list> - Space-separated apt packages to install
  • --ports <csv> - Comma-separated ports to forward (e.g., 3000,8080)
  • --postcreate <cmd> - Command to run after container creation
  • --mount-node-modules - Add node_modules volume mount

completion

  • --setup - Install shell completion (bash/zsh)
  • --cleanup - Remove shell completion

Shell Completion

Tab completion makes using twig much faster by auto-completing commands and git branches.

Installation

# Install shell completion (works for bash and zsh)
twig completion --setup

# Then restart your terminal or source your shell config:
source ~/.bashrc  # for bash
source ~/.zshrc   # for zsh

To remove completion:

twig completion --cleanup

What Gets Completed

  • Commands: branch, list, delete, prune, init-devcontainer (and all their aliases: b, ls, d, p, i)
  • Git branches: When using twig branch <TAB>, all your local git branches will be suggested
  • Worktree branches: When using twig delete <TAB>, only branches that have active worktrees will be suggested

Configuration

twig allows you to configure which editor to open when switching to a worktree. While the shell has an $EDITOR variable, most developers set it to vim for terminal use, even if they prefer Cursor, VS Code, or Claude for their main development.

Config File Locations

twig looks for configuration in the following order (first match wins):

  1. Per-project: .twig file in the repository root
  2. Global:
    • ~/.config/twig/config.json (Linux/macOS)
    • %APPDATA%\twig\config.json (Windows)
  3. Smart defaults: Auto-detected based on project markers (see below)
  4. Fallback: Tries cursor, then code commands

Config Format

You can use either a simple string format or a structured format for more control:

Simple format (most common):

{
  "editor": "cursor"
}

Structured format (with custom arguments):

{
  "editor": {
    "command": "cursor",
    "args": ["--wait", "."]
  }
}

Supported Editor Shortcuts

Common editor shortcuts are recognized and will use friendly names in output:

  • cursor - Cursor AI editor
  • code - Visual Studio Code
  • claude - Claude.ai editor
  • vim - Vim
  • nvim - Neovim
  • emacs - Emacs
  • nano - Nano
  • Custom commands and full paths are also supported

Smart Defaults

If no configuration file is found, twig will try to detect your preferred editor based on project markers:

  • .cursor/ folder → Opens with Cursor
  • .vscode/ folder → Opens with VS Code
  • .claude/ folder → Opens with Claude

This means projects will automatically open in the right editor without any configuration in most cases.

Configuration Examples

Skip editor launch entirely (useful if you prefer to open editors manually):

{
  "editor": "none"
}

Use Vim (great for quick edits):

{
  "editor": "vim"
}

Use custom editor with specific arguments:

{
  "editor": {
    "command": "code",
    "args": ["--new-window", "--goto", "."]
  }
}

Use custom editor path:

{
  "editor": "/usr/local/bin/my-editor"
}

Per-project override: Create a .twig file in your repo:

echo '{"editor": "vim"}' > .twig

You can add .twig to .gitignore for personal preferences, or commit it for team-wide defaults.

Examples

Basic Workflow

# Switch to a feature branch (creates worktree if it doesn't exist)
# Base branch (main/master) is automatically detected
twig branch feature/new-api

# Work on the feature...

# List all active worktrees
twig list

# Switch to another worktree (or create it if it doesn't exist)
twig branch hotfix/urgent-bug

# Clean up when done
twig delete feature/new-api

# Or, if you deleted branches directly with git, clean up orphaned worktrees
# git branch -D feature/old-feature
twig prune

With Dev Containers

# Initialize dev container in your repository
twig init-devcontainer \
  --image mcr.microsoft.com/devcontainers/typescript-node:20 \
  --packages "git curl" \
  --ports "3000,8080" \
  --postcreate "npm install"

# Switch to worktree and start it in a container (creates if needed)
twig branch feature/containerized --in-container

# Switch to existing worktree in its container
twig branch main --in-container

Multi-Feature Development

# Work on multiple features simultaneously
twig branch feature/auth
twig branch feature/api
twig branch feature/ui

# Each worktree is isolated with its own:
# - Working directory
# - Git branch
# - Optional dev container

Automatic Cleanup

When you use twig branch for the first time, it automatically installs a git post-checkout hook that prunes orphaned worktrees. This means if you delete a branch directly (e.g., git branch -D feature/old), the corresponding worktree will be automatically removed the next time you checkout a branch.

You can also manually trigger cleanup anytime:

twig prune

Development

Prerequisites

  • Node.js 22+
  • Git 2.5+

Setup

# Clone and install
git clone https://github.com/aurbano/twig.git
cd twig
npm install  # This also sets up git hooks via husky

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

# Type check
npm run typecheck

Note: A pre-commit hook is automatically installed that runs lint and typecheck before each commit.

Running Locally

# Build and run
npm run build
node dist/index.js <command>

# Or use npm link for global testing
npm link
twig <command>