Automation Rules

Create Rules from Transaction Patterns

The Script

#!/bin/bash
# suggest-rules.sh

kick transactions list \
  --from="2025-01-01" \
  --format=json | \
jq -r '
  group_by(.counterparty) |
  map(select(length >= 10)) |
  map({
    counterparty: .[0].counterparty,
    count: length,
    categories: [.[].category] | unique
  }) |
  map(select(.categories | length == 1)) |
  .[] |
  "Suggested rule: counterparty=\"\(.counterparty)\" → category=\"\(.categories[0])\" (based on \(.count) transactions)"
'

echo ""
echo "Create rules with: kick rules create --condition=\"counterparty=<name>\" --action=\"set-category:<category>\""

How to Customize

  • Adjust minimum transaction count threshold

  • Look at description patterns instead of counterparties

  • Auto-create rules instead of just suggesting

What It Outputs

Suggested rule: counterparty="Amazon Web Services" → category="Cloud Infrastructure" (based on 47 transactions)
Test Rules Before Deploying

The Script

#!/bin/bash
# test-rule.sh

CONDITION="description contains 'AWS'"
NEW_CATEGORY="Cloud Infrastructure"

echo "Testing rule: $CONDITION$NEW_CATEGORY"
echo ""

kick transactions list \
  --filter="$CONDITION" \
  --format=json | \
jq -r '.[] | "Would update: \(.date) | \(.amount) | \(.counterparty) | Current category: \(.category // "none")"'

echo ""
count=$(kick transactions list --filter="$CONDITION" --format=json | jq 'length')
echo "This rule would affect $count transactions"

read -p "Create this rule? (y/n) " -n 1 -r
echo

if [[ $REPLY =~ ^[Yy]$ ]]; then
  kick rules create \
    --name="AWS Categorization" \
    --condition="$CONDITION" \
    --action="set-category:$NEW_CATEGORY"
  echo "✓ Rule created"
fi

How to Customize

  • Test multiple conditions at once

  • Save preview results to a file

  • Add rule to specific entity

What It Outputs

Testing rule: description contains 'AWS' → Cloud Infrastructure

Would update: 2026-01-05 | 125.00 | Amazon Web Services | Current category: none
This rule would affect 3 transactions
Audit and Clean Up Unused Rules

The Script

#!/bin/bash
# audit-rules.sh

echo "Auditing automation rules..."
echo ""

rules=$(kick rules list --format=json)

echo "$rules" | jq -r '.[] | .id' | while read -r rule_id; do
  rule_name=$(echo "$rules" | jq -r ".[] | select(.id==\"$rule_id\") | .name")
  rule_condition=$(echo "$rules" | jq -r ".[] | select(.id==\"$rule_id\") | .condition")
  
  count=$(kick transactions list \
    --from="$(date -d '90 days ago' +%Y-%m-%d)" \
    --filter="$rule_condition" \
    --format=json | jq 'length')
  
  if [ "$count" -eq 0 ]; then
    echo "⚠️  Rule '$rule_name' matched 0 transactions in last 90 days"
    echo "    Consider deleting: kick rules delete --id=$rule_id"
    echo ""
  else
    echo "✓ Rule '$rule_name' matched $count transactions"
  fi
done

How to Customize

  • Change lookback period

  • Auto-delete rules with zero matches

  • Send weekly audit report via email

What It Outputs

✓ Rule 'AWS Categorization' matched 12 transactions
⚠️  Rule 'Old Vendor Auto-Category' matched 0 transactions in last 90 days

Last updated

Was this helpful?