# CLI Data & Telemetry

The Swytchcode CLI is designed to be production-ready while respecting developer workflows and privacy.

In addition to executing tools and managing integrations, the CLI can optionally collect anonymous telemetry, operate without an internet connection, synchronize execution history across devices, and measure API usage for billing.

These features are independent of tool execution and can be configured based on your environment.

---

## Telemetry

Swytchcode can optionally report anonymous command-outcome events to help improve the reliability and performance of the CLI.

Telemetry is designed to be lightweight and never affects the execution of your commands.

Information that may be collected includes:

- The CLI command that was executed
- Whether the command succeeded or failed
- Execution duration
- CLI version
- Platform information

Telemetry does **not** change how your application behaves and is never required for normal CLI operation.

---

### When is telemetry sent?

Telemetry is only sent when the CLI can associate events with an authenticated account.

This includes:

- Users logged in with `swy login`
- CI environments using `SWYTCHCODE_TOKEN`

If you are not authenticated, telemetry events are not sent.

---

### Non-blocking by design

Telemetry is completely asynchronous.

Command execution never waits for telemetry to complete.

If telemetry cannot be delivered—for example because you're offline or the telemetry service is unavailable—your command continues normally.

Telemetry failures never affect:

- command output
- exit codes
- tool execution
- API requests

---

### Disabling telemetry

Telemetry, product analytics, and crash-report consent are controlled by a single switch: `telemetry_enabled`.

```bash
swy config telemetry disable
```

Check the current state at any time:

```bash
swy config telemetry status
```

You can also read or set the underlying key directly:

```bash
swy config get telemetry_enabled
swy config set telemetry_enabled false
```

Once disabled, no telemetry, analytics, or crash-report events are sent - there is no separate opt-in for any of them.

---

## Offline Mode

Swytchcode can operate without continuous internet access.

When offline mode is enabled, the CLI disables all non-essential outbound network communication.

This includes:

- Telemetry
- Cloud synchronization
- Other background services

Core developer workflows continue to function normally.

For example, you can still:

- Execute locally configured tools
- Access project configuration
- Use cached integrations
- View local execution history

Offline mode is useful for:

- Secure enterprise environments
- Air-gapped systems
- Local development
- Travel or unreliable network conditions

---

## Local Execution History

Regardless of whether telemetry or cloud sync is enabled, Swytchcode maintains a local history of CLI activity under `~/.swytchcode/audit/`: outbound network calls, policy-violation entries, and execution stats.

This history allows the CLI to keep track of previous executions without relying on an internet connection, and remains available even when running completely offline.

```bash
swy audit stats            # total runs, success rate, last run, top provider
swy audit network [-n N]   # recent outbound network calls
swy audit policy [-n N]    # recent policy-violation entries
swy audit clear            # delete all local audit files
```

Every network call and policy-violation entry gets a unique id (`nw_...` / `pol_...`) - pass it to `swy audit network --info <id>` or `swy audit policy --info <id>` for full detail. See the [Command Reference](/reference/commands/#system) for the complete `swy audit` surface.

---

## Cloud Sync

Cloud Sync is an optional feature that synchronizes your local audit trail (execution metadata, never payloads) with your Swytchcode workspace.

Once enabled, execution history becomes available from the Swytchcode dashboard, making it easier to review previous runs across multiple machines.

```bash
swy config cloud enable
swy config cloud status
swy config cloud disable
```

Cloud Sync is:

- Optional and disabled by default
- Available only on a paid plan
- Managed only through `swy config cloud` - it is not a plain `config get`/`set` key like `telemetry_enabled`

Because Cloud Sync operates independently of tool execution, disabling it does not affect the runtime or API calls.

---

## Usage Metering

Live API executions are measured for usage and billing purposes.

Only real executions are metered.

Operations such as:

- Dry runs
- Demo executions
- Local validation

are not included in usage measurements.

Usage metering is separate from telemetry.

Disabling telemetry does **not** disable usage metering for billable executions.

---

## Privacy

Swytchcode separates operational data from runtime execution.

- Telemetry helps improve the CLI experience.
- Cloud Sync stores execution history for your workspace.
- Usage metering tracks billable executions.
- Tool execution continues independently of these services.

You can choose whether to enable telemetry and Cloud Sync without affecting how your applications execute tools.

---

## Best Practices

For most development environments, we recommend:

- Enable telemetry to help improve CLI reliability.
- Use Offline Mode when working in restricted environments.
- Enable Cloud Sync if you work across multiple machines.
- Review your organization's privacy and compliance requirements before enabling telemetry.
- Disable telemetry in environments where outbound analytics are not permitted.

---

## What's Next?

- [Authentication](https://docs.swytchcode.com/cli/authentication/) - Learn how the CLI authenticates your account and securely manages provider credentials.
- [Execute Tools](https://docs.swytchcode.com/cli/exec/) - Understand how Swytchcode validates, authenticates, and executes tool calls.
- [Managed Authentication](https://docs.swytchcode.com/guides/managed-authentication/) - Explore how provider credentials are securely resolved during execution.
- [CLI Overview](https://docs.swytchcode.com/cli/overview/) - Learn more about the architecture and core concepts of the Swytchcode CLI.
