copilot-setting sql.instructions.md

SQL rules for raw JDBC, HQL, and database queries in Java, covering safe parameters, query performance, pagination, indexing, and resource handling.

In plain words
What is it for?
Use them when writing or reviewing DAO queries, PreparedStatements, HQL, LIKE searches, joins, subqueries, indexes, and EXPLAIN plans.
Why use it?
They reduce SQL injection risk and help avoid slow or unsafe queries, such as string-built SQL, SELECT *, offset pagination, and queries inside loops.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/zexion7873/copilot-setting/sql
Clone the repo
git clone --depth 1 https://github.com/zexion7873/copilot-setting

Made for: GitHub Copilot.

Per session 732 This file is loaded in full into every session.
When invoked 732 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00732 $0.00732
Opus 5 $0.00366 $0.00366
Sonnet 5 $0.00146 $0.00146
Haiku 4.5 $0.00073 $0.00073

Measured yesterday against content hash aeee0da4269a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

copilot-setting sql.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/sql.instructions.md · 43 lines

How it starts

The opening of the file, as written. The whole thing — 43 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SQL Conventions

Non-negotiable rules for all SQL — raw JDBC, HQL, native queries. Hibernate query patterns: instructions/spring-hibernate.instructions.md. DDL / migration rules: instructions/sql-ddl.instructions.md.

Security

  • JDBC: all user input via PreparedStatement with ? — zero tolerance for string concatenation
  • HQL / Criteria: use named parameters (:paramName) only — never concatenate into query strings
  • Escape %, _, and the escape char itself in any user input bound to LIKE, and declare it — ... LIKE ? ESCAPE '\\'; never silently strip user-supplied wildcards (that changes query semantics)
  • No SELECT * on tables with sensitive columns
  • Never log SQL containing credentials or PII

Performance

  • No SELECT * — list columns explicitly
  • No functions on indexed columns in WHERE — use range conditions
  • No OFFSET pagination on large tables — cursor: WHERE id > ? ORDER BY id LIMIT N
  • N+1 = SQL inside a loop — batch with IN or JOIN
  • IN vs EXISTS subqueries: MySQL 8.0 optimizes both with the same semijoin transforms (EXISTS since 8.0.16) — pick the clearer form and check EXPLAIN; beware NOT IN matching nothing when the subquery returns a NULL
  • Batch INSERT/UPDATE/DELETE — never row-by-row; chunk and commit per chunk to bound lock time, transaction size, and redo/binlog volume (low thousands of rows is a typical starting point, not a fixed limit — tune to row width, index count, and lock/replication pressure)

JDBC Resources

  • try-with-resources for Connection, PreparedStatement, ResultSet
  • WHERE clause mandatory on every UPDATE and DELETE
  • Transactions (raw JDBC only — Spring-managed <tx:advice> handles this automatically): commit or rollback on every code path

Anti-Patterns

Pattern Problem Fix
"WHERE name = '" + name + "'" SQL injection PreparedStatement with ? + setString()
SELECT * FROM orders Unnecessary columns; schema-fragile List columns explicitly
WHERE YEAR(created_at) = 2024 Function kills index Range: >= '2024-01-01' AND < '2025-01-01'
LIMIT 10 OFFSET 10000 Scans 10K rows to discard Cursor: WHERE id > ? ORDER BY id LIMIT 10
SQL inside a for loop N+1 queries WHERE id IN (?, ...) or JOIN
Connection without try-with-resources Leak on exception; pool exhaustion try (Connection c = ...) { }

Read the full file on GitHub · 43 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 43 lines · 732 tokens per session scan A aeee0da4269a

Subscribe to this mod's changes

copilot-setting sql.instructions.md is an instructions file published in the GitHub repository zexion7873/copilot-setting (1 stars, last pushed 28d ago), licensed MIT. It adds 732 tokens to every session, about $0.0037 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.