sql-guard

Review SQL queries for tenant_id scoping, parameterization, and safe timestamp usage.

6|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/anotherben/claude-harness --skill sql-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-guard
Source: https://github.com/anotherben/claude-harness/tree/main/skills/sql-guard
Command: npx skills add https://github.com/anotherben/claude-harness --skill sql-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps prevent tenant isolation breaches and unsafe SQL patterns by guiding developers to follow strict tenant_id scoping, parameterization, and safe timestamp usage before writing or editing queries or migrations.

Core Features & Use Cases

  • Enforces tenant_id scoping on tenant-scoped tables and promotes parameters-based queries.
  • Promotes safe migration practices and type-safe joins to avoid cross-table data leakage.
  • Use Case: Review and guard SQL changes in new features that touch banking records, customers, or transactional stores.

Quick Start

Run the SQL Guard prior to writing or editing queries to ensure tenant isolation, parameterization, and safe timestamp usage.

Frequently Asked Questions about sql-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent tenant isolation breaches in SQL queries?

Preventing tenant isolation breaches requires enforcing strict tenant_id scoping on all tenant-scoped tables in your SQL queries. This involves verifying that every insert, update, delete, and complex join includes proper tenant_id parameterization to avoid cross-table data leakage.

What are safe SQL patterns for database migrations?

Safe SQL patterns for database migrations include using parameterized queries and type-safe joins to prevent cross-table data leakage. Following safe migration practices ensures tenant_id scoping and proper timestamp handling remain intact during schema changes.

How do I review SQL code for tenant_id scoping and parameterization?

Reviewing SQL code for tenant_id scoping requires reading the schema reference and following strict guidelines to verify tenant_id inclusion, parameterization, and proper timestamp handling across all database interactions including inserts, updates, deletes, and complex joins.

Why does tenant data leak across tables in multi-tenant databases?

Tenant data leaks across tables when SQL queries lack proper tenant_id scoping and parameterization. Unsafe query construction in complex joins and missing tenant_id enforcement in inserts, updates, or deletes cause cross-table data leakage in multi-tenant systems.

Do I need parameterized queries to prevent cross-table data leakage?

Parameterized queries are required to prevent cross-table data leakage and ensure tenant isolation. They enforce safe query construction by binding parameters securely, which stops unsafe SQL patterns and protects tenant-scoped data from exposure.

What SQL patterns should I check before writing tenant-scoped queries?

Before writing tenant-scoped queries, you should check for tenant_id scoping on all tenant-scoped tables, parameterized query construction, type-safe joins, and proper timestamp handling. Verifying these patterns prevents tenant isolation breaches and unsafe data leakage.