Getting Started Quick Start - aku11i/phantom GitHub Wiki

Quick Start Guide

Get Phantom up and running in 5 minutes! This guide covers installation and basic usage.

Installation

Global Installation (Recommended)

# Using npm
npm install -g @aku11i/phantom

# Using pnpm
pnpm add -g @aku11i/phantom

# Verify installation
phantom --version

Requirements

  • Node.js v22.0.0 or higher
  • Git (with worktree support)

Basic Usage

Creating Your First Phantom

A "phantom" is a Git worktree - a separate working directory linked to your repository.

# Navigate to any Git repository
cd your-git-repo

# Create a phantom from the current branch
phantom create my-feature

# Create a phantom from a specific branch
phantom create bugfix-123 origin/production

Working with Phantoms

List All Phantoms

phantom list

# Output example:
# NAME           BRANCH              PATH
# my-feature     feature/new-ui      /var/tmp/phantom/repo/my-feature
# bugfix-123     fix/critical-bug    /var/tmp/phantom/repo/bugfix-123

Execute Commands in a Phantom

# Run any command inside a phantom
phantom exec my-feature npm test
phantom exec my-feature git status

# Run multiple commands
phantom exec my-feature "npm install && npm test"

Interactive Shell

# Enter an interactive shell in the phantom
phantom shell my-feature

# You're now in the phantom's directory
# Run any commands as normal
npm install
npm test
git commit -m "Add feature"

# Exit when done
exit

Get Phantom Location

# Print the path to a phantom
phantom where my-feature
# Output: /var/tmp/phantom/repo/my-feature

# Use in scripts
cd $(phantom where my-feature)

Delete a Phantom

# Remove a phantom (worktree)
phantom delete my-feature

# This removes the worktree but preserves the branch

Real-World Examples

Example 1: Feature Development

# Create a phantom for new feature
phantom create new-dashboard

# Enter the phantom
phantom shell new-dashboard

# Inside the phantom shell:
git checkout -b feature/dashboard
npm install
npm run dev
# Make changes, test, commit...
exit

# Back in main worktree, continue other work

Example 2: Quick Bug Fix

# Create phantom from production branch
phantom create hotfix origin/production

# Make the fix
phantom exec hotfix "git checkout -b hotfix/security-patch"
phantom exec hotfix "npm test"

# Review changes
phantom shell hotfix
git diff
git commit -m "Fix security vulnerability"
git push origin hotfix/security-patch
exit

# Clean up
phantom delete hotfix

Example 3: Code Review

# Review a colleague's PR
phantom create review-pr-42 origin/feature/new-api

# Run tests and check code
phantom exec review-pr-42 npm test
phantom exec review-pr-42 npm run lint

# Explore interactively
phantom shell review-pr-42

Example 4: Parallel Development

# Work on multiple features simultaneously
phantom create feature-a
phantom create feature-b
phantom create feature-c

# Run tests in parallel
phantom exec feature-a npm test &
phantom exec feature-b npm test &
phantom exec feature-c npm test &
wait

# Check status of all
phantom list

Command Reference

Command Description Example
create Create a new phantom phantom create <name> [branch]
delete Remove a phantom phantom delete <name>
list List all phantoms phantom list
exec Run command in phantom phantom exec <name> <command>
shell Enter phantom shell phantom shell <name>
where Get phantom path phantom where <name>
--version Show version phantom --version
--help Show help phantom --help

Tips and Best Practices

1. Naming Conventions

Use descriptive names for your phantoms:

  • Feature branches: feature-login, feature-dashboard
  • Bug fixes: fix-memory-leak, bugfix-123
  • Reviews: review-pr-42, review-api-changes

2. Cleanup Regularly

# List phantoms to see what can be cleaned up
phantom list

# Delete phantoms you're done with
phantom delete old-feature

3. Use with Git Workflows

# Create phantom for each PR review
phantom create pr-$(git rev-parse --short HEAD)

# Create phantom for each active ticket
phantom create ticket-JIRA-123

4. Scripting

# Use in scripts
PHANTOM_PATH=$(phantom where my-feature)
if [ -d "$PHANTOM_PATH" ]; then
    cd "$PHANTOM_PATH"
    npm test
fi

Common Use Cases

Running Multiple Development Servers

# Start different versions simultaneously
phantom exec v1 "npm run dev -- --port 3001" &
phantom exec v2 "npm run dev -- --port 3002" &
phantom exec v3 "npm run dev -- --port 3003" &

AI Agent Development

Perfect for running multiple AI coding sessions:

# Create isolated environments for AI agents
phantom create ai-agent-1
phantom create ai-agent-2

# Each agent works in its own phantom
# No conflicts or confusion between parallel sessions

Continuous Integration Testing

# Test against multiple configurations
phantom create test-node-20
phantom create test-node-22

phantom exec test-node-20 "nvm use 20 && npm test"
phantom exec test-node-22 "nvm use 22 && npm test"

Troubleshooting

Phantom Creation Fails

  • Ensure you're in a Git repository
  • Check that the branch exists: git branch -a
  • Verify Git worktree support: git worktree list

Command Not Found

  • Verify installation: npm list -g @aku11i/phantom
  • Check Node.js version: node --version (needs v22+)
  • Try reinstalling: npm install -g @aku11i/phantom

Permission Errors

  • Phantom creates worktrees in /tmp by default
  • Ensure you have write permissions
  • Check disk space: df -h

Next Steps

⚠️ **GitHub.com Fallback** ⚠️