← Back to projects

Technical write-up · Snowflake · CoCo CLI · Cortex · Streamlit in Snowflake

What you can build with Snowflake CoCo CLI (+ Cortex)

I wanted to see how far you can get when the whole thing lives inside Snowflake: the data, the rules, the app, the audit trail and the alerting. So I designed and built a fraud policy copilot. You give it a flagged transaction id, and it gives back a risk score, the policy rules that fired (with citations), recommended next actions, a fraud-ring map, a case, and a native Snowflake alert trail. No external services.

The problem

Fraud analysts burn time hunting AML / KYC policy text for every alert. The decision itself is often quick; finding and citing the right rule, pulling customer context, and leaving an audit trail is what eats the day. I wanted a flow that goes from flagged transaction to policy-cited decision in one step, and keeps every review on record.

Best way in: read the code on GitHub, follow the design below, and run the quickstart yourself.

Demo (optional)

Prefer YouTube? Watch it there.

The design

I split the logic into small, modular skills and chained them, so each step is testable on its own and the same decision logic can run from the CLI or the app:

SkillRole
get_case_contextCustomer + recent transactions
match_policyScore against AML-style rules
explain_decisionCitations + recommendation
suggest_next_actionsAnalyst next steps
map_fraud_ringShared device / IBAN / phone / merchant links

The rules are plain SQL. match_policy checks rules like large cross-border wires, wires from young accounts, large ATM cash, structuring (two or more small transactions in the 24 hours before a large wire), demo high-risk geographies and personal accounts sending large wires. Each fired rule adds points, the score is capped at 100, and the output is a JSON object with the rule code, title, severity and the rule text itself, so the citation travels with the decision.

How CoCo CLI and Cortex fit in

Why it matters

Run it yourself

  1. In a Snowflake worksheet (ACCOUNTADMIN, warehouse COMPUTE_WH):
    USE DATABASE FRAUD_COPILOT;
    USE SCHEMA DEMO;
    Then run sql/01 → 02 → 03 → 04 → 05 in order.
  2. Check the alert:
    SHOW ALERTS LIKE 'FRAUD_HIGH_RISK_ALERT';
    ALTER ALERT FRAUD_HIGH_RISK_ALERT RESUME;   -- if suspended
    EXECUTE ALERT FRAUD_HIGH_RISK_ALERT;        -- fire once without waiting
    If CREATE ALERT isn't available on your trial, there's a Task fallback at the bottom of sql/03_audit_and_alert.sql.
  3. Create a Streamlit app on FRAUD_COPILOT.DEMO with entry file app/streamlit_app.py (Git sync or paste).
  4. Try it: review T2005 (structuring, high score) and open a case, compare with T2001 (wire + geo) and T1001 (clean control), map the ring for C005, then check the Cases and Alerts tabs.

What I learned

View the repo on GitHub Building something similar? Let's talk