causal-inferenceAdd causal reasoning to agent actions. Trigger on ANY high-level action with observable outcomes - emails, messages, calendar changes, file operations, API calls, notifications, reminders, purchases, deployments. Use for planning interventions, debugging failures, predicting outcomes, backfilling historical data for analysis, or answering "what happens if I do X?" Also trigger when reviewing past actions to understand what worked/failed and why.
Install via ClawdBot CLI:
clawdbot install oswalpalash/causal-inferenceA lightweight causal layer for predicting action outcomes, not by pattern-matching correlations, but by modeling interventions and counterfactuals.
Every action must be representable as an explicit intervention on a causal model, with predicted effects + uncertainty + a falsifiable audit trail.
Plans must be causally valid, not just plausible.
Trigger this skill on ANY high-level action, including but not limited to:
| Domain | Actions to Log |
|--------|---------------|
| Communication | Send email, send message, reply, follow-up, notification, mention |
| Calendar | Create/move/cancel meeting, set reminder, RSVP |
| Tasks | Create/complete/defer task, set priority, assign |
| Files | Create/edit/share document, commit code, deploy |
| Social | Post, react, comment, share, DM |
| Purchases | Order, subscribe, cancel, refund |
| System | Config change, permission grant, integration setup |
Also trigger when:
Don't start from zero. Parse existing logs to reconstruct past actions + outcomes.
# Extract sent emails with reply status
gog gmail list --sent --after 2024-01-01 --format json > /tmp/sent_emails.json
# For each sent email, check if reply exists
python3 scripts/backfill_email.py /tmp/sent_emails.json
# Extract past events with attendance
gog calendar list --after 2024-01-01 --format json > /tmp/events.json
# Reconstruct: did meeting happen? was it moved? attendee count?
python3 scripts/backfill_calendar.py /tmp/events.json
# Parse message history for send/reply patterns
wacli search --after 2024-01-01 --from me --format json > /tmp/wa_sent.json
python3 scripts/backfill_messages.py /tmp/wa_sent.json
# For any historical data source:
for record in historical_data:
action_event = {
"action": infer_action_type(record),
"context": extract_context(record),
"time": record["timestamp"],
"pre_state": reconstruct_pre_state(record),
"post_state": extract_post_state(record),
"outcome": determine_outcome(record),
"backfilled": True # Mark as reconstructed
}
append_to_log(action_event)
Every executed action emits a structured event:
{
"action": "send_followup",
"domain": "email",
"context": {"recipient_type": "warm_lead", "prior_touches": 2},
"time": "2025-01-26T10:00:00Z",
"pre_state": {"days_since_last_contact": 7},
"post_state": {"reply_received": true, "reply_delay_hours": 4},
"outcome": "positive_reply",
"outcome_observed_at": "2025-01-26T14:00:00Z",
"backfilled": false
}
Store in memory/causal/action_log.jsonl.
Start with 10-30 observable variables per domain.
Email domain:
send_time → reply_prob
subject_style → open_rate
recipient_type → reply_prob
followup_count → reply_prob (diminishing)
time_since_last → reply_prob
Calendar domain:
meeting_time → attendance_rate
attendee_count → slip_risk
conflict_degree → reschedule_prob
buffer_time → focus_quality
Messaging domain:
response_delay → conversation_continuation
message_length → response_length
time_of_day → response_prob
platform → response_delay
Task domain:
due_date_proximity → completion_prob
priority_level → completion_speed
task_size → deferral_risk
context_switches → error_rate
Store graph definitions in memory/causal/graphs/.
For each "knob" (intervention variable), estimate treatment effects:
# Pseudo: effect of morning vs evening sends
effect = mean(reply_prob | send_time=morning) - mean(reply_prob | send_time=evening)
uncertainty = std_error(effect)
Use simple regression or propensity matching first. Graduate to do-calculus when graphs are explicit and identification is needed.
Before executing actions:
BEFORE executing:
1. Log pre_state
2. If enough historical data: query model for expected outcome
3. If high uncertainty or risk: confirm with user
AFTER executing:
1. Log action + context + time
2. Set reminder to check outcome (if not immediate)
WHEN outcome observed:
1. Update action log with post_state + outcome
2. Re-estimate treatment effects if enough new data
1. User request → identify candidate actions
2. For each action:
a. Map to intervention(s) on causal graph
b. Predict P(outcome | do(action))
c. Estimate uncertainty
d. Compute expected utility
3. Rank by expected utility, filter by safety
4. Execute best action, log prediction
5. Observe outcome, update model
1. Identify failed outcome
2. Trace back through causal graph
3. For each upstream node:
a. Was the value as expected?
b. Did the causal link hold?
4. Identify broken link(s)
5. Compute minimal intervention set that would have prevented failure
6. Log counterfactual for learning
# 1. Create the infrastructure
mkdir -p memory/causal/graphs memory/causal/estimates
# 2. Initialize config
cat > memory/causal/config.yaml << 'EOF'
domains:
- email
- calendar
- messaging
- tasks
thresholds:
max_uncertainty: 0.3
min_expected_utility: 0.1
protected_actions:
- delete_email
- cancel_meeting
- send_to_new_contact
- financial_transaction
EOF
# 3. Backfill one domain (start with email)
python3 scripts/backfill_email.py
# 4. Estimate initial effects
python3 scripts/estimate_effect.py --treatment send_time --outcome reply_received --values morning,evening
Define "protected variables" that require explicit user approval:
protected:
- delete_email
- cancel_meeting
- send_to_new_contact
- financial_transaction
thresholds:
max_uncertainty: 0.3 # don't act if P(outcome) uncertainty > 30%
min_expected_utility: 0.1 # don't act if expected gain < 10%
memory/causal/action_log.jsonl — all logged actions with outcomesmemory/causal/graphs/ — domain-specific causal graph definitionsmemory/causal/estimates/ — learned treatment effectsmemory/causal/config.yaml — safety thresholds and protected variablesreferences/do-calculus.md for formal intervention semanticsreferences/estimation.md for treatment effect estimation methodsGenerated Mar 1, 2026
A marketing team uses the skill to analyze past email campaigns, modeling how send time, subject line, and recipient type affect open and reply rates. They predict optimal times and styles for future campaigns, backfilling from historical email logs to bootstrap the causal model.
An administrative assistant leverages the skill to schedule meetings by predicting attendance rates based on time of day, attendee count, and buffer periods. They backfill from calendar history to refine predictions, reducing reschedules and improving focus quality.
A support team applies the skill to model how response delay and message length affect conversation continuation and resolution rates. They use historical chat logs to backfill data, optimizing response strategies to enhance customer satisfaction.
A project manager uses the skill to predict task completion probabilities based on due date proximity, priority level, and task size. By backfilling from task logs, they optimize workflows to minimize deferral risks and error rates.
An e-commerce analyst employs the skill to understand causal factors behind purchases, such as notification timing and user engagement levels. They backfill from purchase and interaction logs to model interventions, improving conversion rates and reducing refunds.
Offer the skill as a cloud-based service with tiered pricing based on usage volume (e.g., number of actions analyzed per month). Target small to medium businesses for email and calendar optimization, with premium tiers for advanced causal modeling.
Provide custom integration services to deploy the skill within existing enterprise systems (e.g., CRM, project management tools). Charge per project for setup, backfilling historical data, and ongoing support to ensure causal validity.
License the skill as an add-on module for existing data analytics or AI platforms, enhancing their capabilities with causal inference. Revenue comes from licensing fees per user or per integration, targeting tech companies seeking advanced predictive features.
💬 Integration Tip
Start by backfilling historical data from common sources like email and calendar logs to bootstrap the causal model, then integrate incrementally with existing workflows to validate predictions before full deployment.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection