> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/argoproj/argo-cd/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Overview

> Get started with the Argo CD command-line interface, including authentication and common usage patterns

The Argo CD CLI (`argocd`) provides a complete interface for managing your GitOps deployments. This page covers authentication, configuration, and common usage patterns.

## Global Flags

The CLI supports numerous global flags that apply to all commands:

```bash theme={null}
argocd [command] [flags]
```

### Authentication Flags

<ParamField path="--server" type="string">
  Argo CD server address
</ParamField>

<ParamField path="--auth-token" type="string">
  Authentication token (or set `ARGOCD_AUTH_TOKEN` environment variable)
</ParamField>

<ParamField path="--argocd-context" type="string">
  The name of the Argo CD server context to use
</ParamField>

### Connection Flags

<ParamField path="--insecure" type="boolean">
  Skip server certificate and domain verification
</ParamField>

<ParamField path="--plaintext" type="boolean">
  Disable TLS
</ParamField>

<ParamField path="--grpc-web" type="boolean">
  Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2
</ParamField>

<ParamField path="--port-forward" type="boolean">
  Connect to a random argocd-server port using port forwarding
</ParamField>

<ParamField path="--port-forward-namespace" type="string">
  Namespace name which should be used for port forwarding
</ParamField>

### Kubernetes Flags

<ParamField path="--core" type="boolean">
  If set to true, CLI talks directly to Kubernetes instead of Argo CD API server
</ParamField>

<ParamField path="--kube-context" type="string">
  Directs the command to the given kube-context
</ParamField>

## Authentication

### Login to Argo CD Server

Authenticate with username and password:

```bash theme={null}
argocd login cd.example.com
```

You'll be prompted for credentials:

```
WARNING: server certificate had error: x509: certificate signed by unknown authority. Proceed insecurely (y/n)? y
Username: admin
Password: 
'admin:login' logged in successfully
Context 'cd.example.com' updated
```

### SSO Login

Login using Single Sign-On:

```bash theme={null}
argocd login cd.example.com --sso
```

This will open your browser for SSO authentication.

### Skip TLS Verification

For testing or self-signed certificates:

```bash theme={null}
argocd login cd.example.com --insecure
```

<Warning>
  Using `--insecure` is not recommended for production environments as it skips certificate verification.
</Warning>

### Using Authentication Tokens

Generate and use an authentication token:

```bash theme={null}
# Generate a token
argocd account generate-token --account admin

# Use the token
argocd app list --auth-token <your-token> --server cd.example.com

# Or set it as an environment variable
export ARGOCD_AUTH_TOKEN=<your-token>
argocd app list --server cd.example.com
```

### Core Mode (Direct Kubernetes Access)

For administrative tasks without going through the API server:

```bash theme={null}
argocd login cd.example.com --core
```

## Configuration File

The CLI stores configuration in `~/.config/argocd/config` (or `$HOME/.argocd/config` on older versions):

```yaml theme={null}
contexts:
- name: cd.example.com
  server: cd.example.com
  user: admin
current-context: cd.example.com
users:
- auth-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
  name: admin
  refresh-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
```

### Manage Contexts

Switch between multiple Argo CD servers:

```bash theme={null}
# List available contexts
argocd context

# Switch context
argocd context cd.example.com
```

## Common Usage Patterns

### Quick Application Status

```bash theme={null}
# List all applications
argocd app list

# Get specific application
argocd app get my-app

# Watch application sync status
argocd app wait my-app --health
```

### Sync and Deploy

```bash theme={null}
# Sync an application
argocd app sync my-app

# Sync with preview
argocd app diff my-app
argocd app sync my-app

# Force sync (override protections)
argocd app sync my-app --force
```

### Multiple Output Formats

Most commands support different output formats:

```bash theme={null}
# JSON output
argocd app list -o json

# YAML output
argocd app get my-app -o yaml

# Wide format (more details)
argocd cluster list -o wide
```

## Port Forwarding

Access Argo CD without external exposure:

```bash theme={null}
# Use port forwarding for all commands
argocd app list --port-forward --port-forward-namespace argocd

# Or configure it in your context
argocd login --port-forward --port-forward-namespace argocd
```

## Shell Completion

Enable shell completion for faster command entry:

<Tabs>
  <Tab title="Bash">
    ```bash theme={null}
    # Add to ~/.bashrc
    source <(argocd completion bash)

    # Or install globally
    argocd completion bash > /etc/bash_completion.d/argocd
    ```
  </Tab>

  <Tab title="Zsh">
    ```bash theme={null}
    # Add to ~/.zshrc
    source <(argocd completion zsh)

    # Or for Oh My Zsh
    argocd completion zsh > "${fpath[1]}/_argocd"
    ```
  </Tab>

  <Tab title="Fish">
    ```bash theme={null}
    argocd completion fish | source

    # To load completions for each session
    argocd completion fish > ~/.config/fish/completions/argocd.fish
    ```
  </Tab>
</Tabs>

## Troubleshooting

### Connection Issues

```bash theme={null}
# Test connection
argocd version

# Enable debug logging
argocd app list --loglevel debug

# Skip TLS verification (temporary)
argocd app list --insecure
```

### Authentication Expiry

If your token expires:

```bash theme={null}
# Re-login
argocd relogin

# Or login again
argocd login cd.example.com
```

## Available Commands

<CardGroup cols={2}>
  <Card title="app" icon="rocket" href="/cli/app">
    Manage applications
  </Card>

  <Card title="appset" icon="layer-group" href="/cli/appset">
    Manage ApplicationSets
  </Card>

  <Card title="cluster" icon="server" href="/cli/cluster">
    Manage cluster credentials
  </Card>

  <Card title="repo" icon="code-branch" href="/cli/repo">
    Manage repository connections
  </Card>

  <Card title="project" icon="folder" href="/cli/project">
    Manage projects
  </Card>

  <Card title="admin" icon="user-shield" href="/cli/admin">
    Administrative commands
  </Card>

  <Card title="account" icon="user" href="/cli/account">
    Manage account settings
  </Card>
</CardGroup>

## Environment Variables

<ParamField path="ARGOCD_AUTH_TOKEN" type="string">
  Authentication token to avoid passing `--auth-token` flag
</ParamField>

<ParamField path="ARGOCD_SERVER" type="string">
  Argo CD server address to avoid passing `--server` flag
</ParamField>

<ParamField path="ARGOCD_OPTS" type="string">
  Additional CLI options applied to all commands
</ParamField>

## Next Steps

<CardGroup cols={2}>
  <Card title="App Commands" icon="rocket" href="/cli/app">
    Learn application management commands
  </Card>

  <Card title="Cluster Commands" icon="server" href="/cli/cluster">
    Configure cluster connections
  </Card>
</CardGroup>
