Files
MyAiConfiguration/shared/skills/implementation/sql-write/SKILL.md
T
Julian Lechner f5d8f6f11b
CI / CI configuration security checks (push) Successful in 3s
CI / Capabilities and shell quality (push) Successful in 14s
CI / Python tests and compilation (push) Successful in 26s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 14s
CI / PowerShell tests on Ubuntu (push) Successful in 1m4s
CI / Installed client configuration smoke tests (push) Successful in 33s
CI / Bash integration and installation guards (push) Successful in 1m1s
feat(skills): reworked skills and rules
2026-11-18 14:17:49 +01:00

23 lines
2.9 KiB
Markdown

---
name: sql-write
description: Use when writing or modifying SQL queries, schema, database migrations, or data updates; account for dialect, compatibility, authorization, and data safety.
---
# SQL Write
Use when writing or changing SQL statements, schema definitions, or database migrations.
## Workflow
1. Identify the database engine and version, target schema, affected callers, and expected data shape. Inspect existing migrations and SQL style first. Before relying on engine-specific syntax, transaction, locking, or migration behavior, MUST apply the implementation checkpoint in `technical-research`.
2. Parameterize values and validate any dynamic identifiers against an allowlist. Preserve tenant boundaries and authorization filters in every query path. Apply `rules-security-data` for persistence and personal data.
3. Use least privilege: application identities get only the rights their queries need; migrations run under a separate identity that holds schema rights. Do not grant schema or admin rights to the application identity.
4. For schema changes, consider existing rows, nullability, defaults, constraints, indexes, and deployment order. Prefer additive, backward-compatible steps when old and new application versions may overlap. Make migration scripts safe to re-run after a partial failure: guard steps with existence checks, or generate idempotent scripts (for EF Core, `dotnet ef migrations script --idempotent` where the provider supports it).
5. For new or changed queries on large or hot tables, inspect the execution plan against representative data, and justify any new index by that plan and its write cost.
6. Use transactions and explicit rollback or recovery steps where supported and appropriate. Estimate affected rows before broad updates or deletes. For large updates or deletes, plan the locks taken, batch the work in bounded transactions, and make the batches resumable.
7. For personal data deletion (for example a GDPR erasure request), cover every copy: related tables, audit and history tables, caches, search indexes, exports, replicas, and backups. State copies that cannot be deleted now, such as backups, and when they expire.
8. Do not execute writes, destructive SQL, or production SQL without explicit authorization. Explicit authorization means the user names the target environment and the statement or its intent, after seeing the statement and the expected affected row count. For destructive changes, a backup or rollback path must also be stated. A request to write SQL, or to "run it now" without these, does not authorize running it against live data.
9. Verify syntax and behavior against the intended engine, then inspect query results, migration ordering, and relevant application tests. MUST apply the verification checkpoint in `technical-research` to external claims; documentation cannot replace execution evidence.
Report the database dialect, files or migration changed, verification, and any operational prerequisite.