the playbook
cr8script's sweet spot isn't algorithm interviews and it isn't
spreadsheet hell — it's the twenty-minute question
that lands in your DMs at 4pm. Pull the log, group by something,
rank, paste the result back. Below: three real shapes of that
question, each solved in a self-contained script you could run
over lunch. Inline data so the scripts are testable without
wiring up your real source — swap the literal list for an
http.get or csv.parse call when you're
ready to point at the actual feed.
which endpoints are slow?
let log = [ { path: "/api/orders", ms: 42 }, { path: "/api/orders", ms: 51 }, { path: "/api/orders", ms: 68 }, { path: "/api/orders", ms: 220 }, { path: "/api/orders", ms: 920 }, { path: "/api/orders", ms: 45 }, { path: "/api/users", ms: 12 }, { path: "/api/users", ms: 18 }, { path: "/api/users", ms: 15 }, { path: "/api/users", ms: 22 }, { path: "/api/search", ms: 410 }, { path: "/api/search", ms: 520 }, { path: "/api/search", ms: 380 }, { path: "/api/search", ms: 612 }, { path: "/api/search", ms: 1180 }, { path: "/api/search", ms: 489 }, { path: "/api/health", ms: 3 }, { path: "/api/health", ms: 4 }, { path: "/api/health", ms: 3 }, { path: "/api/checkout", ms: 240 }, { path: "/api/checkout", ms: 310 }, { path: "/api/checkout", ms: 280 }, { path: "/api/checkout", ms: 1850 }, { path: "/api/checkout", ms: 290 } ] # p95: sort times ascending, pick value at ceil(n * 0.95). to p95(times) let sorted = times | sort by it let idx = math.ceil(sorted.length * 0.95) return sorted[idx] end # cr8 has no substring slice; pad to a fixed width by appending spaces. to pad_right(s, width) var out = s for each i in 1..(width - s.length) out = out + " " end return out end let by_path = log | group by path | summarize { n: length(items), avg_ms: math.round(average(items | map ms)), p95_ms: p95(items | map ms), max_ms: max(items | map ms) } | sort by p95_ms descending show "endpoint n avg p95 max" show "------------------------------------------" for each row in by_path let path_col = pad_right(row.path, 17) let n_col = pad_right(to_text(row.n), 3) let avg_col = pad_right(to_text(row.avg_ms), 6) let p95_col = pad_right(to_text(row.p95_ms), 6) show f"{path_col} {n_col} {avg_col} {p95_col} {to_text(row.max_ms)}" end
endpoint n avg p95 max ------------------------------------------ /api/checkout 5 594 1850 1850 /api/search 6 598 1180 1180 /api/orders 6 224 920 920 /api/users 4 17 22 22 /api/health 3 3 4 4
The whole pipeline reads like a sentence: group by path,
summarize each group with a record of stats, sort by p95
descending. No pandas import, no DataFrame ceremony. The
static checker would catch row.pat95 as a typo
before the script even runs.
top 10 customers this quarter
let q_start = "2026-04-01" let orders = [ { date: "2026-04-02", customer: "Acme", amount: 1240.50 }, { date: "2026-04-05", customer: "Globex", amount: 399.99 }, { date: "2026-04-09", customer: "Acme", amount: 890.00 }, { date: "2026-04-11", customer: "Initech", amount: 2100.75 }, { date: "2026-04-14", customer: "Soylent", amount: 540.00 }, { date: "2026-04-15", customer: "Globex", amount: 120.40 }, { date: "2026-04-18", customer: "Acme", amount: 3200.00 }, { date: "2026-04-19", customer: "Hooli", amount: 780.20 }, { date: "2026-04-22", customer: "Initech", amount: 450.10 }, { date: "2026-04-25", customer: "Pied Piper", amount: 1899.99 }, { date: "2026-04-26", customer: "Soylent", amount: 680.00 }, { date: "2026-04-28", customer: "Massive Dynamic", amount: 5400.00 }, { date: "2026-04-29", customer: "Hooli", amount: 340.40 }, { date: "2026-05-01", customer: "Acme", amount: 720.50 }, { date: "2026-05-02", customer: "Globex", amount: 860.00 }, # last quarter -- excluded by the date filter { date: "2026-03-15", customer: "Acme", amount: 4500.00 }, { date: "2026-03-22", customer: "Hooli", amount: 2200.00 } ] to pad_right(s, width) var out = s for each i in 1..(width - s.length) out = out + " " end return out end let top = orders | where date is at least q_start | group by customer | summarize { revenue: sum(items | map amount), n_orders: length(items) } | sort by revenue descending | take 10 show f"Top customers since {q_start}" show "----------------------------------------------" show "rank customer revenue orders" show "----------------------------------------------" var rank = 0 for each row in top rank = rank + 1 let rk_col = pad_right(to_text(rank) + ".", 4) let name_col = pad_right(row.customer, 18) let rev_col = pad_right("$" + to_text(row.revenue), 12) show f"{rk_col} {name_col} {rev_col} {to_text(row.n_orders)}" end show "" let total = sum(top | map revenue) show f"sum of top {to_text(length(top))}: ${to_text(total)}"
Top customers since 2026-04-01 ---------------------------------------------- rank customer revenue orders ---------------------------------------------- 1. Acme $6051 4 2. Massive Dynamic $5400 1 3. Initech $2550.85 2 4. Pied Piper $1899.99 1 5. Globex $1380.39 3 6. Soylent $1220 2 7. Hooli $1120.6 2 sum of top 7: $19622.83
cr8 numbers are decimal by default, so
1240.50 + 890.00 + 3200.00 + 720.50 is exactly
$6051.00 — not $6050.999999...
like floats would give you. The pipeline (filter, group, sum,
rank, take) is one expression with no intermediate variables.
did anything change in prod?
let prod = { app_name: "atlas-api", log_level: "info", rate_limit_per_min: 600, feature_new_search: false, db_pool_size: 40, cache_ttl_seconds: 300, region: "us-east-1", pager_email: "ops@atlas.example" } let staging = { app_name: "atlas-api", log_level: "debug", rate_limit_per_min: 1200, feature_new_search: true, db_pool_size: 40, cache_ttl_seconds: 60, region: "us-east-1", feature_dark_mode: true } # present in prod, absent in staging var missing_in_staging = [] for each k in prod.keys if staging.has(k) is false then missing_in_staging = missing_in_staging + [{ key: k, prod_value: prod.get(k) }] end end # present in staging, absent in prod (would be added on promotion) var added_in_staging = [] for each k in staging.keys if prod.has(k) is false then added_in_staging = added_in_staging + [{ key: k, staging_value: staging.get(k) }] end end # shared keys with different values var changed = [] for each k in prod.keys if staging.has(k) then let pv = prod.get(k) let sv = staging.get(k) if pv is not sv then changed = changed + [{ key: k, prod: pv, staging: sv }] end end end show "=== config drift: prod vs staging ===" show "" show f"removed in staging ({to_text(length(missing_in_staging))})" if length(missing_in_staging) is 0 then show " (none)" else for each row in missing_in_staging show f" - {row.key} = {to_text(row.prod_value)}" end end show "" show f"added in staging ({to_text(length(added_in_staging))})" if length(added_in_staging) is 0 then show " (none)" else for each row in added_in_staging show f" + {row.key} = {to_text(row.staging_value)}" end end show "" show f"changed ({to_text(length(changed))})" if length(changed) is 0 then show " (none)" else for each row in changed show f" ~ {row.key}: {to_text(row.prod)} -> {to_text(row.staging)}" end end show "" let total_drift = length(missing_in_staging) + length(added_in_staging) + length(changed) show f"summary: {to_text(total_drift)} drift point(s) between prod and staging"
=== config drift: prod vs staging === removed in staging (1) - pager_email = ops@atlas.example added in staging (1) + feature_dark_mode = true changed (4) ~ log_level: info -> debug ~ rate_limit_per_min: 600 -> 1200 ~ feature_new_search: false -> true ~ cache_ttl_seconds: 300 -> 60 summary: 6 drift point(s) between prod and staging
Records expose .keys, .has(k), and
.get(k), so a structural diff is just three loops.
The honest is not comparison means
0 is not false — cr8 won't quietly tell you
they're equal because both look "falsy" the way Python or JS
would.
None of these scripts are bundled examples in the language repo — they're the kind of one-shot answers you'd write, paste into Slack, and forget. The point isn't that you'd commit them; it's that cr8 fits in your head well enough to write them in the same five minutes you'd otherwise spend booting a notebook.