惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
小众软件
小众软件
The Last Watchdog
The Last Watchdog
Latest news
Latest news
P
Palo Alto Networks Blog
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
P
Privacy International News Feed
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
T
Threatpost
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
Spread Privacy
Spread Privacy
T
Tor Project blog
Cyberwarzone
Cyberwarzone
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
CERT Recently Published Vulnerability Notes
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
博客园 - 司徒正美
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
A
Arctic Wolf
腾讯CDC
WordPress大学
WordPress大学
IT之家
IT之家
Last Week in AI
Last Week in AI
博客园 - 聂微东
P
Proofpoint News Feed
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Help Net Security
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
美团技术团队
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How to Build an agent using coral
Tejaswa Hinduja · 2026-06-01 · via DEV Community

How I Built an AI Agent That Queries GitHub, Calendar, and Sleep Data With One SQL Interface

A practical guide to Coral — the local-first SQL runtime that gives your agents a single query layer over any API


I spent the better part of a week building an agent that could answer questions like "why am I not productive lately?" The idea was simple: pull data from GitHub, Google Calendar, and sleep tracking, cross-reference everything, and get an AI answer.

The hard part turned out to be the data plumbing. Every source has its own auth, its own pagination, its own quirks. By the time I had GitHub and Calendar talking to the same script, I had written more glue code than actual agent logic.

Then I found Coral.

This post walks through what Coral is, why it matters for agent development, and how to build a working AI agent with it from scratch.


The problem with how agents access data today

Most agent workflows look like this:

Agent → Tool A → API A
Agent → Tool B → API B
Agent → Tool C → API C

Each tool call is isolated. The agent has to reason about three separate schemas, handle three different auth flows, and then try to mentally join the results. This creates:

  • Too many LLM round-trips — each tool call is its own context window exchange
  • Repeated glue code — pagination, retry logic, rate limiting, per source
  • Poor cross-source reasoning — the LLM sees results one at a time, not as a unified dataset
  • High token costs — raw API responses are verbose JSON, not trimmed result sets

The benchmark from the Coral team actually quantified this: across 82 real-world tasks, Claude was 20% more accurate and 2x more cost efficient using Coral versus direct provider MCPs. For complex multi-hop queries (the kind coding agents actually do), accuracy jumped 31% and cost dropped 3.4x.

The reason is architectural. Coral gives agents one SQL interface over everything.


What is Coral?

Coral is a local-first SQL runtime that sits between your agent and your data sources. You write SQL, Coral translates it into API calls (handling auth, pagination, and retries), and returns clean tabular rows.

Your Agent → SQL → Coral → GitHub API
                         → Google Calendar API  
                         → Local JSONL files
                   ↓
              One result set

The key properties:

Local-first. Everything runs on your machine. Credentials are stored locally and never leave. Coral is a read layer — it makes API calls on your behalf but doesn't send your data anywhere.

Sources as SQL schemas. When you connect GitHub, it appears as a github schema. You query github.commits, github.issues, github.pulls just like database tables. Same pattern for every source.

Joins across sources. Because every source looks like a SQL table, you can JOIN across them. Coral executes the join locally after fetching each side. That single query replaces three separate tool calls and the LLM reasoning needed to combine them.

MCP server built-in. Coral ships with an MCP server so you can wire it directly into Claude Code, Cursor, or any MCP-compatible agent with one command.


Installing Coral

macOS:

brew install withcoral/tap/coral

Linux:

curl -fsSL https://withcoral.com/install.sh | sh

Windows (10/11 x86_64):
Download coral-x86_64-pc-windows-msvc.zip from the latest GitHub release, extract it, and add coral.exe to your PATH.

Verify the install:

coral --version


Connecting your first source

Coral ships with bundled sources for GitHub, Google Calendar, Linear, Sentry, Datadog, Stripe, Slack, and more. See everything available:

coral source discover

Let's connect GitHub. You'll need a Personal Access Token with repo and read:user scopes:

coral source add --interactive github
# Coral will prompt: Enter your GitHub PAT

Once connected, verify it works:

coral sql "SELECT schema_name, table_name FROM coral.tables WHERE schema_name = 'github'"

You should see rows for github.commits, github.issues, github.pulls, github.user, and others.

Try a real query:

coral sql "
  SELECT CAST(commit__author__date AS DATE) AS date, COUNT(*) AS commits
  FROM github.commits
  WHERE owner = 'your-username'
    AND commit__author__date >= NOW() - INTERVAL '7 days'
  GROUP BY 1
  ORDER BY 1 DESC
"

Coral flattens nested JSON with __ as the separator. So commit.author.date in the GitHub API response becomes commit__author__date in your SQL. Run SELECT column_name FROM coral.columns WHERE schema_name = 'github' AND table_name = 'commits' to inspect the exact column names for any table.


Building the agent

We'll build a Node.js agent that answers natural language questions about your GitHub activity. Ask it "what have I been shipping this week?" and it queries your real commit data and returns an AI-generated summary.

Project setup

mkdir my-coral-agent && cd my-coral-agent
npm init -y
npm install @google/genai dotenv

Create a .env file:

GEMINI_API_KEY=your_key_here
GITHUB_USERNAME=your_github_username

The agent — agent.ts

The full agent is around 80 lines. Here's how it works:

Step 1: Query Coral for real data

import { execFileSync } from 'child_process'

function coralQuery<T>(sql: string): T[] {
  const stdout = execFileSync('coral', ['sql', '--format', 'json', sql.trim()], {
    encoding: 'utf-8',
    timeout: 30_000,
    stdio: ['pipe', 'pipe', 'ignore'],  // suppress Coral's stderr
  })
  return JSON.parse(stdout) as T[]
}

We call Coral's CLI and ask for JSON output. execFileSync blocks until Coral finishes — Coral handles all the GitHub API calls, pagination, and auth internally.

Step 2: Gather the data

function getGithubActivity(username: string, days: number) {
  // Commits per day
  const commits = coralQuery<{ date: string; repos: string; count: number }>(`
    SELECT
      CAST(commit__author__date AS DATE)   AS date,
      ARRAY_AGG(DISTINCT repo)             AS repos,
      COUNT(*)                             AS count
    FROM github.commits
    WHERE owner = '${username}'
      AND commit__author__date >= NOW() - INTERVAL '${days} days'
    GROUP BY 1
    ORDER BY 1 DESC
  `)

  // Open PRs
  const prs = coralQuery<{ title: string; state: string; created_at: string }>(`
    SELECT title, state, created_at
    FROM github.pulls
    WHERE owner = '${username}'
      AND created_at >= NOW() - INTERVAL '${days} days'
    ORDER BY created_at DESC
    LIMIT 20
  `)

  return { commits, prs }
}

Step 3: Ask Gemini

import { GoogleGenAI } from '@google/genai'

async function ask(question: string, data: object): Promise<string> {
  const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY! })

  const response = await ai.models.generateContent({
    model: 'gemini-2.5-flash',
    config: {
      systemInstruction: `You are a developer productivity assistant. 
        You have access to real GitHub data. Be direct and specific. 
        Reference actual repos and dates from the data.`,
    },
    contents: `
      Developer question: "${question}"

      GitHub data (last 7 days):
      ${JSON.stringify(data, null, 2)}

      Answer the question using this data.
    `,
  })

  return response.text ?? ''
}

Step 4: Wire it together

import dotenv from 'dotenv'
dotenv.config()

async function main() {
  const question = process.argv.slice(2).join(' ')
  if (!question) {
    console.log('Usage: npx tsx agent.ts "what have I been working on?"')
    process.exit(1)
  }

  const username = process.env.GITHUB_USERNAME!
  console.log('Querying GitHub via Coral...')

  let data: object
  try {
    data = getGithubActivity(username, 7)
  } catch (err) {
    console.error('Coral query failed:', err)
    process.exit(1)
  }

  console.log('Analyzing...\n')
  const answer = await ask(question, data)
  console.log(answer)
}

main()

Run it

npx tsx agent.ts "what have I been shipping this week?"
npx tsx agent.ts "which repo am I spending the most time on?"
npx tsx agent.ts "have I been less active than usual?"

The agent queries your live GitHub data, hands it to Gemini, and returns a natural language answer grounded in actual commit history.


Going further: cross-source queries

The real power of Coral is joins across sources. Add a second source:

coral source add --interactive google_calendar

Now you can ask questions that span both:

-- Commits on days with heavy meeting load
SELECT
  CAST(c.commit__author__date AS DATE) AS date,
  COUNT(DISTINCT c.sha)                AS commits,
  COUNT(DISTINCT e.id)                 AS meetings
FROM github.commits c
LEFT JOIN google_calendar.events e
  ON CAST(c.commit__author__date AS DATE) = CAST(e.start_date_time AS DATE)
WHERE c.owner = 'your-username'
  AND c.commit__author__date >= NOW() - INTERVAL '30 days'
GROUP BY 1
ORDER BY 1 DESC

This is a query that would normally require two separate API calls, result storage, and manual joining in your agent code. With Coral, it's one SQL statement.


Using Coral over MCP

If you're using Claude Code, Cursor, or any MCP-compatible agent, you can expose Coral as an MCP server — no custom code required:

# Claude Code
claude mcp add --scope user coral -- coral mcp-stdio

After this, your agent can query all connected sources directly using natural language. Ask it to "show me open GitHub issues assigned to me" and it will write the SQL and run it through Coral automatically.

You can also install Coral's skills to teach your agent the discovery-first workflow:

npx skills add withcoral/skills

This gives your agent knowledge of coral.tables, coral.columns, and the metadata tables it needs to explore schemas before writing queries.


What I actually built

The agent I described at the start — the one that cross-references GitHub, Calendar, and sleep data to answer "why am I not productive?" — uses exactly this pattern.

The behavioral metrics engine computes:

  • Sleep decline vs baseline
  • Late-night coding session frequency
  • Meeting load increase as a percentage over your own baseline
  • Context switching (repos per day, live from GitHub commits)
  • Interruption count trends

All of it feeds into Gemini as a structured prompt. The result looks like this in the terminal:

  BURNOUT RISK  ─────────────────────────────────

  ▘▀▀▀▀▀▀▀▀▀▀▀▝
  ▌  75/100    ▐
  ▌    HIGH    ▐
  ▗▄▄▄███████▄▖

  ────────────────────────────────────────────────

  TL;DR
  ────────────────────────────────────────
  Sleep dropped 38% while meetings tripled — you're
  compensating with late-night coding and it's not working.

  KEY FINDINGS
  ────────────────────────────────────────
  ◆ Average sleep fell from 8.1h to 5.0h over 30 days
  ◆ Meetings increased from 1.5/day to 5.2/day (+180%)
  ◆ 6 late-night coding sessions in the last 7 days vs 0 in baseline
  ◆ Context switching across 4 repos/day vs 1 repo/day baseline
  ◆ Productivity score: 36/100 (down from 79 baseline)

The full source is on GitHub. The key file is src/coral/sources/github.ts which shows exactly how to wrap Coral queries in a TypeScript function and handle the column naming conventions.


Summary

Coral is one of those tools that removes a whole category of boilerplate. Instead of writing per-source auth, pagination, and retry logic, you write SQL. Instead of your agent reasoning about three separate tool outputs, it reasons about one result set.

The setup is:

# 1. Install
brew install withcoral/tap/coral   # or curl on Linux, zip on Windows

# 2. Connect a source  
coral source add --interactive github

# 3. Query
coral sql "SELECT repo, COUNT(*) FROM github.commits WHERE owner = 'you' GROUP BY 1"

# 4. Use in your agent
execFileSync('coral', ['sql', '--format', 'json', query])

That's really it. The complexity sits inside Coral, and your agent code stays clean.


If you build something with Coral, I'd like to see it. The xetroc source is at github.com/TejaswaHinduja/xetroc if you want a reference implementation to work from.