data-scientist
Expert data processing specialist with intelligent DuckDB/Polars selection for maximum performance. Always includes numpy, never uses pandas, runs everything through uv. Triggers: 'analyze the data', 'analyze this file', 'what is in this CSV/parquet/json', 'summarize this', 'group by', 'filter rows', 'sort by', 'join these files', 'merge datasets', 'time series trend', 'last 30 days data', 'compare yesterday and today', 'distribution/histogram', 'correlation', 'clean duplicates', 'handle missing values', 'dataset larger than RAM', 'SQL query on files', 'DataFrame operations', 'chart/plot this data', DuckDB vs Polars selection, quick data exploration CLI. NOT for plain text/code inspection, configs, or tiny inline math.
git clone --depth 1 https://github.com/code-yeongyu/lazycodex /tmp/data-scientist && cp -r /tmp/data-scientist/plugins/omo/skills/data-scientist ~/.claude/skills/data-scientistSKILL.md
# Data Scientist: High-Performance Data Processing Expert
## Role & Expertise
Performance-obsessed data scientist with expertise in:
- Intelligent tool selection: DuckDB vs Polars based on operation characteristics
- Zero-copy data interchange via Apache Arrow
- Memory-efficient processing for datasets exceeding RAM
- SQL and DataFrame API mastery for analytical workloads
## Environment Setup
Everything runs through **uv**. If `uv` is not on PATH, set it up first — pick the path that matches the system and run it, no manual guesswork:
```bash
bash scripts/setup-uv.sh # macOS / Linux / WSL / Git Bash — auto-detects OS + arch, installs or updates uv to latest
```
```powershell
powershell -ExecutionPolicy Bypass -File scripts/setup-uv.ps1 # native Windows — installs or updates uv to latest
```
Both scripts detect the platform, install uv when missing (official installer first, Homebrew/winget as fallback), upgrade it when present (`uv self update`), put it on PATH for the current shell, and verify with `uv --version`. The full per-platform matrix, PATH notes, and CI usage live in [references/uv-setup.md](references/uv-setup.md). Verify: `uv --version`.
## Core Principles
### ABSOLUTE RULES
1. **ALWAYS include numpy** in all data processing operations (`uv run --with numpy ...`)
2. **NEVER use pandas** - Polars and DuckDB beat it decisively on every operation; the entire skill assumes pandas is absent
3. **ALWAYS use Python via `uv run`** for calculations and data processing
4. **Intelligent tool selection**: Choose DuckDB or Polars based on operation types, NOT arbitrarily
5. **Zero-copy conversions**: hand data across DuckDB and Polars through Arrow — `duckdb.sql(...).pl()`. Never call `.df()` (returns a pandas frame; crashes without pandas). Keep `pyarrow` in the package set or `.pl()` raises `ModuleNotFoundError`
6. **Lazy evaluation**: Prefer `scan_csv`/`scan_parquet` and `.collect()` only when needed
7. **Direct file queries**: Let DuckDB query files directly instead of loading to memory when possible
### Standard Package Pattern
```bash
# Default for data tasks (numpy + pyarrow are mandatory parts of the set)
uv run --with numpy --with duckdb --with polars --with pyarrow python -c "{code}"
# With visualization (RECOMMENDED for most analysis requests)
uv run --with numpy --with duckdb --with polars --with pyarrow --with matplotlib python -c "{code}"
# Pure Polars
uv run --with numpy --with polars python -c "{code}"
# Pure DuckDB (with the Arrow handoff available)
uv run --with numpy --with duckdb --with pyarrow python -c "{code}"
```
**When to include matplotlib:**
- User requests visualization: "graph", "chart", "plot", "show me"
- Exploratory data analysis (EDA): "analyze", "trends", "patterns"
- Time-series analysis: "over time", "daily", "trends"
- Distribution analysis: "distribution", "histogram", "statistics"
- Comparison tasks: "compare", visual comparison implied
- **Default to including matplotlib** when in doubt - overhead is minimal
## Tool Selection Logic
### Decision Tree (Apply in Order)
1. **Is it a `.duckdb` file?** → **USE DUCKDB** (native format, optimal performance)
2. **Simple one-off query without needing full data in memory?** → **USE DUCKDB** (direct file query, zero memory load)
3. **Very heavy complex SQL query (multi-table joins, window functions)?** → **USE DUCKDB** (superior SQL optimizer)
4. **Main operation is FILTERING?** → **USE POLARS** (typically the fastest by a wide margin — see benchmarks)
5. **Main operation is SORTING?** → **USE POLARS** (typically the fastest)
6. **Complex SQL JOINS needed?** → **USE DUCKDB** (stronger join engine, more join types)
7. **Heavy GROUP BY AGGREGATIONS?** → **USE DUCKDB** (typically faster on large datasets)
8. **Window functions with partitioning?** → **POLARS** (typically faster)
9. **Complex TRANSFORMATIONS (pivot, melt, string ops)?** → **USE POLARS**
10. **Dataset larger than available RAM?** → **USE POLARS** (streaming support) or **DUCKDB** (out-of-core)
11. **Mixed operations?** → **USE HYBRID APPROACH** (leverage strengths of both)
### Quick Reference
```
Simple query → DuckDB
Heavy complex query → DuckDB
Filter → Polars
Sort → Polars
Join → DuckDB
Aggregate → DuckDB
Window → Polars
Transform → Polars
Too large for RAM → Polars streaming
Mixed operations → Hybrid
```
The exact multipliers these heuristics distill (with sources and caveats — routing heuristics, not guarantees) live in [performance-benchmarks.md](references/performance-benchmarks.md).
## Essential Patterns
### DuckDB Direct File Query
```python
import duckdb
# Query file directly - no memory load
result = duckdb.sql("""
SELECT category, SUM(amount) as total
FROM 'data.csv'
GROUP BY category
""").pl() # .pl() -> Polars via Arrow. Requires pyarrow. Never .df() (pandas).
```
### Polars Lazy Evaluation
```python
import polars as pl
# Lazy scan - optimizes and executes once
result = (
pl.scan_csv('data.csv')
.filter(pl.col('value') > 100)
.sort('value', descending=True)
.collect()
)
```
### Zero-Copy DuckDB → Polars
```python
import duckdb
# Direct conversion via Arrow (pyarrow required in the package set)
df_polars = duckdb.sql("SELECT * FROM 'data.csv'").pl()
```
### Hybrid Approach
```python
import duckdb
import polars as pl
# Phase 1: DuckDB for joins
joined = duckdb.sql(
"SELECT * FROM 'orders.csv' o "
"JOIN 'customers.csv' c ON o.customer_id = c.customer_id"
).pl()
# Phase 2: Polars for filtering
filtered = joined.filter(pl.col('amount') > 100)
# Phase 3: Back to DuckDB for aggregation
duckdb.register('filtered_data', filtered)
final = duckdb.sql('SELECT category, SUM(amount) FROM filtered_data GROUP BY category').pl()
```
## Quick Query CLI
For ad-hoc data exploration, use the built-in query runner:
```bash
# SQL query (uses DuckDB)
uv run scripts/quick-query.py data.csv "SELECT category, COUNT(*) FROM data GROUP BY category"
# Filter expression — Polars SQLUse when Codex needs to understand or respond to automatic comment-checker feedback emitted after an edit-like PostToolUse hook.
Use when Codex needs language-server diagnostics, definitions, references, symbols, or rename safety checks in the current workspace.
Use when the user asks about Codex Rules behavior, injected project rules, supported rule file locations, matching, or environment configuration.
ACTIVATES ONLY on an explicit user request for the ulw-plan workflow: the user themselves saying ulw-plan, ulw plan, /skill:ulw-plan, or asking in their own words for a work plan before coding. NEVER self-activates: a bare ulw/ultrawork run, an agent-side routing decision, or reading this file is not a request, and the plan-gated reviewers (metis/momus) stay locked without a user request plus a written .omo/plans plan file. Explore-first planning consultant (Prometheus) that grounds in the codebase, asks only the forks exploration cannot resolve - or researches them to best practice when the intent is fuzzy - waits for explicit approval, then writes ONE decision-complete work plan a worker executes with zero further interview. Triggers: ulw-plan, ulw plan, plan this, make a plan, plan before coding, interview me, break this down, start planning, plan mode.
Goal-like loop that uses ultrawork mode to decompose work into systematic, evidence-bound steps.
MUST USE for any real runtime debugging across ANY language or binary — crashes, silent failures, wrong responses, stuck processes, memory leaks, async misbehavior, unexplained timing, reverse engineering. Runs a hypothesis-driven loop: form ≥3 hypotheses, investigate in parallel, after 2 failed rounds spawn Oracles from orthogonal angles, confirm root cause, lock with a failing test, fix minimally, QA by actually USING the system, scrub artifacts. The actual HOW lives in `references/` — READ THEM. Triggers: 'debug this', 'why is X not working', 'hanging', 'attach a debugger', 'reverse engineer', 'pwndbg', 'gdb', 'lldb', 'node inspect', 'pdb', 'dlv', 'delve', 'rust-gdb', 'set a breakpoint', 'context window exploded', 'why is the response empty', 'why is this happening', 'trace this bug', 'reproduce and fix', 'silent failure', 'HTTP 200 but empty', 'why did it stop', 'inspect the binary', 'playwright', 'flaky test', 'fails intermittently', 'passes in isolation', 'only fails in CI'.
Designer-turned-developer who crafts stunning UI/UX even without design mockups
MUST USE whenever a task needs a commit or git-history investigation. Covers atomic commits, staging, commit-message style, rebase, squash, fixup/autosquash, blame, bisect, reflog, git log -S/-G, and questions like who wrote this or when was this added. Do not use for ordinary code edits unless the user asks for git work.