💰 Cost Sentinel: Local FinOps for VS Code
🛑 The Problem
Data platform teams are bleeding cloud credits due to unoptimized or accidental queries run during development. A single unconstrained SELECT * on a multi-terabyte BigQuery or Snowflake table can cost hundreds of dollars in seconds. Relying on cloud-provider APIs for cost estimation introduces latency, requires complex IAM role management for every developer, and risks exposing proprietary schema data to third-party tools.
💡 The Solution
Cost Sentinel is a lightweight, local-first VS Code extension that parses SQL Abstract Syntax Trees (AST) in real-time to estimate query costs before execution. It shifts FinOps entirely to the left—right into the developer's IDE.
Core Capabilities:
- Real-Time Estimation: Parses SQL keystroke-by-keystroke to calculate costs instantly.
- Budget Guardrails: Visual Red Alerts in the status bar when a query exceeds a configurable threshold.
- 100% Air-Gapped: Zero telemetry, no database connections, and no external API calls.
🏗️ Architecture & Trade-offs
When designing this tool, I evaluated several architectural paths. The current implementation prioritizes developer velocity and security over absolute precision.
| Approach |
Pros |
Cons |
Decision |
| Cloud Provider EXPLAIN API |
100% accurate dollar amounts. |
High latency (network trip per keystroke); requires sharing AWS/GCP credentials in the IDE. |
❌ Rejected for MVP |
| Local RegEx Parsing |
Extremely fast. Zero dependencies. |
Fails on complex nested queries and sub-selects. |
❌ Rejected |
| Local AST Parsing (Chosen) |
Fast, completely offline, zero credential risk, accurate table identification. |
Estimates based on static table size mapping, not dynamic partitions. |
✅ Selected |
Why a VS Code Extension?
With ~70% market share among data engineers, VS Code offers the lowest friction for adoption. The logic is decoupled from the UI, preparing the architecture for a future Language Server Protocol (LSP) migration.
🗺️ Roadmap
- [x] Phase 1: Local AST parsing and VS Code Status Bar integration.
- [ ] Phase 2: Dynamic schema pulling (opt-in CLI tool to update the local pricing map from AWS Glue/Hive Metastore).
- [ ] Phase 3: Extract core parsing logic into a standalone Language Server Protocol (LSP) to support IntelliJ/DataGrip.
- [ ] Phase 4: Pre-commit hook integration to block expensive queries at the Git level.
⚙️ Configuration
Users can define their own table mappings and thresholds in their settings.json without touching the codebase:
{
"costSentinel.costPerTB": 5.0,
"costSentinel.alertThreshold": 50.0
}