Back to catalog

database-work

Interactive browser-based AppSec training game where players identify vulnerabilities in code and learn secure coding practices

  • Category: discovered
  • Tags: github, community
  • Version: 1.0.0
  • Author: walid
  • Downloads: 0
  • GitHub stars: 2
  • Updated: 2025-11-21

Download the latest version (v1.0.0) from this page.

SKILL.md

# Database Work Skill

## Activation Context
Activates when working with databases, data models, queries, or migrations.

## When to Invoke database-engineer Agent
- Designing database schemas
- Creating migrations
- Optimizing queries
- Setting up indexes
- Implementing data validation
- Planning data architecture

## Coordination Protocol

### Before Starting Database Work
1. Review data requirements from architect
2. Understand business logic from backend-engineer
3. Consider scalability requirements
4. Plan for data integrity

### During Development
1. Design normalized schema (unless denormalization needed)
2. Add proper indexes for query performance
3. Implement foreign key constraints
4. Create reversible migrations
5. Document schema changes
6. Test migrations in staging

### Migration Checklist
- [ ] Migration is reversible (has up and down)
- [ ] Tested in local environment
- [ ] Tested in staging environment
- [ ] Data backup plan for production
- [ ] Indexes added for new columns used in queries
- [ ] Foreign keys and constraints defined
- [ ] Default values specified where appropriate
- [ ] No data loss scenarios

## Handoff Points
- **From architect**: Data model requirements
- **To backend-engineer**: Schema documentation and query patterns
- **To qa-engineer**: Data validation test scenarios
- **To devsecopsengineer**: Migration deployment process

## Performance Optimization
- Index frequently queried columns
- Use appropriate data types
- Avoid N+1 query problems
- Implement connection pooling
- Monitor slow queries
- Use EXPLAIN to analyze query plans

## Security Considerations (security-engineer review)
- Encrypt sensitive data at rest
- Use parameterized queries (prevent SQL injection)
- Implement row-level security where needed
- Limit database user permissions
- No passwords or secrets in migrations
- Regular backups and disaster recovery plan

## Best Practices
- Follow naming conventions (snake_case for PostgreSQL, etc.)
- Add created_at and updated_at timestamps
- Use UUIDs or auto-increment for primary keys
- Document relationships and constraints
- Version control all schema changes
- Test migrations both up and down
- Keep migrations small and focused

## Common Patterns
- **One-to-Many**: Use foreign keys
- **Many-to-Many**: Use junction tables
- **Soft Deletes**: Add deleted_at column
- **Audit Trails**: Create audit log tables
- **Polymorphic Associations**: Use type and ID columns