dry-run-gate-pattern
Dry-Run Gate Pattern
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 18
- Forks
- 6
01 前言 Front Matter
- name
- dry-run-gate-pattern
- metadata
- { "original-index": 2, "short-description": "Dry-Run Gate Pattern" }
- description
- Dry-Run Gate Pattern
02 资源文件 1
- 参考文档skill.json139 B
03 SKILL.md 正文
Dry-Run Gate Pattern
What
A boolean flag that defaults to true, preventing any modifications unless the
caller explicitly opts in. The script runs all analysis and reporting but aborts
before making changes.
Why
Prevents accidental execution. Every script is read-only by default. The DBA
must consciously pass --execute 1 to apply changes. This is critical when the
same script targets DEV, QA, and PROD.
How
DO $$
DECLARE
dry_run boolean := COALESCE(
NULLIF(current_setting('da.execute', true), ''),
'0'
) <> '1';
BEGIN
-- ... gap analysis, reporting ...
IF dry_run THEN
RAISE NOTICE 'DRY-RUN COMPLETE -- no changes applied';
RAISE NOTICE 'To execute, run with --execute 1';
RAISE EXCEPTION 'DRY-RUN complete -- no changes applied.';
END IF;
END $$;
The runner (scripts/run_sql_file.js) sets da.execute via:
SET da.execute = '1';
The COALESCE(NULLIF(...), '0') expression handles three edge cases:
- Setting not set at all (
current_settingreturns NULL withtrueflag) (PG 16 docs: functions-admin.html -- "returns NULL if missing_ok is true") - Setting set to empty string
- Setting set to '0'
All three default to dry-run mode.
When to Use
- Every DDL script that modifies schema or data
- Scripts that will be run by humans (not just automated pipelines)
Where We Used It
- DA-102: Phase 1 dry-run gate before column renames
- DA-126/DA-127: Before FK constraint creation
- DA-134/DA-139: Before index creation
Gotchas
RAISE EXCEPTIONaborts the current DO block AND prevents subsequent statements from running -- this is the desired behavior for dry-run- The
trueparameter incurrent_setting('da.execute', true)means "return NULL if setting doesn't exist" instead of throwing an error
Category: Safety | Origin: DA-102
04 同仓库更多 Skills
yeet
Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).
wrangler
Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
workspace-skill-discovery
Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude/skills/ or skills/ in any repo) are never missed.
workers-best-practices
Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
winui-app
Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.
windows-brain-script-portability
Scripts in ~/.claude/scripts/ that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.