用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill constraints-reviewer命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Create distinctive, production-grade frontend interfaces with high design quality. Use when building web components, pages, or applications. Includes framework-specific guidance for Tailwind, React, Vue, and Rails/Hotwire ecosystems.
Skill file structure, naming conventions, directory layout, frontmatter requirements, and invocation control. Use when creating skill files or slash commands to ensure correct format and validation.
Forces adversarial reasoning before committing to decisions. Triggers on architectural choices, approach selection, and planning phases to prevent premature commitment bias.
基于 SOC 职业分类
正在显示 SKILL.md
| name | constraints-reviewer |
| description | Review data constraints and referential integrity in Rails models and migrations. |
| allowed-tools | Read Grep Glob Bash |
Review database constraints, foreign keys, and data integrity rules.
# PROBLEM: Model-only validation (race condition vulnerable)
validates :email, uniqueness: true
# SOLUTION: Database constraint + model validation
add_index :users, :email, unique: true
validates :email, uniqueness: true
# PROBLEM: Check-then-insert race condition
def claim_slot
return false if Slot.where(user_id: user.id).exists?
Slot.create!(user_id: user.id)
end
# SOLUTION: Database constraint with rescue
.create!( user.id)
| Validation | Required DB Constraint |
|---|---|
presence: true | NOT NULL |
uniqueness: true | Unique index |
belongs_to | Foreign key |
enum | Check constraint |
numericality: { in: } | Check constraint |
# PROBLEM: Orphaned records on deletion
has_many :comments
# SOLUTION: Dependent handling
has_many :comments, dependent: :destroy # For callbacks
# OR database-level:
add_foreign_key :comments, :posts, on_delete: :cascade
# PROBLEM: No referential integrity for polymorphics
belongs_to :commentable, polymorphic: true
# SOLUTION: Validate type + consider alternatives
ALLOWED_TYPES = %w[Post Article].freeze
validates :commentable_type, inclusion: { in: ALLOWED_TYPES }
# Better: separate tables instead of polymorphic
belongs_to :post, optional: true
belongs_to :article, optional: true
validates :post_id, presence: true, unless: :article_id?
# Find orphaned comments (missing parent)
Comment.left_joins(:post).where(posts: { id: nil })
# Find missing foreign keys
ActiveRecord::Base.connection.tables.each do |table|
columns = ActiveRecord::Base.connection.columns(table)
columns.select { |c| c.name.end_with?('_id') }.each do |col|
# Check if FK exists
end
end
uniqueness validations have unique indexes?presence validations have NOT NULL constraints?_id columns have foreign keys?## Constraints Review: [PASS/WARN/FAIL]
### Missing Database Constraints
- [model]: [validation without DB enforcement]
### Foreign Key Issues
- [table]: [missing FK on _id column]
### Race Condition Risks
- [code location]: [check-then-insert pattern]
### Orphan Risks
- [association]: [could create orphans]
### Recommendations
1. [Prioritized fixes]