首页
/ Database Migration Assistant

Database Migration Assistant

2026-03-13 04:45:02作者:冯爽妲Honey

Description

This skill provides guidance on database schema migration best practices, including version control, rollback strategies, and data consistency保障.

Trigger Phrases

  • "create database migration"
  • "database schema change"
  • "migrate database version"

3. **添加示例代码**到examples目录:
```javascript
// examples/migration-script.js
/**
 * 数据库迁移示例脚本
 * 功能:添加用户状态字段并设置默认值
 */
async function up(db) {
  await db.query(`ALTER TABLE users ADD COLUMN status VARCHAR(20) DEFAULT 'active'`);
}

async function down(db) {
  await db.query(`ALTER TABLE users DROP COLUMN status`);
}

module.exports = { up, down };
  1. 添加验证脚本到scripts目录,确保技能功能正常:

    #!/bin/bash
    # scripts/validate-skill.sh
    echo "Validating database migration skill..."
    # 验证SKILL.md格式
    npx claude-code validate-skill ./SKILL.md
    # 测试示例脚本语法
    node examples/migration-script.js
    
  2. 注册技能到系统

    npx claude-code register-skill ./db-migration-assistant
    

3.3 技能系统在团队协作中的应用

技能系统为团队协作提供了多种赋能方式:

3.3.1 建立团队技能库

创建团队共享技能库,集中管理项目特定技能:

# 创建团队技能库
mkdir -p team-skills
# 设置技能库路径
npx claude-code config set skillPaths ./team-skills
# 从Git仓库导入团队技能
npx claude-code import-skill git@gitcode.com:your-team/team-skills.git

3.3.2 实现技能版本控制

通过版本控制管理技能迭代,确保团队使用统一版本:

# 在SKILL.md头部声明版本信息
---
id: db-migration-assistant
version: 1.2.0
author: dev-team@example.com
compatibility: 2.0.0+
---

3.3.3 技能使用分析与优化

通过技能使用统计了解团队技能应用情况:

# 生成技能使用报告
npx claude-code stats skills --period 30d

报告将显示各技能的使用频率、效果评分和改进建议,帮助团队优化技能库。

3.4 跨场景技能迁移指南

将技能从一个项目迁移到另一个项目的最佳实践:

  1. 技能打包

    npx claude-code package-skill db-migration-assistant --output migration-skill-v1.2.tar.gz
    
  2. 依赖检查

    npx claude-code check-dependencies migration-skill-v1.2.tar.gz --target-project ./new-project
    
  3. 适应性调整

    # 生成迁移适配报告
    npx claude-code adapt-skill migration-skill-v1.2.tar.gz --target-project ./new-project
    
  4. 导入与验证

    npx claude-code import-skill migration-skill-v1.2.tar.gz --project ./new-project
    cd new-project
    npx claude-code test-skill db-migration-assistant
登录后查看全文
热门项目推荐
相关项目推荐