# Advanced Scripting

Most commands support `--format=json` for easy parsing with `jq`:

**Get transaction count by category:**

bash

```bash
kick transactions list --format=json | \
  jq 'group_by(.category) | map({category: .[0].category, count: length})'
```

**Find largest transactions:**

bash

```bash
kick transactions list --format=json | \
  jq 'sort_by(.amount) | reverse | .[0:10]'
```

**Calculate averages:**

bash

```bash
kick transactions list --format=json | \
  jq 'group_by(.counterparty) | map({counterparty: .[0].counterparty, avg: (map(.amount) | add / length)})'
```

{% endtab %}

{% tab title="Environment Variables" %} Set defaults to avoid repeating flags:

bash

```bash
export KICK_WORKSPACE="Client Name"
export KICK_ENTITY="ACME Corp"
export KICK_FORMAT="json"

# Commands use these defaults
kick transactions list
kick reports pl --period="2026-01"
```

**Available variables:**

* `KICK_WORKSPACE` — Default workspace
* `KICK_ENTITY` — Default entity
* `KICK_FORMAT` — Default output format {% endtab %}

{% tab title="Configuration File" %} Store settings in `~/.kick/config.yaml`:

yaml

```yaml
workspace: Client Name
entity: ACME Corp
default_format: json
```

Commands automatically use these settings unless overridden with flags. {% endtab %} {% endtabs %}

***

#### Scheduling Scripts

Run scripts automatically with cron (Linux/Mac):

bash

```bash
# Edit crontab
crontab -e

# Daily at 9am: Unreconciled transaction alert
0 9 * * * /path/to/daily-recon-alert.sh

# First day of month: Generate monthly reports
0 8 1 * * /path/to/monthly-pl-reports.sh

# Every Monday: Export to warehouse
0 10 * * 1 /path/to/export-to-warehouse.sh

# Every hour: Sync to Google Sheets
0 * * * * /path/to/sync-to-sheets.sh
```

For Windows, use Task Scheduler.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kick.co/ai/kick-cli/cli-use-case-library/advanced-scripting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
