migration-patterns
Skill419 starsChanged 4 months agoMITView on GitHub
Database migration creation with mandatory RLS policies and ARCHitect approval workflow. Use when creating migrations, adding tables with RLS, updating ORM schema, adding GRANT statements, or planning data migrations. Do NOT use for application code changes without schema impact.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- rshankras/claude-code-apple-skillstheir own version, first seen Jul 16, 2026
- adyba/pi-safe-workflowword for word, first seen Jul 10, 2026
- atuljha23/holocrontheir own version, first seen Apr 22, 2026
- VersoXBT/claude-initial-setuptheir own version, first seen Mar 9, 2026
Other versions4 projects use a version of this.
Word for word · 1
- adyba/pi-safe-workflow★ 0100% same
Edited · 0
None found.
Wrote their own version · 3
- rshankras/claude-code-apple-skills★ 777same name
- VersoXBT/claude-initial-setup★ 4same name
- atuljha23/holocron★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/00-core-principles.mdcCursor rule
- .cursor/rules/01-git-workflow.mdcCursor rule
- .cursor/rules/02-pattern-discovery.mdcCursor rule
- .cursor/rules/03-safe-ai-dlc.mdcCursor rule
- .cursor/rules/04-knowledge-vault.mdcCursor rule
- .cursor/rules/10-backend-python.mdcCursor rule
- .cursor/rules/11-frontend-react.mdcCursor rule
- .cursor/rules/12-database-sql.mdcCursor rule
- .cursor/rules/13-testing.mdcCursor rule
- .cursor/rules/14-spec-creation.mdcCursor rule
- .cursor/rules/15-deployment.mdcCursor rule
- .cursor/rules/16-stripe-payments.mdcCursor rule
- .cursor/rules/20-agent-architect.mdcCursor rule
- .cursor/rules/21-agent-backend.mdcCursor rule
- .cursor/rules/22-agent-qas.mdcCursor rule
- .cursor/rules/23-agent-security.mdcCursor rule
- .cursor/rules/30-background-agents.mdcCursor rule
- .cursor/rules/31-mcp-integration.mdcCursor rule
- .cursor/rules/README.mdCursor rule
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- frontend-patternsSkill
- git-advancedSkill
- linear-sopSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
- agent-coordinationSkill
- api-patternsSkill
- confluence-docsSkill
- deployment-sopSkill
- frontend-patternsSkill
- git-advancedSkill
- linear-sopSkill
- migration-patternsSkill
- orchestration-patternsSkill
- pattern-discoverySkill
- release-patternsSkill
- rls-patternsSkill
- safe-ai-dlcSkill
- safe-workflowSkill
- security-auditSkill
- spec-creationSkill
- stripe-patternsSkill
- team-coordinationSkill
- testing-patternsSkill
- vault-syncSkill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 81
Before ANY schema change:
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Migration Patterns Skill
TEMPLATE: This skill uses
{{PLACEHOLDER}}tokens. Replace with your project values before use.
Purpose
Guide database migration creation with mandatory RLS policies, following security-first architecture and approval workflow.
When This Skill Applies
- Creating database migrations
- Adding new tables (all tables need RLS)
- Updating ORM schema
- Adding GRANT statements
- Schema impact analysis
- Data migration planning
Stop-the-Line Conditions
FORBIDDEN Patterns
-- FORBIDDEN: RLS policies in separate file
-- RLS MUST be in the same migration file as the table creation
-- FORBIDDEN: Table without RLS
CREATE TABLE user_data (...);
-- Missing: ALTER TABLE user_data ENABLE ROW LEVEL SECURITY;
-- FORBIDDEN: Resolve applied migrations (bypasses verification)
-- npx prisma migrate resolve --applied "migration_name"
-- alembic stamp head
-- FORBIDDEN: Missing user_id index
CREATE TABLE payments (...);
-- Missing: CREATE INDEX idx_payments_user_id ON payments(user_id);
-- FORBIDDEN: Schema changes without ARCHitect approval
-- All migrations require approval before PRCORRECT Patterns
-- CORRECT: Complete migration with RLS in same file
CREATE TABLE user_data (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id TEXT NOT NULL,
data JSONB,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Enable RLS (SAME FILE - MANDATORY)
ALTER TABLE user_data ENABLE ROW LEVEL SECURITY;
-- User policy
CREATE POLICY user_data_user_select ON user_data
FOR SELECT TO {{PROJECT}}_app_user
USING (user_id = current_setting('app.current_user_id', true));
-- Index for RLS performance (MANDATORY)
CREATE INDEX idx_user_data_user_id ON user_data(user_id);
-- Grant permissions
GRANT SELECT, INSERT, UPDATE ON user_data TO {{PROJECT}}_app_user;Migration Workflow (MANDATORY)
Step 1: Get ARCHitect Approval
Before ANY schema change:
1. Document proposed changes
2. Get ARCHitect approval (create issue or discussion)
3. Only proceed after explicit approvalStep 2: Create Migration
# For Prisma
npx prisma migrate dev --name descriptive_name
# For Alembic
alembic revision --autogenerate -m "descriptive_name"
# Verify migration file created
ls {{MIGRATIONS_DIR}}/Step 3: Add RLS to Migration
Edit the generated migration to include:
ALTER TABLE ... ENABLE ROW LEVEL SECURITY- User SELECT policy
- User INSERT policy (if applicable)
- User UPDATE policy (if applicable)
- Admin policies (if needed)
- System policies (for background jobs)
- Index on user_id column
- GRANT statements
Step 4: Verify Locally
# Test migration
{{MIGRATION_RUN_COMMAND}}
# Verify RLS is enabled
psql -c "SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = 'public';"Step 5: Update Documentation
After successful migration:
- Update
docs/database/DATA_DICTIONARY.md(MANDATORY) - Update RLS policy catalog if new policies added
- Document in ticket
RLS Policy Templates
User Read Policy
CREATE POLICY {table}_user_select ON {table}
FOR SELECT TO {{PROJECT}}_app_user
USING (user_id = current_setting('app.current_user_id', true));User Write Policy
CREATE POLICY {table}_user_insert ON {table}
FOR INSERT TO {{PROJECT}}_app_user
WITH CHECK (user_id = current_setting('app.current_user_id', true));Admin Policy
CREATE POLICY {table}_admin_all ON {table}
FOR ALL TO {{PROJECT}}_app_user
USING (current_setting('app.user_role', true) = 'admin');System Policy (Background Jobs)
CREATE POLICY {table}_system_all ON {table}
FOR ALL TO {{PROJECT}}_app_user
USING (current_setting('app.context_type', true) = 'system');Migration Checklist
Before PR:
- ARCHitect approval obtained
- RLS policies in same migration file
- User policies created
- user_id index created
- GRANT statements added
- Local migration test passed
- DATA_DICTIONARY.md updated
- Evidence attached to ticket
Production Migration Requirements
For production migrations:
- POPM/lead must be present (MANDATORY)
- Backup taken before migration
- Rollback plan documented
- Post-migration validation steps defined
- Data integrity checks planned
Authoritative References
- Migration SOP:
docs/database/RLS_DATABASE_MIGRATION_SOP.md(MANDATORY) - Data Dictionary:
docs/database/DATA_DICTIONARY.md(update after changes) - RLS Implementation:
docs/database/RLS_IMPLEMENTATION_GUIDE.md - RLS Policies:
docs/database/RLS_POLICY_CATALOG.md - Security First:
docs/guides/SECURITY_FIRST_ARCHITECTURE.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

