数据库迁移文件审查
migration-guard
审查数据库迁移文件的命名规范和危险操作。对迁移文件自动激活。
- License 许可
- MIT
- 最近更新
- 2026-05-15
- Stars
- ★ 13
- Forks
- 1
01 前言 Front Matter
- name
- migration-guard
- paths
- [ "migrations/**", "*.sql", "db/migrate/**" ]
- title
- migration-guard
- description
- Review database migration files for naming conventions and dangerous operations. Auto-activates for migration files.
03 SKILL.md 正文
Migration review
Review the current migration file for naming conventions, rollback presence, and dangerous operations.
Step 1: Identify the file being reviewed
Use the current file context to determine which migration file is being worked on. If the user specified a file path, use that. If the context is ambiguous, ask the user which file to review before proceeding.
Step 2: Check the file name
Extract the file name (not the full path) and check it against two accepted naming formats:
Format A — Timestamp prefix:
Pattern: YYYYMMDDHHMMSS_description.sql
Example: 20260513143207_add_user_roles.sql
- Year: 4 digits
- Month: 2 digits (01–12)
- Day: 2 digits (01–31)
- Hour: 2 digits (00–23)
- Minute: 2 digits (00–59)
- Second: 2 digits (00–59)
- Underscore separator
- Description: lowercase letters, digits, underscores
- Extension:
.sql
Format B — Sequential prefix:
Pattern: NNNN_description.sql
Example: 0042_add_user_roles.sql
- Number: 1 or more digits, typically zero-padded to 4 digits
- Underscore separator
- Description: lowercase letters, digits, underscores
- Extension:
.sql
If the file name matches neither format, mark the naming check as FAIL and note the reason.
Step 3: Check for rollback
Read the file content and look for either:
- A clearly labeled rollback section (a comment like
-- rollback,-- down,-- revert, followed by SQL that undoes the migration) - A comment explicitly marking it as irreversible (e.g.,
-- This migration is irreversible,-- no rollback)
If neither is present, mark rollback as NO.
Step 4: Check for dangerous operations
Read the file and scan for these patterns (case-insensitive):
DROP TABLEwithoutIF EXISTSimmediately following — flag as WARNINGDROP TABLE IF EXISTS— acceptable, no warningDELETE FROMwithout aWHEREclause on the same or next line — flag as WARNINGUPDATEwithout aWHEREclause on the same or next line — flag as WARNINGTRUNCATEon any table — flag as WARNING (destructive, often irreversible in production)DROP COLUMN— flag as NOTICE (may break dependent code; not always dangerous but requires attention)
For each match, note the line number.
Step 5: Output the checklist
Present findings in this format:
Migration review: <filename>
Naming convention: PASS
- Format: timestamp-prefix / sequential-prefix
(or)
Naming convention: FAIL
- Reason: <specific reason>
Rollback: YES / NO / MARKED IRREVERSIBLE
- <brief note on what the rollback does, or why it is marked irreversible>
Dangerous operations: NONE
(or)
Dangerous operations:
WARNING line 14: DELETE without WHERE clause
WARNING line 22: TRUNCATE on orders table
NOTICE line 31: DROP COLUMN — confirm no dependent code references this column
Do not modify the migration file. This skill reviews only.
04 同仓库更多 Skills
版本号升级与 Git 标签
tag-version
升级软件包版本并创建带注释的 git 标签。接受语义化版本号(1.2.0)或升级类型(patch、minor、major)。不执行推送——请使用 publish 技能进行推送。作为发布工作流的一部分使用。
项目完整发布流程
release
运行完整的发布工作流:变更日志条目、版本升级、git 标签和 GitHub Release。依次调用 changelog-entry、tag-version 和 publish。在发布项目新版本时使用。
GitHub 版本发布
publish
将当前分支和所有标签推送到 origin,然后使用最新标签及其 CHANGELOG.md 条目创建 GitHub Release。在 tag-version 之后使用以完成发布。
变更日志条目生成
changelog-entry
按照 Keep a Changelog 格式为所有未发布的提交起草变更日志条目。将提交分组为新增(Added)、变更(Changed)、修复(Fixed)、移除(Removed)和安全(Security)。在发布新版本之前或更新 CHANGELOG.md 时使用。
代码自动格式化
auto-format-on-edit
每次编辑后使用 Prettier 和 ESLint 自动格式化代码文件。当 Claude 编辑文件时在后台激活。格式化是静默的——没有提示,除非格式化程序失败,否则没有输出。当您希望在编码会话期间自动执行一致的格式化时使用。
代码质量审计
code-quality-audit
运行全面的代码质量审计,涵盖安全性、性能和可维护性。用于季度审计、发布前审查或接入大型代码库时。