Analyst In A Box
ASecurityExplains why a business number moved (revenue, GMV, orders, average order value, margin, conversion, any KPI) and who should act next, the way a senior business analyst would. Use it whenever someone asks why a metric rose or fell, what drove a change, which channel/region/product is responsible, why one segment grew faster than another, or why growth this period differs from last period; also when they share sales or order data (CSV, Excel, SQLite, DuckDB) and want to understand it, build a ...
- 3 stars
- 0 votes
- 0 copies
- 2 views
- Added November 7, 2026
Works with
Security analysis
92/100- Installs packages at runtime which could introduce malicious dependencies
Pro scans all 20 files and shows the line behind each finding
npx -y skills add weigezi/analyst-in-a-box --skill analyst-in-a-box --agent claude-codeAre you the author of Analyst In A Box?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/weigezi-analyst-in-a-box)---
name: analyst-in-a-box
description: Explains why a business number moved (revenue, GMV, orders, average order value, margin, conversion, any KPI) and who should act next, the way a senior business analyst would. Use it whenever someone asks why a metric rose or fell, what drove a change, which channel/region/product is responsible, why one segment grew faster than another, or why growth this period differs from last period; also when they share sales or order data (CSV, Excel, SQLite, DuckDB) and want to understand it, build a metric tree, or set up recurring performance analysis. Works in Chinese too (为什么跌了, 为什么涨了, 异动归因, 贡献度, 拆解, 增速差). Use it even if the user never says "attribution".
license: Apache-2.0 (see LICENSE)
compatibility: Python 3.10+ with pandas, pyyaml and openpyxl (duckdb optional). The scripts run on your machine and make no network calls; your AI tool reads what they print.
metadata:
version: 0.2.1
---
# analyst-in-a-box
[中文](SKILL.zh.md)
Answer one question well: **why did this number move, and who should do what next.**
The scripts do every calculation. Your job is to frame the question, run the scripts, talk to the user,
and record what they teach you so the next answer is better.
## Two phases, six steps
**Input phase** (no P-number) — recognise tables and build the workspace (once, reused).
**Per-question phase** — run on each question:
- P0: Frame the question (what metric, what comparison)
- P1: Data health check for this question (enough data, no obvious issues). If P1 finds the data insufficient or the question invalid, go back to P0
- P2: Mathematical analysis (which slice of the number changed, computed by scripts)
- P3: Real-world causes (what happened in reality, hypotheses ranked by evidence)
- P4: Actions and owners (who should do what)
- P5: Report and store conclusions
## Ground rules (read these first)
1. **Never do the arithmetic yourself.** Every number you tell the user comes from a script's output.
Language models get decomposition maths wrong; the scripts check that every breakdown sums to the total.
2. **Do not treat column names as definitions.** After intake (E0), `explore` (E1) may draft hypotheses from
shape and evidence and store them as `inferred` / `proposed` on the hypothesis card. The user confirms in E2;
until then nothing inferred becomes a metric, filter or threshold definition.
3. **Thresholds belong to the user.** "What counts as a single point", "what counts as unusual": these are
business judgement. The workspace stores them with their source; never invent one in conversation.
4. **Outside events are hypotheses.** Weather, news, competitors: they only show that timing matches.
The run decides how they may be worded (three checks: timing, affected slice, size).
5. **Everything the user teaches you goes through `correct`.** That writes it down with their words and makes
a regression case, so the skill cannot quietly forget it.
6. **Causes are hypotheses ranked by evidence.** "Where it moved" (P2) is computed by scripts; "why it moved" (P3)
is a hypothesis: data-verified, sourced-to-confirm, or AI-inferred. You may propose causes but must label the tier.
## Two hard rules
1. **Scripts compute; you explain.** Every number you cite comes from script output; never invent arithmetic or column meanings.
2. **Column names are not definitions.** After E0, E1 may draft on the hypothesis card; the user confirms in E2. With
`ACCEPT_ALL_CONFIRMS=false` (locked), one `approve_direction` confirms **direction only** — unedited items stay `inferred` / `default`.
Generate and show **`card.yaml` up front** after `explore` (before the user answers E2). Industry options appear mid-probe; packs apply only after the user selects an industry on `confirm-card` (unset = no pack).
## Gated commands (explored workspaces)
After E1, workspaces carry `onboarding.E1_exploration`. Until E2 writes `card_approval` with `card: approve_direction`:
| Command | Blocked? |
|---|---|
| `run`, `followup` | yes — exit code **4** (`card_not_approved`) |
| `regress` | no — `gate: regress` via `evolve.regress` only |
| `init`, `confirm`, `explore`, `confirm-card`, `check`, `network`, `docs`, `coverage`, `correct`, `propose`, `formation`, `record-finding` | no |
| Legacy workspaces (no exploration marker) | `run` / `followup` not gated (`card.state: absent`) |
## Running the scripts
All commands are run from this skill's folder and print JSON:
```bash
python3 scripts/aib_cli.py <command> --workspace <dir> ...
```
If `import pandas, yaml` fails, install first: `pip install -r scripts/requirements.txt`
(or prefix with `uv run --with-requirements scripts/requirements.txt`).
A **workspace** is one company's knowledge (its metric tree, its world, its corrections). Keep it in the
user's own folder, never inside this skill; ask where if it is not obvious, default `./aib-workspace`.
## 1. First use: from a table to a first answer
Goal: within one conversation the user sees an attribution that is correct and tells them something new.
1. `init <data-file> --workspace <dir> --lang zh|en` reads the table and returns questions. When the user has
several tables (orders, products, a campaign calendar, a price log, traffic, weather...), give a folder or
several files. The script finds the main table, the lookups, the links between tables (with coverage), the
event records and the outside series, and turns each into a multiple-choice question. Show every question
with its suggested answer and its evidence. Nothing enters the workspace until the user confirms.
Details: [references/intake.md](references/intake.md).
2. Ask those questions **as multiple choice**, a few at a time, in the user's language. Do not pre-fill
answers from column names; show the examples the script gives so the user can recognise the column.
3. Put the answers in a JSON file keyed by question `id` and run `confirm --workspace <dir> --answers <file>`.
It writes the workspace and returns `first_run`. Whenever the user asks to accept all suggestions instead of
choosing one by one, set `"_via": {"<question id>": "bulk_accept"}` for those answers (missing means `picked`).
With `ACCEPT_ALL_CONFIRMS=false`, bulk-accepted thresholds stay `kind: default, status: proposed`.
4. **Onboarding E1:** draft `exploration.yaml` (probing questions and families), then
`explore --workspace <dir> --file exploration.yaml [--depth full|minimal]`. It validates the draft, stores
inferred items in `model.yaml`, and writes `card.yaml` — show the card up front; industry options appear mid-probe,
and packs apply only after the user selects an industry on confirm (E2).
5. **Onboarding E2:** `confirm-card --workspace <dir> --answers answers.yaml` (`card: approve_direction` records direction
in `model.yaml`; per-item `confirm`/`edit`/`unknown`). Explored workspaces block `run` with exit code 4 until E2 is done.
6. Run a first analysis when ready: `run --workspace <dir> --config '<first_run as JSON>'`, then present the report (section 3).
7. Offer, do not force: "Which dimension do you usually look at first?" Their answer is a `set_priority`
correction (section 4). Further business knowledge is asked **when an answer needs it**, not as an upfront survey.
8. If the user gives documents (weekly reports, reviews), **you read them**; the script never does. For every
event or mechanism that could explain a number, record it with
`propose --workspace <dir> --doc <file> --file <proposals>`, each with the exact sentence it came from,
copied as it is. A sentence not in the document is refused. Accepted ones are "from a document, to confirm",
and they do not count as explained until the user confirms. You may propose a cause; label it AI-inferred,
and never make up numbers. Quotes from documents are copied exactly, never reworded.
## 2. Answering a question
Map the question to a run, then call `run`. Details and edge cases: [references/questions.md](references/questions.md).
| The user asks | Run |
|---|---|
| "Why did revenue fall last week?" | `--metric revenue --current <Mon> <Sun> --base yoy` (or `pop` if they say "vs last week") |
| "Why did the east region fall?" | add `--filter region=east` |
| "Why is Q3 growth lower than Q2?" | second order across time: `--current <Q3> --base yoy --previous` |
| "Why did offline grow faster than online?" | second order across sides: `--compare <id>`; add the comparison to `model.yaml` first if it is missing |
| "Visitors went up but conversion fell" | first order; the formula breakdown in the report answers it |
| "Why did October fall vs September?" (month to date) | `--current <Oct 1> <today> --base pop`: the base is Sep 1 to the same day |
| "Did we sell more, or charge more?" | first order; add a `pvm` entry to `model.yaml` (price-volume-mix) |
| "Is it new customers or lost ones?" | add `"growth_accounting": {"customer_column": "<column the user named>"}` to the config |
| "And inside that, what?" | `followup --from <run_dir> --slot <slot id> [--dimensions d1,d2]` |
If the metric, dimension or comparison does not exist in the workspace, say so and ask; do not approximate
with a different one. If `run` returns exit code 3 with `metric_definition_needed`, ask how that metric is
defined (especially the denominator) before computing it; confirm with `confirm_metric`, then re-run.
Already-confirmed definitions are reused. Question-stated filters define the analysis scope: put them in
`--filter` / `--scope` first; do not cut or report that condition again as a finding. Windows of different
length default to daily averages (`per_day: true` is set automatically) with a note in the report; a holiday
in one period only is reported with two ways out (`"holiday": "exclude"` or `"shift_base"`). `followup`
keeps the earlier run's filters, periods and path, and records which run it followed.
## 3. Presenting the result
The run writes `report.zh.md`, `report.en.md`, `report.zh.html`, `report.en.html`, `record.json` and charts.
In the conversation, say the conclusion first, then give the user the HTML path to open.
Show the report in the user's language; it is already ordered
conclusion → is it unusual → breakdown → why → who should act.
Keep its numbers exactly; do not round them differently or recompute. Point to the chart files.
How to talk about structure vs rate, shares above 100%, and hypotheses: [references/report.md](references/report.md).
After presenting the report, record observations the user agrees with using
`record-finding --workspace <dir> --from <run_dir> --file findings.yaml`. Each finding needs
`observation` (en/zh) and `numbers` (labels mapped to paths into that run's `record.json`). The
command refuses unresolved paths and blocked runs. Numbers are stored with `numbers_resolved`;
origins `outside_network` and `post_card` are never auto-promoted to facts.
Then handle what the run says it is missing:
- **`gaps`**: the data shows a change nobody has explained. Ask one plain question:
"New customers' average order fell; do you know why?" Record the answer (section 4) and re-run.
- **`to_confirm`**: entries that are only proposed, including outside events. Ask whether to confirm them.
- **`blocked: true`**: a "wrong" tier pre-delivery check failed (the arithmetic is broken). Show which one;
do not present the conclusions.
- **`data_suspect: true`**: a "data" tier check failed (data quality, unequal windows, missing base).
The report proceeds but the first line flags the issue; conclusions are marked suspect. No cause counts
as "data-verified" while data is in doubt.
- **Data note** (first lines of the conclusion): worth checking, but the conclusions proceed. Never explain
a change the data itself may have made.
- **"Within the usual range"**: say it is normal and do not hunt for a cause, unless the report names one group
that stands far out from its own swings.
- **A cited record that "cannot explain this change"** (true in both periods): it does not answer the question.
Ask what changed in this period.
## 4. Learning from the user
When the user corrects you or explains something, record it with `correct --workspace <dir> --json '<correction>'`.
Use their own words in `quote`. Types: `add_mechanism`, `add_event`, `add_action`, `add_alias`,
`set_priority`, `set_param`, `confirm`, `retire`, `confirm_metric`. Formats and examples: [references/learning.md](references/learning.md).
Include `"run"` (the config of the run that prompted it) and `"slot"` (e.g. `customer_type=new`) so the
regression case can replay it. Re-run the question to show the change, then run `regress` to show every
earlier lesson still holds. Report the coverage figure: it is how the user sees the skill learning.
## 5. Outside events and news
When a gap looks external, or the user mentions weather, holidays, policy, competitors or world events:
1. Search the web (your own search tool) within the dates of the change and the region or product affected.
2. Pick at most three relevant items. For each, record an `add_event` correction with `kind: external`,
`source: {kind: document, ref: <url>}`, `status: proposed` and the entities it would touch.
3. Re-run. The three checks decide the wording: "passed all three checks" or "timing matches, not proven".
Never present news as the cause on your own judgement.
Calendars and continuous outside data (weather, exchange rates, market benchmarks) are workspace sources;
see [references/workspace.md](references/workspace.md).
## 6. Keeping the workspace healthy
- `check` lists every problem (unknown columns, missing sources, a formula that does not hold on the data).
- `docs` rebuilds readable, linked Markdown pages from the YAML for people who do not read YAML.
- `coverage` shows, run by run, how many explanations could cite a record.
- Edit YAML directly only for structure (a new comparison, a new data source). Business knowledge goes
through `correct` so it is sourced and regression-tested.
## Reference files
| File | Read when |
|---|---|
| [references/intake.md](references/intake.md) | the user gives several tables or documents; asking intake questions, recording `propose` |
| [references/workspace.md](references/workspace.md) | writing or reading any workspace file |
| [references/questions.md](references/questions.md) | turning an unusual question into a run |
| [references/operators.md](references/operators.md) | the user asks how a number was computed, or which method is used |
| [references/report.md](references/report.md) | presenting a report, explaining structure vs rate, hypotheses |
| [references/learning.md](references/learning.md) | recording a correction |
| [references/network.md](references/network.md) | the user wants to see the workspace as a page: `network` writes the structure-layer `knowledge.html`; each `confirm` round writes `intake.html` |
Files in this skill
- LICENSE
- SKILL.md
- SKILL.zh.md
- references/intake.md
- references/intake.zh.md
- references/learning.md
- references/learning.zh.md
- references/network.md
- references/network.zh.md
- references/operators.md
- references/operators.zh.md
- references/questions.md
- references/questions.zh.md
- references/report.md
- references/report.zh.md
- references/workspace.md
- references/workspace.zh.md
- scripts/aib/__init__.py
- scripts/aib/__main__.py
- scripts/aib/cli.py
Attribution
Related skills
View all in data →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.