title: "Codex + Astra: How Multimodal Agents Turn Raw Data Into Discovery [SKILL.md Guide]" description: "Learn how agentic workflows using Codex and Astra automate complex data analysis. Includes a ready-to-install SKILL.md for anomaly detection in business metrics" slug: "codex-astra-agentic-data-analysis-skill-md" category: 1579052
Codex + Astra: How Multimodal Agents Turn Raw Data Into Discovery
60-Second Executive Summary
What happened: On November 24, 2026, a case study demonstrated how two amateur astronomers leveraged OpenAI Codex (code generation) and Google Astra (multimodal reasoning/agent orchestration) to identify potential exoplanet candidates in public NASA Kepler and TESS datasets. They did not write custom pipelines from scratch. They prompted an agentic loop: Astra visualized light curves, hypothesized transit signals, instructed Codex to write Python analysis scripts, executed them, and iterated until statistical significance emerged.
Why it changes business operations: This is not an astronomy story. It is a knowledge-work architecture story. It proves that a multimodal orchestrator (Astra) + a code executor (Codex) + domain context (your data) replaces the need for a dedicated data science team for 80% of analytical workflows. For a solopreneur or small agency, the barrier to "custom data intelligence" has collapsed from "hire a $150k ML engineer" to "install a SKILL.md playbook and point it at your CSV/Database."
The Agentic Takeaway: The winning formula is AGENTS.md (Context) + SKILL.md (Process) + MCP (Tool Access) + Human-in-the-Loop (Judgment). The astronomers provided the domain context (what a transit looks like). The Agent handled the syntax, the API calls, the visualization, and the iteration loop. Your business data (Stripe logs, GA4 exports, CRM pipelines, support tickets) is your Kepler dataset. The "exoplanets" are your hidden churn signals, fraud patterns, or upsell opportunities.
Free Download: The 1-Person Agentic Business Blueprint
Get 1 Plug-and-Play SKILL.md template, 1 Departmental Agent Blueprint, and 3 Master Prompts to deploy in Claude, ChatGPT, or Gemini today.
Strategic Impact: Plugging Into the 3-Layer Agentic Stack
Most founders treat AI as a chat interface. The Astra/Codex breakthrough proves the ROI lives in the Agentic Stack. Here is how you operationalize this today without writing a single line of infrastructure code.
Layer 1: AGENTS.md - The Company Brain (Context & Guardrails)
The astronomers knew what to look for (periodic dips in brightness). Your AGENTS.md file codifies your business physics.
- Action: Define your "Light Curves." What are the time-series metrics that matter? MRR, Daily Active Users, Ticket Resolution Time, Ad Spend vs. ROAS.
- Guardrail: Explicitly forbid the agent from hallucinating data sources. "Only query the analytics_warehouse MCP server. Do not invent column names."
Layer 2: SKILL.md - The Playbook (Deterministic SOP)
The astronomers ran a loop: Visualize -> Hypothesize -> Code -> Execute -> Verify. That is a Skill. Not a prompt. A Skill is a version-controlled, testable, repeatable Standard Operating Procedure that an Agent executes autonomously.
- Value: You write the SOP once (or install ours below). The Agent runs it every Monday at 6 AM on fresh data.
- Difference: A prompt asks "Analyze this." A Skill commands "Run the Anomaly_Detection_v3 protocol on the stripe_churn table and output a Slack alert if p-value < 0.01."
Layer 3: MCP (Model Context Protocol) - The Tool Connectors (Action)
Astra needed access to NASA archives. Your agents need access to Postgres, Stripe API, HubSpot, Google Sheets, S3.
- Setup: Deploy an MCP Gateway (open source, runs on a $5 VPS or Railway/Render). Expose read-only views of your business tables.
- Security: The Agent never sees raw credentials. It calls mcp.query(sql="..."). The Gateway enforces row-level security.
Layer 4: Human-in-the-Loop (HITL) - The Oversight (Judgment)
The astronomers verified the candidates. Your Agent drafts the "Anomaly Report." You (or your Ops Lead) spend 5 minutes reading it, clicking "Approve -> Auto-generate Retention Campaign" or "False Positive -> Log to Training Set." - Rule: Agent Proposes, Human Disposes. Never auto-execute destructive actions (refunds, firings, budget cuts) without a signed confirmation.
Ready-to-Install: SKILL.md for Automated Anomaly Detection
This Skill generalizes the "Exoplanet Hunting" workflow for Business Time-Series Anomaly Detection. It works on any metric with a timestamp and a value (Revenue, Traffic, Error Rates, Inventory).
Save this file as skills/01_anomaly_detection_time_series.skill.md in your Agentic OS repository.
---
name: "Automated Time-Series Anomaly Detection"
version: "1.0.0"
description: |
Scans specified time-series metrics for statistically significant anomalies (spikes, drops, trend breaks)
using STL Decomposition + Isolation Forest. Outputs a prioritized executive brief with root-cause hypotheses
and suggested SQL drill-down queries. Designed for daily/weekly automated runs via Agent Scheduler.
author: "The AI Business Shortcut"
tags: [analytics, anomaly-detection, finance, marketing, operations, mcp, codex]
required_mcp_servers:
- "analytics_warehouse" # Read-only access to metrics tables
- "notification_gateway" # Slack/Email webhook for alerts
guardrails:
- "NEVER write to production tables. Read-only transactions only."
- "NEVER expose PII in output. Aggregate to daily/weekly grain."
- "ALWAYS cite the exact SQL query used for evidence."
- "IF statistical significance (p-value) > 0.05, classify as 'Noise' and suppress alert unless 'force_verbose: true'."
- "MAX execution time: 120 seconds per metric."
inputs:
metric_configs:
type: "array"
description: "List of metrics to scan. Define in AGENTS.md or pass dynamically."
items:
type: "object"
required: ["metric_name", "table_name", "timestamp_col", "value_col", "grain", "lookback_days"]
properties:
metric_name: { type: "string", example: "Net New MRR" }
table_name: { type: "string", example: "finance.daily_metrics" }
timestamp_col: { type: "string", example: "metric_date" }
value_col: { type: "string", example: "net_new_mrr_usd" }
grain: { type: "string", enum: ["daily", "weekly", "monthly"], example: "daily" }
lookback_days: { type: "integer", minimum: 30, maximum: 730, example: 365 }
seasonality_period: { type: "integer", description: "Days for seasonal cycle (7 for weekly, 365 for yearly)", example: 7 }
alert_threshold_zscore:
type: "number"
default: 3.0
description: "Z-score threshold on residuals to flag anomaly."
force_verbose:
type: "boolean"
default: false
description: "If true, report all investigated metrics, not just anomalies."
outputs:
anomaly_brief:
type: "object"
description: "Markdown report for Human-in-the-Loop review."
drill_down_queries:
type: "array"
description: "Parameterized SQL snippets for investigator to run next."
---
# SOP: Automated Anomaly Detection Protocol
## Phase 0: Initialization & Context Load
1. **Load Company Brain:** Read `AGENTS.md` to retrieve `company_context`, `metric_definitions`, and `current_strategic_priorities`.
2. **Validate Inputs:** Ensure `metric_configs` array is populated. If empty, fetch default list from `AGENTS.md > default_metrics_to_monitor`.
3. **MCP Health Check:** Ping `analytics_warehouse`. If latency > 5s or error, **ABORT** and alert `notification_gateway` with tag `#infra-alert`.
## Phase 1: Data Ingestion Loop (Per Metric Config)
**FOR EACH** `config` IN `metric_configs`:
1. **Construct Query:** Build parameterized SQL:
```sql
SELECT {{timestamp_col}} as ds, {{value_col}} as y
FROM {{table_name}}
WHERE {{timestamp_col}} >= CURRENT_DATE - INTERVAL '{{lookback_days}} days'
ORDER BY {{timestamp_col}} ASC;
```
2. **Execute via MCP:** Call `analytics_warehouse.query(sql=...)`.
3. **Validate Data Quality:**
- Row count >= `seasonality_period * 2` (minimum 2 cycles).
- Null ratio in `y` < 5%.
- **FAIL FAST:** If failed, log `Data Quality Issue: {{metric_name}}` to report, `CONTINUE` to next metric.
## Phase 2: Agentic Analysis (Codex Execution)
**Instruction to Code Executor (Internal Monologue/Tool Call):**
> "Write a Python script using `pandas`, `statsmodels` (STL), `sklearn` (IsolationForest), and `scipy`.
> Input: DataFrame `df` with columns `ds` (datetime), `y` (float).
> Steps:
> 1. Ensure regular frequency (resample/interpolate if gaps < 3 periods).
> 2. Run STL Decomposition (period={{seasonality_period}}, robust=True) -> Trend, Seasonal, Resid.
> 3. Fit IsolationForest(contamination=0.01, random_state=42) on Resid values.
> 4. Calculate Z-scores of Resid.
> 5. Flag anomalies: `is_anomaly = (iforest_score == -1) AND (abs(z_score) > {{alert_threshold_zscore}})`.
> 6. Focus on **LAST 14 DAYS** (or last 2 periods if weekly/monthly).
> 7. Output JSON: `{ 'anomaly_dates': [], 'anomaly_values': [], 'z_scores': [], 'trend_direction': 'up/down/flat', 'seasonal_strength': float }`."
4. **Execute Code:** Run generated script via Code Execution Tool (Codex equivalent).
5. **Parse Result:** Structure output into `Finding` object.
## Phase 3: Hypothesis Generation (Astra Multimodal Reasoning)
**FOR EACH** `Finding` WHERE `anomaly_dates` NOT EMPTY:
1. **Contextualize:** Retrieve relevant context from `AGENTS.md` (e.g., "Last week: Black Friday Sale", "Yesterday: API v3 Deploy").
2. **Generate Hypotheses (Max 3):**
- *Internal:* "Deploy v3 caused 5xx spike -> Revenue drop."
- *External:* "Competitor launched lifetime deal -> Churn spike."
- *Data Artifact:* "Timezone shift in logging -> Fake drop."
3. **Draft Drill-Down SQL:** Generate parameterized query to test top hypothesis (e.g., `SELECT error_code, count(*) FROM logs WHERE date=... GROUP BY 1`).
## Phase 4: Report Assembly & Delivery
1. **Render Markdown Brief:** Use template `templates/anomaly_brief.md.j2` (see Output Template below).
2. **Route Output:**
- **ALWAYS:** Save full JSON + MD to `artifacts/anomaly_{{run_date}}.json`.
- **IF** Anomalies Found: Push Markdown to `notification_gateway` (Slack `#insights-anomalies`).
- **IF** `force_verbose`: Push summary of *all* scanned metrics (Green/Red status) to `notification_gateway` (Slack `#insights-daily-digest`).
---
# Output Template: `templates/anomaly_brief.md.j2`
```markdown
# 🚨 Anomaly Detection Brief - {{ run_date }}
**Scan Window:** Last {{ lookback_days }} days | **Metrics Scanned:** {{ metrics_scanned_count }} | **Anomalies Found:** {{ anomalies_found_count }}
---
{% for finding in findings %}
## {{ finding.metric_name }} {{ "🔴 ANOMALY" if finding.anomalies else "🟢 NOMINAL" }}
**Grain:** {{ finding.grain }} | **Lookback:** {{ finding.lookback_days }}d
**Trend:** {{ finding.trend_direction }} | **Seasonal Strength:** {{ "%.2f"|format(finding.seasonal_strength) }}
### 📈 Evidence (Last 14 Days)
| Date | Actual Value | Expected (Trend+Seasonal) | Residual | Z-Score | Flag |
|------|--------------|---------------------------|----------|---------|------|
{% for row in finding.recent_rows %}
| {{ row.ds }} | {{ row.y }} | {{ row.predicted }} | {{ row.resid }} | {{ row.z_score }} | {{ "🚨" if row.is_anomaly else "" }} |
{% endfor %}
### 🧠Agent Hypotheses (Priority Order)
{% for i, hyp in finding.hypotheses %}
{{ i+1 }}. **{{ hyp.type }}:** {{ hyp.description }}
- *Test Query:* `\`\`\`sql\n{{ hyp.test_query }}\n\`\`\``
{% endfor %}
### 🎯 Recommended Human Action
- [ ] **Validate:** Run Test Query above in MCP Explorer.
- [ ] **Classify:** `True Positive` / `False Positive (Data Issue)` / `False Positive (Benign Event)`.
- [ ] **Actuate:** If True Positive -> Link to Incident Ticket / Trigger Playbook `{{ finding.suggested_playbook }}`.
---
{% endfor %}
*Generated by Agentic OS • Skill: `Automated Time-Series Anomaly Detection v1.0` • {{ timestamp_utc }}*
Companion Copy-Paste Prompt (No-Code Test Drive)
Paste this into ChatGPT (GPT-4o), Claude 3.5 Sonnet, or Gemini 1.5 Pro. Prerequisite: Export a CSV of one key metric (Date, Value) from your Stripe, GA4, or SQL tool (last 12 months ideal).
# ROLE: Senior Data Scientist & Business Analyst
# CONTEXT: I am a solo founder / operator. I have a CSV of a key business metric (Date, Value). I want to replicate the "Astra/Codex Exoplanet Discovery" workflow: find hidden anomalies (exoplanets) in my data without writing infrastructure code.
# MY DATA:
# Paste your CSV content below (or describe columns if huge).
# Expected columns: 'date' (YYYY-MM-DD), 'value' (numeric).
# Example: "date,value\n2023-01-01,1200\n2023-01-02,1350..."
<<PASTE_YOUR_CSV_HERE>>
# TASK: Execute the "Automated Time-Series Anomaly Detection" SOP manually.
# STRICTLY FOLLOW THESE STEPS. DO NOT SKIP TO CONCLUSION.
## STEP 1: DATA QUALITY & EXPLORATION
- Parse CSV. Check for gaps, nulls, frequency irregularities.
- Output: "Data Quality Report" (Rows, Date Range, Gaps, Null %, Visual ASCII Sparkline of trend).
## STEP 2: STATISTICAL DECOMPOSITION (Simulate STL + Isolation Forest)
- Since I cannot run `statsmodels` here, simulate the logic rigorously:
1. Estimate Trend (Rolling median, window=30d).
2. Estimate Seasonality (Day-of-week or Month-of-year averages).
3. Calculate Residuals = Value - Trend - Seasonal.
4. Calculate Rolling Z-Score of Residuals (window=30d).
5. Flag Anomalies: |Z-Score| > 3.0 AND in last 30 days of data.
- Output: Table of **Top 5 Anomalies** (Date, Value, Trend, Seasonal, Residual, Z-Score).
## STEP 3: HYPOTHESIS GENERATION (The "Astra" Step)
- For EACH flagged anomaly, generate 3 distinct hypotheses:
1. **Internal Operational:** (Code deploy, pricing change, email send, server outage).
2. **External Market:** (Competitor move, holiday, news cycle, seasonality shift).
3. **Data Artifact:** (Tracking break, timezone bug, duplicate entry, backfill).
- Format: "Hypothesis [Type]: [Specific Mechanism]. Verification Question: [How to prove/disprove with 1 SQL query or log check]."
## STEP 4: EXECUTIVE BRIEF (The "Human-in-the-Loop" Handoff)
- Produce a **Markdown Report** formatted exactly for Slack/Notion.
- Sections: **Summary**, **Top Anomaly Table**, **Hypothesis Matrix**, **Immediate Action Items (Checkboxes)**.
- Tone: Crisp, executive, zero fluff. "Here is the signal. Here is what to check. Here is the decision needed."
# GUARDRAILS:
- NO Python code output. You are the reasoning engine.
- NO hallucination of my business context. If unknown, state "Context Missing: [Specific Question for Founder]".
- If NO anomalies found (Z < 3), state "Nominal. No statistical outliers in recent window." and show the highest Z-scores anyway for context.
The Shortcut: From "Interesting Tech" to "Operational Asset" in 1 Hour
The astronomers had PhDs and months of iteration. You have The AI Business Shortcut 2.0.
You just saw the Anatomy of a Skill. That SKILL.md block above? It is 1 of 10 Ready-to-Install SKILL.md Files included in the $37 Edition 2.0 pack. They cover:
- Competitive_Intel_Synthesis (Automated competitor pricing/positioning scans)
- Client_Health_Scoring (Churn prediction from ticket/usage logs)
- SEO_Content_Gap_Analysis (Programmatic content planning)
- Financial_Variance_Explainer (Flux analysis for P&L)
- ...and 5 more high-leverage operational playbooks.
Plus you get:
- 50 Master Prompts (The "Companion Prompts" for every department: Sales, Marketing, Ops, Finance, Product).
- 5 Departmental Agent Blueprints (Full AGENTS.md configurations for a CMO Agent, CFO Agent, CTO Agent, COO Agent, CEO Agent - pre-wired with MCP tool definitions).
- The AGENTS.md Company OS Template (The "Company Brain" structure to onboard your human team and digital agents simultaneously).
Stop prompting. Start architecting. The Astra/Codex paradigm proves the future belongs to those who codify their workflows into Skills, connect them via MCP, and govern them via AGENTS.md.
Get The AI Business Shortcut 2.0 for $37 → [Insert Your Affiliate/Checkout Link Here]
Next Edition: We reverse-engineer the new "Computer Use" agent loop for browser-based workflow automation (RPA replacement).
Take The Ultimate Shortcut: Install The Full Agentic Business OS (Edition 2.0) for Just $37
Reading about new AI agent releases is helpful — deploying standardized, repeatable Agent Skills (SKILL.md) and departmental workflows across your company is what multiplies output without adding headcount.
Inside The AI Business Shortcut 2.0, you get the complete plug-and-play system built for ChatGPT, Claude, and Gemini:
- 50 Battle-Tested Master Prompts: Fill-in-the-blank templates across all 10 core business departments.
- 10 Plug-and-Play Agent Skills (SKILL.md .zip Pack): Standardized SOP folders ready to install in Claude, ChatGPT Projects/Custom GPTs, and Gemini Gems.
- 5 Departmental AI Agent Blueprints + AGENTS.md Company Brain: Govern Sales, Content, Onboarding/Support, Finance/Ops, and Executive reporting with Human-in-the-Loop guardrails and a 20-minute weekly audit protocol.
- 30-Minute Agentic Quick-Start Checklist: Zero coding required — 30-day 100% money-back guarantee.
👉 Click Here to Get The AI Business Shortcut 2.0 for Just $37 Today