# struere diff

> Show content differences between local and remote resources

The `diff` command compares your local resource definitions against the remote deployed state, showing per-field content diffs with colored `+`/`-` lines.

## Usage

```bash
bunx struere diff
bunx struere diff --env production
bunx struere diff --resource agents --name support
bunx struere diff --stat
```

## Flags

| Flag | Description |
|------|-------------|
| `--env <environment>` | Environment: `development`, `production`, or `eval`. Default: `development` |
| `--resource <type>` | Filter by resource type: `agents`, `triggers`, `entity-types`, `roles`, `routers` |
| `--name <slug>` | Filter to a specific resource by slug |
| `--json` | Output results as structured JSON |
| `--stat` | Show summary only (changed field counts), no content diff |

## What It Does

The `diff` command:

1. Loads all local resource definitions from your project directories
2. Fetches the current remote state for the target environment
3. Compares each resource field-by-field
4. Displays a unified diff with colored `+`/`-` lines for each changed field

Resources that exist only locally are shown as entirely new (`+`). Resources that exist only remotely are shown as deletions (`-`).

## Example Output

```
agents/support (support)
────────────────────────────────────────────────────────────
  systemPrompt:
    - You are a helpful support agent.
    + You are a helpful support agent for Acme Corp.
  model:
    - openai/gpt-5-mini
    + anthropic/claude-sonnet-4

triggers/daily-report (daily-report)
────────────────────────────────────────────────────────────
  schedule:
    - 0 9 * * *
    + 0 8 * * *
```

## Stat Mode

Use `--stat` for a summary without the full diff content:

```bash
bunx struere diff --stat
```

```
agents/support         2 fields changed
triggers/daily-report  1 field changed

2 resources changed, 3 fields total
```

## JSON Output

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

```bash
bunx struere diff --json
```

Returns a JSON object with per-resource diffs, each containing the resource type, slug, and an array of field changes with `field`, `local`, and `remote` values.

## Filtering

Narrow the diff to a specific resource type or individual resource:

```bash
# Only show agent diffs
bunx struere diff --resource agents

# Only show diffs for a specific agent
bunx struere diff --resource agents --name support

# Only show trigger diffs in production
bunx struere diff --resource triggers --env production
```

## Relationship with Other Commands

| Command | What it does |
|---------|-------------|
| `struere status` | Shows which resources are new, synced, or deleted (no content diff) |
| `struere diff` | Shows per-field content differences between local and remote |
| `struere deploy` | Syncs local files to production |
| `struere pull` | Syncs remote to local (overwrites local files) |

Use `struere status` to see which resources changed at a glance, then `struere diff` to inspect exactly what changed before deploying.
