database-integration

pluginagentmarketplace's avatarfrom pluginagentmarketplace

Database integration - schema design, queries, migrations, optimization

⭐1stars🔀0forks📁View on GitHub🕐Updated Dec 31, 2025

When & Why to Use This Skill

The Database Integration skill is a comprehensive toolkit designed to automate and optimize the entire database lifecycle. It empowers developers to design normalized schemas, write high-performance queries, and manage complex migrations across multiple database engines like PostgreSQL, MySQL, and MongoDB. By incorporating built-in validation for 3NF normalization and N+1 query detection, it ensures that your data layer is both scalable and efficient from the start.

Use Cases

  • Architecting Scalable Schemas: Automatically generate normalized database models and relationship mappings for modern ORMs like Prisma, Drizzle, or SQLAlchemy.
  • Performance Auditing & Optimization: Identify performance bottlenecks such as missing indexes or inefficient query patterns and receive actionable recommendations for optimization.
  • Automated Migration Workflows: Generate version-controlled migration scripts to safely evolve database structures as application requirements change.
  • Cross-Platform Query Generation: Write and refine complex SQL or NoSQL queries tailored for specific environments, including PostgreSQL, MySQL, Redis, and SQLite.
namedatabase-integration
descriptionThe specific database action to perform
sasmp_version"1.3.0"
bonded_agent04-database-design
bond_typePRIMARY_BOND
atomictrue
single_responsibilitydatabase_operations
typeobject
required[action]
enum[select, insert, update, delete, aggregate]
defaultpostgresql
success{ type: boolean }
schema{ type: object }
query{ type: string }
migration{ type: string }
performance_notes{ type: array, items: { type: string } }
max_attempts3
backoffexponential
initial_delay_ms1000
jittertrue
levelINFO
events[schema_designed, query_written, migration_created]
metrics[query_complexity, index_recommendations]

Database Integration Skill

Atomic skill for database operations including schema design, query writing, and performance optimization.

Responsibility

Single Purpose: Design and implement database schemas, queries, and migrations

Actions

design_schema

Design database schema with proper normalization and indexes.

// Input
{
  action: "design_schema",
  database_type: "postgresql",
  orm: "prisma"
}

// Output
{
  success: true,
  schema: {
    models: ["User", "Post", "Comment"],
    relationships: ["User hasMany Post", "Post hasMany Comment"],
    indexes: ["users_email_idx", "posts_author_idx"]
  },
  performance_notes: ["Composite index recommended for posts queries"]
}

write_query

Write optimized database queries.

create_migration

Create database migration scripts.

optimize_performance

Analyze and optimize query performance.

Validation Rules

function validateParams(params: SkillParams): ValidationResult {
  if (!params.action) {
    return { valid: false, error: "action is required" };
  }

  if (params.action === 'write_query' && !params.query_type) {
    return { valid: false, error: "query_type required for write_query" };
  }

  return { valid: true };
}

Error Handling

Error Code Description Recovery
INVALID_DATABASE Unsupported database type Check supported databases
N_PLUS_ONE_DETECTED N+1 query pattern found Add eager loading
MISSING_INDEX Query would cause full table scan Add index recommendation
NORMALIZATION_VIOLATION Schema violates 3NF Suggest refactoring

Logging Hooks

{
  "on_invoke": "log.info('database-integration invoked', { action, database_type })",
  "on_success": "log.info('Database operation completed', { schema, performance_notes })",
  "on_error": "log.error('Database skill failed', { error })"
}

Unit Test Template

import { describe, it, expect } from 'vitest';
import { databaseIntegration } from './database-integration';

describe('database-integration skill', () => {
  describe('design_schema', () => {
    it('should create normalized schema', async () => {
      const result = await databaseIntegration({
        action: 'design_schema',
        database_type: 'postgresql',
        orm: 'prisma'
      });

      expect(result.success).toBe(true);
      expect(result.schema.indexes.length).toBeGreaterThan(0);
    });

    it('should recommend indexes for foreign keys', async () => {
      const result = await databaseIntegration({
        action: 'design_schema',
        database_type: 'postgresql'
      });

      expect(result.schema.indexes).toContain(expect.stringMatching(/_idx$/));
    });
  });

  describe('optimize_performance', () => {
    it('should detect N+1 queries', async () => {
      const result = await databaseIntegration({
        action: 'optimize_performance',
        database_type: 'postgresql'
      });

      expect(result.success).toBe(true);
      expect(result.performance_notes).toBeDefined();
    });
  });
});

Integration

  • Bonded Agent: 04-database-design
  • Upstream Skills: backend-development
  • Downstream Skills: fullstack-testing

Version History

Version Date Changes
1.0.0 2024-01 Initial release
2.0.0 2025-01 Production-grade upgrade with query optimization