# Commands

Complete reference for all CLI commands

## [`create`](/content/docs/cli/commands#create/index.html)

Creates a new StackPatch project from scratch.

```
npx stackpatch create [project-directory]
```

### [Usage](/content/docs/cli/commands#usage/index.html)

```
# Interactive (prompts for project name)
npx stackpatch create

# With project name
npx stackpatch create my-app

# Using npm create
npm create stackpatch@latest my-app

# Using bunx
bunx create-stackpatch@latest my-app
```

### [What Gets Created](/content/docs/cli/commands#what-gets-created/index.html)

- ✅ New Next.js project with TypeScript and Tailwind CSS
- ✅ Basic project structure
- ✅ All dependencies installed
- ✅ Welcome screen

After creation, add patches with `npx stackpatch add`.

## [`add`](/content/docs/cli/commands#add/index.html)

Adds patches (features) to an existing Next.js project.

```
npx stackpatch add [patch-name]
```

### [Available Patches](/content/docs/cli/commands#available-patches/index.html)

- **`auth`** or **`auth-ui`** \- Complete authentication setup

### [Usage](/content/docs/cli/commands#usage-1/index.html)

```
# Interactive mode (select patch)
npx stackpatch add

# Add auth patch directly
npx stackpatch add auth

# Alternative name
npx stackpatch add auth-ui
```

### [Interactive Mode](/content/docs/cli/commands#interactive-mode/index.html)

If you don't specify a patch name, you'll be prompted to:

1. **Select a patch** from available options
2. **Choose OAuth providers**(if installing auth):
   - Google OAuth
   - GitHub OAuth
   - Email/Password (Credentials)

### [What Gets Added](/content/docs/cli/commands#what-gets-added/index.html)

When you add a patch, StackPatch:

1. **Detects** your project structure (`app/` vs `src/app/`)
2. **Copies** files to correct locations
3. **Installs** missing dependencies
4. **Updates** your code (e.g., adds providers to `layout.tsx`)
5. **Tracks** all changes in `.stackpatch/manifest.json`

See [Guides](/content/docs/guides/index.html) for details on available patches.

## [`revert`](/content/docs/cli/commands#revert/index.html)

Reverts a StackPatch installation, restoring your project to its previous state.

```
npx stackpatch revert
```

### [Usage](/content/docs/cli/commands#usage-2/index.html)

```
# Revert the last installation
npx stackpatch revert
```

### [What Happens](/content/docs/cli/commands#what-happens/index.html)

1. **Shows** what will be reverted (patch name, files, timestamp)
2. **Asks** for confirmation
3. **Removes** all files added by StackPatch
4. **Restores** all modified files to the original state
5. **Uninstalls** dependencies added by StackPatch
6. **Cleans up** the `.stackpatch` directory

> **Note:** You must be in the directory where you ran `stackpatch add`. The command uses `.stackpatch/manifest.json` to track changes.

See [FAQ](/content/docs/faq/index.html) for information about reverting changes.

## [Command Examples](/content/docs/cli/commands#command-examples/index.html)

### [Create and Setup](/content/docs/cli/commands#create-and-setup/index.html)

```
# 1. Create a new project
npx stackpatch create my-app

# 2. Navigate to project
cd my-app

# 3. Add authentication
npx stackpatch add auth
```

### [Add to Existing Project](/content/docs/cli/commands#add-to-existing-project/index.html)

```
# Navigate to your Next.js project
cd my-existing-project

# Add authentication
npx stackpatch add auth
```

### [Revert Installation](/content/docs/cli/commands#revert-installation/index.html)

```
# Undo the last installation
npx stackpatch revert
```

## [Global Options](/content/docs/cli/commands#global-options/index.html)

These options work with any command:

- `--help, -h` \- Display help information
- `--version, -V` \- Display CLI version
- `--yes, -y` \- Skip prompts (for `create` command)

## [Next Steps](/content/docs/cli/commands#next-steps/index.html)

- [Quick Start](/content/docs/quick-start/index.html) \- Learn how to add your first patch
- [Guides](/content/docs/guides/index.html) \- Practical guides for common setups
- [FAQ](/content/docs/faq/index.html) \- Frequently asked questions
