Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
snowflake-deploy-medic【部署与运维】Review and safely diagnose Snowflake infrastructure and database deployments across the snowflakedb/snowflake Terraform 2.x provider, grants/state/imports, schemachange versioned and repeatable migrations, Snowflake CLI/drivers, and behavior-change releases. Use before a production deploy, when a plan wants to replace or revoke grants, state is unrea…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Snowflake deployment failures hide in the seams: a grant resource is declared as new although the remote grant already exists; provider state is truncated; a versioned migration was edited after application; a repeatable checksum change reruns unexpectedly; or a current CLI/driver behavior change is mistaken for a database defect. This skill creates one evidence-backed gate across those seams.
The deterministic classifier is
scripts/analyze_deploy_evidence.py. It
accepts a bounded schema-v2 projection plus its digest from an independent CI or
artifact channel. It emits privacy-safe findings, a point-in-time zero-change
status, ordered read-only checks, and post-deploy invariants. Nested receipt
hashes detect internal inconsistency; they never substitute for trusted origin.
Read
references/terraform-provider-2x.md,
references/schemachange-integrity.md,
and references/zero-change-rollback.md
for the relevant surface. Always verify current primary docs and release notes;
the versions in a local receipt are observations, not timeless recommendations.
terraform apply, terraform destroy, state editing, schemachange deploy, mutating snow sql, or Snowflake DDL/DML automatically.terraform.tfstate or CHANGE_HISTORY to make a plan green.Collect a timestamped receipt from the exact account, role, backend, and CI commit. Hash account, role, backend, workspace, object, address, operator, and owner identities before they enter the packet. Obtain the canonical packet SHA-256 independently from the trusted CI/artifact channel. The packet must include:
terraform plan -detailed-exitcode output: exit code, change count,
resource actions, replacements/destroys, grant/ownership changes, and preview
features.CHANGE_HISTORY count/hash; repeated R/A executions make those counts differ.0 and changes are 0, tied to the
saved plan hash and verified affected-object count. Otherwise, a rollback or
forward-fix test against this exact plan/migration set, including
owner, preconditions, validation, and stop condition.Missing evidence is an explicit finding. A successful command from a different role, account, or environment is not a deployment receipt.
Record the installed versions and lockfiles. Read the live provider registry, Snowflake CLI/client-driver release notes, and current behavior-change notes for the target account release window. Do not rely on a cached blog post or a generic “latest” label. Keep auth read-only and least-privileged; use key pair/OAuth/ workload identity/external-browser mechanisms without exposing secrets.
The pack's generic query collector may support diagnosis, but it is not positive
evidence for this gate. A raw query receipt, a self-asserted hash, or a receipt
with truncation_possible: true cannot prove a complete affected-object or
dependency inventory. Build the schema-v2 projection in trusted CI from sanitized
terraform show -json, backend metadata, lock-file selection, repository migration
inventory, CHANGE_HISTORY, official BCR status/items, and exact tool versions.
Validate that state parses and belongs to the intended backend/workspace. Preserve a backend version/lock receipt before refreshing. Run only the reviewed read-only plan with detailed exit status:
0 and changes=0: candidate zero-change receipt;2: valid preview with changes, requiring review;For a grant adoption, declare the intended address and use the current provider's documented import identity. Refresh and require a zero-change plan. Inspect grant scope, future grants, role/object ownership, managed access, privilege removals, and provider normalization. Never destroy a live dependency graph to avoid an import.
For provider 2.x preview resources/features, read the exact current support
boundary and release notes. A green plan does not make preview behavior stable.
See references/terraform-provider-2x.md.
Record every migration-guide segment between the locked source and target provider
versions. Each segment receipt must bind its source, versions, affected addresses,
immutable source snapshot, state-move boundary, disposition, and canonical SHA-256.
Segments must advance monotonically without gaps, cycles, or synthetic multi-minor
leaps. Empty means explicitly
verified not applicable, not “not checked.”
If dbt Project objects are in scope, inventory their deployed/staged code hashes,
current and target version model, supported runtime, behavior-change disposition,
and rollback artifact. The pending live-version behavior changes the rollback model;
see references/dbt-project-and-provider-migrations.md.
Separate migration types:
V...__...sql: versioned, tracked once; checksum drift blocks deployment until
the applied content is reconciled.R__...sql: repeatable; checksum changes intentionally cause a rerun, so prove
idempotence and scope before approval.A__...sql: always-run; review side effects and cost on every deploy.Compare repository content to the actual CHANGE_HISTORY row. Check duplicate
version names and branch ordering. Use current verify/dry-run behavior and
review upgrade notes for checksum normalization regressions before changing the
tool version. Never alter history by hand. See
references/schemachange-integrity.md.
python3 "${CLAUDE_SKILL_DIR}/scripts/analyze_deploy_evidence.py" \
--input ./snowflake-deploy-evidence.json \
--as-of '<current-utc-evaluation-timestamp>' \
--trusted-bundle-sha256 'sha256:<digest-from-trusted-ci-or-artifact-channel>'
The explicit --as-of value prevents wall-clock-dependent output. A clean
verdict is PASS_AS_OF, expires at that exact timestamp, and is never permission
to apply. Expected findings include:
TRUSTED_BUNDLE_DIGEST_MISSING_OR_MISMATCHED,
EVIDENCE_CONTEXT_INVALID_OR_STALE, PLAN_RECEIPT_UNVERIFIABLE,
PLAN_EXIT_ACTION_CONTRADICTION, TERRAFORM_STATE_UNREADABLE_OR_UNBOUND;GRANT_IMPORT_REQUIRED, DESTRUCTIVE_PLAN_CHANGE,
AFFECTED_OBJECT_DENOMINATOR_UNVERIFIED;VERSIONED_CHECKSUM_DRIFT, REPEATABLE_CHANGE_DETECTED,
ALWAYS_MIGRATION_UNREVIEWED, MIGRATION_DENOMINATOR_UNVERIFIED;PROVIDER_PREVIEW_FEATURE, PROVIDER_PREVIEW_DENOMINATOR_UNVERIFIED,
PROVIDER_MIGRATION_DENOMINATOR_UNVERIFIED, DEPLOY_TOOLCHAIN_UNVERIFIED;BCR_INVENTORY_UNVERIFIED, DBT_PROJECT_DENOMINATOR_UNVERIFIED,
PREFLIGHT_DENOMINATOR_UNVERIFIED, STATE_BACKUP_RECEIPT_UNVERIFIABLE;ROLLBACK_RECEIPT_UNVERIFIABLE, POST_CHANGE_INVARIANTS_UNVERIFIED,
ZERO_CHANGE_RECEIPT_UNVERIFIABLE.The script is pure and connector-neutral. It reports findings from supplied evidence; it does not call Terraform, schemachange, Snowflake CLI, or Snowflake.
Return a receipt containing scope/identity, current toolchain sources, zero-change or plan verdict, grant/import/state findings, migration checksum findings, BCR review, and rollback status. For each finding distinguish observed, derived, unknown, and hypothesis. Name the exact next read-only check and the approval boundary for any later mutation.
After a separately approved deployment, collect fresh evidence. The preflight classifier validates only the invariant plan; it does not claim to execute or verify post-deploy checks. Reconcile the saved state/plan, grant addresses, migration history, toolchain/BCR receipt, observed invariant results, and rollback/forward-fix validation in a separate operator-reviewed receipt.
BLOCKED or PASS_AS_OF; neither authorizes apply.issued status when the plan is truly zero-change.If the JSON receipt is malformed, the classifier exits with code 2; correct the receipt instead of reading a partial verdict. If state, plan, change history, toolchain, or BCR evidence is missing, emit an explicit unknown/blocking finding. If the account, backend, role, or repository commit cannot be established, stop at identity verification. If a user asks to auto-apply, destroy, deploy, mutate SQL, or edit state/history, return the reviewed read-only checks and approval boundary instead. A successful CLI command from another environment is not proof of this deployment.
When Terraform wants to create a grant that already exists, classify
GRANT_IMPORT_REQUIRED. Declare the intended address, use the current provider's
documented import identity, refresh, and require a zero-change plan. Do not hand-
edit terraform.tfstate or destroy the database to force adoption.
When a V... checksum differs from CHANGE_HISTORY, block the release and restore
the applied content or create a new migration. When an R__... checksum changes,
review the intentional rerun and idempotence separately. Never update the history
table by hand to silence either finding.
references/terraform-provider-2x.md —
provider support, state/plan, grant import, ownership, and preview review.references/schemachange-integrity.md —
versioned/repeatable/always scripts, checksums, history, and upgrade risk.references/toolchain-bcr.md — current CLI,
driver, authentication, and behavior-change review.references/zero-change-rollback.md —
detailed plan semantics and change-specific rollback boundaries.references/source-notes.md — primary research
routes; verify live pages at execution time.references/dbt-project-and-provider-migrations.md
— provider migration segments and dbt Project live-version preflight.