Causal Assumptions Experimental Design Lens
Philosophical Mode: Causal-Structural
Primary Question: "What causal assumptions support this design?"
Focus: Confounders, Mediators, Colliders, Adjustment Sets, Identification Strategy
When to Use
- Experiment claims causal effects
- Pipeline has shared components that might confound
- Need to verify identification strategy
- User invokes
/exp-lens-causal-assumptions or /make-experiment-diag causal
Critical Constraints
NEVER:
- Modify any source code files
- Do not litter the codebase with useless comments, TODO markers, or explanatory annotations — the skill output and diagram speak for themselves
ALWAYS:
- Classify every variable as Treatment, Outcome, Confounder, Mediator, Collider, Instrument, or Selection variable
- Map every directed edge to a concrete code-level data flow
- Flag all unblocked backdoor paths explicitly
- Document the identification strategy with testable assumptions
- BEFORE creating any diagram, LOAD the
/mermaid skill using the Skill tool - this is MANDATORY
Analysis Workflow
Step 1: Launch Parallel Exploration Subagents
Spawn Explore subagents to investigate:
Treatment & Outcome Definition
- Find experiment config, treatment assignment code, outcome measurement
- Look for: treatment, control, outcome, response, endpoint, metric
Confounding Pathways
- Find shared data sources, preprocessing, environment variables
- Look for: shared, common, config, environment, seed, global
Mediator & Mechanism Variables
- Find intermediate processing steps between treatment and outcome
- Look for: transform, preprocess, feature, intermediate, pipeline
Collider & Selection Variables
- Find filtering, subsetting, or conditional logic applied post-treatment
- Look for: filter, subset, exclude, condition, threshold, select
Randomization & Assignment
- Find how experimental units are assigned to conditions
- Look for: random, assign, allocate, split, stratify, block
Step 2: Build the Causal Graph Structure
For each variable identified, classify as: Treatment, Outcome, Confounder, Mediator, Collider, Instrument, or Selection variable. Map directed edges based on code-level data flow. Flag any unblocked backdoor paths.
Step 3: Identify Causal Assumptions
CRITICAL — Analyze Claim Direction:
For every edge in the causal graph, determine:
- Does code implement a causal mechanism (A produces B) or merely a statistical association?
- Is the direction grounded in temporal ordering or domain knowledge?
- Are there feedback loops?
Document each assumption as either testable or untestable, and record the evidence (or lack of evidence) from the codebase.
Step 4: Create the Diagram
Use flowchart with:
Direction: TB (causes flow downward to effects)
Subgraphs:
- TREATMENT ASSIGNMENT
- MEDIATING MECHANISMS
- OUTCOME MEASUREMENT
- CONFOUNDERS
- SELECTION/COLLIDERS
Node Styling:
cli class: Treatment variables
output class: Outcome variables
handler class: Mediators
stateNode class: Confounders
detector class: Colliders and selection variables
gap class: Unblocked backdoor paths
newComponent class: Instruments
Edge Labels: causal, confounds, selects, mediates, blocks
Step 5: Write Output
Write the diagram to: temp/exp-lens-causal-assumptions/exp_diag_causal_assumptions_{YYYY-MM-DD_HHMMSS}.md
Output Template
# Causal Assumptions Diagram: {Experiment Name}
**Lens:** Causal Assumptions (Causal-Structural)
**Question:** What causal assumptions support this design?
**Date:** {YYYY-MM-DD}
**Scope:** {What was analyzed}
## Causal Variables
| Variable | Type | Measured? | Controlled? |
|----------|------|-----------|-------------|
| {name} | {Treatment/Outcome/Confounder/Mediator/Collider/Instrument/Selection} | {Yes/No} | {Yes/No} |
## Causal DAG
```mermaid
%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%
flowchart TB
%% CLASS DEFINITIONS %%
classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;
classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;
classDef gap fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#000;
classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;
subgraph Confounders ["CONFOUNDERS"]
CONF["Confounder Variable<br/>━━━━━━━━━━<br/>Shared source<br/>Controlled?"]
end
subgraph Treatment ["TREATMENT ASSIGNMENT"]
TREAT["Treatment<br/>━━━━━━━━━━<br/>Assignment mechanism<br/>Randomized?"]
INSTR["Instrument<br/>━━━━━━━━━━<br/>Exclusion restriction"]
end
subgraph Mediators ["MEDIATING MECHANISMS"]
MED["Mediator<br/>━━━━━━━━━━<br/>Intermediate step"]
end
subgraph Outcome ["OUTCOME MEASUREMENT"]
OUT["Outcome<br/>━━━━━━━━━━<br/>Metric / endpoint"]
end
subgraph Selection ["SELECTION/COLLIDERS"]
COLL["Collider<br/>━━━━━━━━━━<br/>Post-treatment filter"]
end
%% CAUSAL EDGES %%
CONF -->|"confounds"| TREAT
CONF -->|"confounds"| OUT
INSTR -->|"causal"| TREAT
TREAT -->|"causal"| MED
MED -->|"mediates"| OUT
TREAT -->|"selects"| COLL
OUT -->|"selects"| COLL
%% CLASS ASSIGNMENTS %%
class TREAT cli;
class OUT output;
class MED handler;
class CONF stateNode;
class COLL detector;
class INSTR newComponent;
Color Legend:
| Color |
Category |
Description |
| Dark Blue |
Treatment |
Treatment assignment variables |
| Dark Teal |
Outcome |
Outcome measurement variables |
| Orange |
Mediator |
Intermediate mechanism variables |
| Teal |
Confounder |
Shared causes of treatment and outcome |
| Red |
Collider/Selection |
Post-treatment filters (conditioning risk) |
| Green |
Instrument |
Variables affecting only treatment |
| Amber |
Backdoor Path |
Unblocked confounding path |
Identification Strategy
| Assumption |
Testable? |
Evidence |
| {assumption} |
{Yes/No} |
{evidence from codebase} |
Unblocked Backdoor Paths
| Path |
Variables |
Severity |
Mitigation |
| {path} |
{A -> ... -> B} |
{High/Medium/Low} |
{adjustment/unavailable} |
---
## Pre-Diagram Checklist
Before creating the diagram, verify:
- [ ] LOADED `/mermaid` skill using the Skill tool
- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
- [ ] Diagram will include a color legend table
---
## Related Skills
- `/make-experiment-diag` - Parent skill for lens selection
- `/mermaid` - MUST BE LOADED before creating diagram
- `/exp-lens-estimand-clarity` - For clarifying the target estimand
- `/exp-lens-validity-threats` - For broader validity threat inventory
1---2name: exp-lens-causal-assumptions3description: Create Causal Assumptions experimental design diagram showing confounders, mediators, colliders, and identification strategy. Causal-structural lens answering "What causal assumptions support this design?"4---56# Causal Assumptions Experimental Design Lens78**Philosophical Mode:** Causal-Structural9**Primary Question:** "What causal assumptions support this design?"10**Focus:** Confounders, Mediators, Colliders, Adjustment Sets, Identification Strategy1112## When to Use1314- Experiment claims causal effects15- Pipeline has shared components that might confound16- Need to verify identification strategy17- User invokes `/exp-lens-causal-assumptions` or `/make-experiment-diag causal`1819## Critical Constraints2021**NEVER:**22- Modify any source code files23- Do not litter the codebase with useless comments, TODO markers, or explanatory annotations — the skill output and diagram speak for themselves2425**ALWAYS:**26- Classify every variable as Treatment, Outcome, Confounder, Mediator, Collider, Instrument, or Selection variable27- Map every directed edge to a concrete code-level data flow28- Flag all unblocked backdoor paths explicitly29- Document the identification strategy with testable assumptions30- BEFORE creating any diagram, LOAD the `/mermaid` skill using the Skill tool - this is MANDATORY3132---3334## Analysis Workflow3536### Step 1: Launch Parallel Exploration Subagents3738Spawn Explore subagents to investigate:3940**Treatment & Outcome Definition**41- Find experiment config, treatment assignment code, outcome measurement42- Look for: treatment, control, outcome, response, endpoint, metric4344**Confounding Pathways**45- Find shared data sources, preprocessing, environment variables46- Look for: shared, common, config, environment, seed, global4748**Mediator & Mechanism Variables**49- Find intermediate processing steps between treatment and outcome50- Look for: transform, preprocess, feature, intermediate, pipeline5152**Collider & Selection Variables**53- Find filtering, subsetting, or conditional logic applied post-treatment54- Look for: filter, subset, exclude, condition, threshold, select5556**Randomization & Assignment**57- Find how experimental units are assigned to conditions58- Look for: random, assign, allocate, split, stratify, block5960### Step 2: Build the Causal Graph Structure6162For each variable identified, classify as: Treatment, Outcome, Confounder, Mediator, Collider, Instrument, or Selection variable. Map directed edges based on code-level data flow. Flag any unblocked backdoor paths.6364### Step 3: Identify Causal Assumptions6566**CRITICAL — Analyze Claim Direction:**67For every edge in the causal graph, determine:68- Does code implement a causal mechanism (A produces B) or merely a statistical association?69- Is the direction grounded in temporal ordering or domain knowledge?70- Are there feedback loops?7172Document each assumption as either testable or untestable, and record the evidence (or lack of evidence) from the codebase.7374### Step 4: Create the Diagram7576Use flowchart with:7778**Direction:** `TB` (causes flow downward to effects)7980**Subgraphs:**81- TREATMENT ASSIGNMENT82- MEDIATING MECHANISMS83- OUTCOME MEASUREMENT84- CONFOUNDERS85- SELECTION/COLLIDERS8687**Node Styling:**88- `cli` class: Treatment variables89- `output` class: Outcome variables90- `handler` class: Mediators91- `stateNode` class: Confounders92- `detector` class: Colliders and selection variables93- `gap` class: Unblocked backdoor paths94- `newComponent` class: Instruments9596**Edge Labels:** causal, confounds, selects, mediates, blocks9798### Step 5: Write Output99100Write the diagram to: `temp/exp-lens-causal-assumptions/exp_diag_causal_assumptions_{YYYY-MM-DD_HHMMSS}.md`101102---103104## Output Template105106```markdown107# Causal Assumptions Diagram: {Experiment Name}108109**Lens:** Causal Assumptions (Causal-Structural)110**Question:** What causal assumptions support this design?111**Date:** {YYYY-MM-DD}112**Scope:** {What was analyzed}113114## Causal Variables115116| Variable | Type | Measured? | Controlled? |117|----------|------|-----------|-------------|118| {name} | {Treatment/Outcome/Confounder/Mediator/Collider/Instrument/Selection} | {Yes/No} | {Yes/No} |119120## Causal DAG121122```mermaid123%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%124flowchart TB125 %% CLASS DEFINITIONS %%126 classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;127 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;128 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;129 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;130 classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;131 classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;132 classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;133 classDef gap fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#000;134 classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;135136 subgraph Confounders ["CONFOUNDERS"]137 CONF["Confounder Variable<br/>━━━━━━━━━━<br/>Shared source<br/>Controlled?"]138 end139140 subgraph Treatment ["TREATMENT ASSIGNMENT"]141 TREAT["Treatment<br/>━━━━━━━━━━<br/>Assignment mechanism<br/>Randomized?"]142 INSTR["Instrument<br/>━━━━━━━━━━<br/>Exclusion restriction"]143 end144145 subgraph Mediators ["MEDIATING MECHANISMS"]146 MED["Mediator<br/>━━━━━━━━━━<br/>Intermediate step"]147 end148149 subgraph Outcome ["OUTCOME MEASUREMENT"]150 OUT["Outcome<br/>━━━━━━━━━━<br/>Metric / endpoint"]151 end152153 subgraph Selection ["SELECTION/COLLIDERS"]154 COLL["Collider<br/>━━━━━━━━━━<br/>Post-treatment filter"]155 end156157 %% CAUSAL EDGES %%158 CONF -->|"confounds"| TREAT159 CONF -->|"confounds"| OUT160 INSTR -->|"causal"| TREAT161 TREAT -->|"causal"| MED162 MED -->|"mediates"| OUT163 TREAT -->|"selects"| COLL164 OUT -->|"selects"| COLL165166 %% CLASS ASSIGNMENTS %%167 class TREAT cli;168 class OUT output;169 class MED handler;170 class CONF stateNode;171 class COLL detector;172 class INSTR newComponent;173```174175**Color Legend:**176| Color | Category | Description |177|-------|----------|-------------|178| Dark Blue | Treatment | Treatment assignment variables |179| Dark Teal | Outcome | Outcome measurement variables |180| Orange | Mediator | Intermediate mechanism variables |181| Teal | Confounder | Shared causes of treatment and outcome |182| Red | Collider/Selection | Post-treatment filters (conditioning risk) |183| Green | Instrument | Variables affecting only treatment |184| Amber | Backdoor Path | Unblocked confounding path |185186## Identification Strategy187188| Assumption | Testable? | Evidence |189|------------|-----------|----------|190| {assumption} | {Yes/No} | {evidence from codebase} |191192## Unblocked Backdoor Paths193194| Path | Variables | Severity | Mitigation |195|------|-----------|----------|------------|196| {path} | {A -> ... -> B} | {High/Medium/Low} | {adjustment/unavailable} |197```198199---200201## Pre-Diagram Checklist202203Before creating the diagram, verify:204205- [ ] LOADED `/mermaid` skill using the Skill tool206- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)207- [ ] Diagram will include a color legend table208209---210211## Related Skills212213- `/make-experiment-diag` - Parent skill for lens selection214- `/mermaid` - MUST BE LOADED before creating diagram215- `/exp-lens-estimand-clarity` - For clarifying the target estimand216- `/exp-lens-validity-threats` - For broader validity threat inventory