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

# Plan & Apply

> Preview and push changes to the hub

The plan and apply workflow lets you preview changes before deploying them — similar to Terraform.

## Plan

`griffin plan` compares your local monitor files against what's deployed on the hub and shows the diff:

```bash theme={null}
griffin plan
griffin plan production
griffin plan --monitor health-check
griffin plan --env production --monitor health-check
```

Use `--monitor <name>` to preview changes for only that monitor.

Example output:

```
Monitors to create:
  + health-check
  + user-crud

Monitors to update:
  ~ payment-flow (frequency changed)

Monitors unchanged:
  = auth-check

2 to create, 1 to update, 1 unchanged
```

### CI/CD usage

`griffin plan` exits with code **2** when there are pending changes and **0** when everything is in sync. This makes it useful in CI pipelines:

```bash theme={null}
griffin plan || echo "Changes pending"
```

Use `--json` for machine-readable output:

```bash theme={null}
griffin plan --json
```

## Apply

`griffin apply` pushes your local monitors to the hub:

```bash theme={null}
griffin apply
griffin apply production
# Apply only a single monitor by name
griffin apply --monitor health-check
griffin apply --env production --monitor health-check
```

Use `--monitor <name>` to create or update only that monitor. By default, it shows you what will change and asks for confirmation. Use flags to customize:

```bash theme={null}
# Skip confirmation
griffin apply --auto-approve

# Preview without making changes
griffin apply --dry-run

# Delete monitors that no longer exist locally
griffin apply --prune
```

### The prune flag

Without `--prune`, `apply` only creates and updates monitors. Monitors that exist on the hub but not locally are left untouched.

With `--prune`, monitors on the hub that don't have a corresponding local monitor file are deleted.

```bash theme={null}
# Safe: only creates/updates
griffin apply

# Destructive: also deletes removed monitors
griffin apply --prune
```

<Warning>
  Use `--prune` carefully. Always run `griffin plan` first to verify what will be deleted.
</Warning>

## Validate and test (with optional filter)

You can restrict validation or local runs to a single monitor by name:

```bash theme={null}
griffin validate --monitor health-check
griffin test --monitor health-check
griffin test --env staging --monitor health-check
```

## Typical workflow

```bash theme={null}
# 1. Write or modify monitor files in __griffin__/

# 2. Test locally
griffin test

# 3. Preview changes
griffin plan production

# 4. Deploy
griffin apply production
```
