# CLI

The CLI applies completed task patches to your local repositories. It bridges server-based AI work with your local development.

## Installation

```bash
npm install -g @profoundlogic/coderflow-cli
```

## Connecting to the Server

```bash
coder login
```

Enter your server URL and credentials when prompted.

## Applying Patches

Apply changes from a completed task to your local repos:

```bash
# Interactive selection from completed tasks
coder apply

# Apply a specific task
coder apply <task-id>

# Apply only certain files
coder apply --include="*.js"
```

Changes are staged (`git add`) but not committed, so you can review before committing.

## Discarding Changes

Undo applied changes (unstage, restore, clean):

```bash
# Discard in default environment
coder discard

# Discard in specific environment
coder discard --env=myproject

# Skip confirmation
coder discard --yes
```

## Attaching to Containers

```bash
# Connect to last container
coder attach

# Connect with bash shell
coder attach --shell

# Connect to specific container
coder attach <container-id>
```

## Configuration and Profiles

Manage connection settings:

```bash
# Show current config
coder config show

# Set server URL
coder config set serverUrl http://myserver:3000
```

Use profiles to connect to different servers:

```bash
# Create profile
coder profile create production

# Switch profiles
coder profile switch production

# Use profile for one command
coder --profile=production apply
```

## Getting Help

```bash
# General help
coder --help

# All commands
coder --help-all

# Help for specific command
coder apply --help
```

Task management commands are available for when you prefer CLI over the Web UI. Run `coder --help-all` to see `run`, `status`, `results`, `list`, and more.
