Skill: /causal — OpenCausalInf Causal Inference Toolkit
Purpose
Multi-mode skill for causal inference when experiments aren't possible. Helps users estimate treatment effects from observational data with explicit assumption checking, sensitivity analysis, and mandatory caveats. Uses coded helpers from helpers/stats/experiment_stats/causal/.
When to Use
Invoke as /causal [mode] or trigger on causal inference intents:
- "Did this feature actually cause the improvement?"
- "We can't run an experiment, but..."
- "Was this change responsible for the metric movement?"
- "Can we measure the impact retroactively?"
Modes
/causal select
Purpose: Walk the method selection decision tree and recommend a causal method.
Agent: agents/causal/causal-method-selector.md
Flow:
- Ask 4-6 diagnostic questions:
- Can you randomize? → Route to
/experiment design
- Do you have a comparison group?
- Do you have pre-treatment data?
- Are there observable confounders you can measure?
- How many time periods do you have?
- Recommend: Pre-Post, DiD, PSM, Regression Adjustment, or "not feasible"
- Output: recommended method + confidence level + rationale
Checkpoint: Method confirmation (Type C — user must confirm before analysis)
/causal analyze
Purpose: Run the selected causal method on data.
Agent: agents/causal/causal-analyzer.md
Flow:
- Read selected method from previous step or user input
- Dispatch to appropriate helper:
from helpers.stats.experiment_stats.causal import (
pre_post_analysis, did_basic, propensity_match,
regression_adjust,
)
# Method routing:
# "pre_post" → pre_post_analysis(pre, post, covariates)
# "did" → did_basic(df, outcome, treat, post)
# "psm" → propensity_match(df, treat, covariates, outcome)
# "regression" → regression_adjust(df, outcome, treatment, covariates)
- Generate charts (treatment effect, balance plots for PSM, event study for DiD)
- Output:
working/causal_analysis_results.json
/causal check
Purpose: Run assumption checks for the selected method.
Agent: agents/causal/causal-assumption-checker.md
Flow:
- Identify which assumptions apply to the selected method:
- DiD: Parallel trends, no anticipation, stable composition
- PSM: Common support, balance (SMD < 0.1), positivity
- Pre-Post: No concurrent events, trend stability
- Regression: All confounders included, correct specification
- Run quantitative checks:
from helpers.stats.experiment_stats.causal import (
check_parallel_trends, check_common_support,
balance_table,
)
- Output: per-assumption PASS / WARNING / FAIL verdicts
Checkpoint: Any FAIL (Type C) → present options: adjust method, add caveats, or abort
/causal sensitivity
Purpose: Test how robust the estimate is to unmeasured confounding.
Agent: agents/causal/causal-sensitivity.md
Flow:
- Run sensitivity analysis based on method:
from helpers.stats.experiment_stats.causal import rosenbaum_bounds, e_value
# PSM: rosenbaum_bounds(treated_outcomes, control_outcomes)
# All: e_value(risk_ratio, ci_lower)
- Translate to plain language: "An unmeasured confounder would need to be X times stronger than anything we measured to explain away this result."
- Output: sensitivity report
/causal report
Purpose: Generate a report with mandatory caveats.
Agent: agents/causal/causal-report-generator.md
Flow:
- Compile: estimate + CI + assumption verdicts + sensitivity results
- Place on confidence ladder (RCT > DiD+reg > PSM > DiD > regression > pre-post)
- Include mandatory caveat block (method-specific, non-negotiable)
- Output:
outputs/causal_report_{{DATE}}.md
/causal full
Purpose: End-to-end: select → analyze → check → sensitivity → report.
Flow: Runs all modes in sequence. All Type C checkpoints fire.
Confidence Ladder
Methods ranked by causal credibility (highest to lowest):
| Level |
Method |
Confidence |
| 1 |
RCT (Randomized Experiment) |
HIGH |
| 2 |
DiD + Regression Adjustment |
MODERATE-HIGH |
| 3 |
PSM (Good Overlap + Balance) |
MODERATE |
| 4 |
DiD (Parallel Trends OK) |
MODERATE |
| 5 |
Regression Adjustment |
LOW-MODERATE |
| 6 |
Pre-Post (With Trend) |
LOW |
| 7 |
Pre-Post (Simple) |
VERY LOW |
Mandatory Caveats (Non-Negotiable)
Every causal report MUST include the method-specific caveat. These are architecturally required — the agent cannot produce a report without them.
| Method |
Mandatory Caveat |
| Pre-Post |
"Assumes nothing else changed during this period. Any concurrent event could explain this result." |
| DiD |
"Assumes the control group would have followed the same trend. Plausible but unprovable." |
| PSM |
"Controls for observed confounders only. Unmeasured factors could bias this estimate." |
| Regression |
"Assumes all relevant confounders are included and the model is correctly specified." |
Helper Function Reference
| Function |
Module |
Use For |
pre_post_analysis() |
causal.pre_post |
Pre-post comparison |
did_basic() |
causal.did |
2x2 DiD estimator |
parallel_trends_test() |
causal.did |
Test parallel trends assumption |
event_study() |
causal.did |
Period-by-period effects |
propensity_match() |
causal.matching |
PSM pipeline |
balance_table() |
causal.balance |
SMD balance diagnostics |
love_plot() |
causal.balance |
Before/after balance visual |
regression_adjust() |
causal.regression |
OLS with covariates |
rosenbaum_bounds() |
causal.sensitivity |
PSM sensitivity |
e_value() |
causal.sensitivity |
Universal sensitivity measure |
check_parallel_trends() |
causal.assumptions |
DiD assumption |
check_common_support() |
causal.assumptions |
PSM assumption |
Cross-Product Handoffs
/causal select → "Can you randomize? YES" → suggest /experiment design
/experiment power → NOT_VIABLE → suggest /causal select
/causal check → All assumptions FAIL → suggest redesign or descriptive-only analysis
State Management
analyses/{slug}/
├── causal_config.yaml # Method selection + parameters (tracked)
├── working/ # Intermediates (gitignored)
│ ├── causal_analysis_results.json
│ ├── assumption_report.md
│ └── sensitivity_report.md
└── outputs/ # Final reports (per-analysis run folder)
└── causal_report_{{DATE}}.md
1---2name: causal3description: >-4 Causal inference toolkit for when experiments are not possible: estimate treatment effects from5 observational data with assumption checks and mandatory caveats. Invoke as /causal. Trigger on6 "causal", "caused", "impact of", "effect of", "attribution", "counterfactual",7 "difference-in-differences", "DiD", "propensity matching", "pre-post". If randomization IS8 possible, route to /experiment design instead.9---1011# Skill: /causal — OpenCausalInf Causal Inference Toolkit1213## Purpose14Multi-mode skill for causal inference when experiments aren't possible. Helps users estimate treatment effects from observational data with explicit assumption checking, sensitivity analysis, and mandatory caveats. Uses coded helpers from `helpers/stats/experiment_stats/causal/`.1516## When to Use17Invoke as `/causal [mode]` or trigger on causal inference intents:18- "Did this feature actually cause the improvement?"19- "We can't run an experiment, but..."20- "Was this change responsible for the metric movement?"21- "Can we measure the impact retroactively?"2223## Modes2425### `/causal select`26**Purpose:** Walk the method selection decision tree and recommend a causal method.27**Agent:** `agents/causal/causal-method-selector.md`28**Flow:**291. Ask 4-6 diagnostic questions:30 - Can you randomize? → Route to `/experiment design`31 - Do you have a comparison group?32 - Do you have pre-treatment data?33 - Are there observable confounders you can measure?34 - How many time periods do you have?352. Recommend: Pre-Post, DiD, PSM, Regression Adjustment, or "not feasible"363. Output: recommended method + confidence level + rationale37**Checkpoint:** Method confirmation (Type C — user must confirm before analysis)3839### `/causal analyze`40**Purpose:** Run the selected causal method on data.41**Agent:** `agents/causal/causal-analyzer.md`42**Flow:**431. Read selected method from previous step or user input442. Dispatch to appropriate helper:45 ```python46 from helpers.stats.experiment_stats.causal import (47 pre_post_analysis, did_basic, propensity_match,48 regression_adjust,49 )50 # Method routing:51 # "pre_post" → pre_post_analysis(pre, post, covariates)52 # "did" → did_basic(df, outcome, treat, post)53 # "psm" → propensity_match(df, treat, covariates, outcome)54 # "regression" → regression_adjust(df, outcome, treatment, covariates)55 ```563. Generate charts (treatment effect, balance plots for PSM, event study for DiD)574. Output: `working/causal_analysis_results.json`5859### `/causal check`60**Purpose:** Run assumption checks for the selected method.61**Agent:** `agents/causal/causal-assumption-checker.md`62**Flow:**631. Identify which assumptions apply to the selected method:64 - **DiD:** Parallel trends, no anticipation, stable composition65 - **PSM:** Common support, balance (SMD < 0.1), positivity66 - **Pre-Post:** No concurrent events, trend stability67 - **Regression:** All confounders included, correct specification682. Run quantitative checks:69 ```python70 from helpers.stats.experiment_stats.causal import (71 check_parallel_trends, check_common_support,72 balance_table,73 )74 ```753. Output: per-assumption PASS / WARNING / FAIL verdicts76**Checkpoint:** Any FAIL (Type C) → present options: adjust method, add caveats, or abort7778### `/causal sensitivity`79**Purpose:** Test how robust the estimate is to unmeasured confounding.80**Agent:** `agents/causal/causal-sensitivity.md`81**Flow:**821. Run sensitivity analysis based on method:83 ```python84 from helpers.stats.experiment_stats.causal import rosenbaum_bounds, e_value85 # PSM: rosenbaum_bounds(treated_outcomes, control_outcomes)86 # All: e_value(risk_ratio, ci_lower)87 ```882. Translate to plain language: "An unmeasured confounder would need to be X times stronger than anything we measured to explain away this result."893. Output: sensitivity report9091### `/causal report`92**Purpose:** Generate a report with mandatory caveats.93**Agent:** `agents/causal/causal-report-generator.md`94**Flow:**951. Compile: estimate + CI + assumption verdicts + sensitivity results962. Place on confidence ladder (RCT > DiD+reg > PSM > DiD > regression > pre-post)973. Include mandatory caveat block (method-specific, non-negotiable)984. Output: `outputs/causal_report_{{DATE}}.md`99100### `/causal full`101**Purpose:** End-to-end: select → analyze → check → sensitivity → report.102**Flow:** Runs all modes in sequence. All Type C checkpoints fire.103104## Confidence Ladder105106Methods ranked by causal credibility (highest to lowest):107108| Level | Method | Confidence |109|-------|--------|------------|110| 1 | RCT (Randomized Experiment) | **HIGH** |111| 2 | DiD + Regression Adjustment | **MODERATE-HIGH** |112| 3 | PSM (Good Overlap + Balance) | **MODERATE** |113| 4 | DiD (Parallel Trends OK) | **MODERATE** |114| 5 | Regression Adjustment | **LOW-MODERATE** |115| 6 | Pre-Post (With Trend) | **LOW** |116| 7 | Pre-Post (Simple) | **VERY LOW** |117118## Mandatory Caveats (Non-Negotiable)119120Every causal report MUST include the method-specific caveat. These are architecturally required — the agent cannot produce a report without them.121122| Method | Mandatory Caveat |123|--------|-----------------|124| Pre-Post | "Assumes nothing else changed during this period. Any concurrent event could explain this result." |125| DiD | "Assumes the control group would have followed the same trend. Plausible but unprovable." |126| PSM | "Controls for observed confounders only. Unmeasured factors could bias this estimate." |127| Regression | "Assumes all relevant confounders are included and the model is correctly specified." |128129## Helper Function Reference130131| Function | Module | Use For |132|----------|--------|---------|133| `pre_post_analysis()` | `causal.pre_post` | Pre-post comparison |134| `did_basic()` | `causal.did` | 2x2 DiD estimator |135| `parallel_trends_test()` | `causal.did` | Test parallel trends assumption |136| `event_study()` | `causal.did` | Period-by-period effects |137| `propensity_match()` | `causal.matching` | PSM pipeline |138| `balance_table()` | `causal.balance` | SMD balance diagnostics |139| `love_plot()` | `causal.balance` | Before/after balance visual |140| `regression_adjust()` | `causal.regression` | OLS with covariates |141| `rosenbaum_bounds()` | `causal.sensitivity` | PSM sensitivity |142| `e_value()` | `causal.sensitivity` | Universal sensitivity measure |143| `check_parallel_trends()` | `causal.assumptions` | DiD assumption |144| `check_common_support()` | `causal.assumptions` | PSM assumption |145146## Cross-Product Handoffs147148- `/causal select` → "Can you randomize? YES" → suggest `/experiment design`149- `/experiment power` → NOT_VIABLE → suggest `/causal select`150- `/causal check` → All assumptions FAIL → suggest redesign or descriptive-only analysis151152## State Management153154```155analyses/{slug}/156├── causal_config.yaml # Method selection + parameters (tracked)157├── working/ # Intermediates (gitignored)158│ ├── causal_analysis_results.json159│ ├── assumption_report.md160│ └── sensitivity_report.md161└── outputs/ # Final reports (per-analysis run folder)162 └── causal_report_{{DATE}}.md163```