Generate type-safe, extensible Drizzle ORM repository classes with multi-dialect support and dependency injection
This skill has safety concerns that you should review before use. Some patterns were detected that may pose a risk.Safety score: 60/100.
KillerSkills scans all public content for safety. Use caution before installing or executing flagged content.
Generate type-safe, extensible repository classes for Drizzle ORM projects supporting PostgreSQL, MySQL, and SQLite with dependency injection and customizable codegen.
This skill helps you work with the Drizzle Repository Codegen Framework, an NPM package that generates type-safe repository classes with three layers: base repositories (abstract common operations), generated repositories (auto-generated from schema), and custom repositories (developer extensions). It supports multiple database dialects, uses TSyringe for dependency injection, and provides CLI tools for code generation.
When working with this repository:
1. **Use Bun runtime commands**
- Run files: `bun <file>` (not `node` or `ts-node`)
- Install packages: `bun install` (not `npm install`)
- Run scripts: `bun run <script>` (not `npm run`)
- Hot reload: `bun --hot src/index.ts`
- Type checking: `bun --check`
2. **Run tests with Bun's test runner**
- All tests: `bun test`
- Watch mode: `bun test --watch`
- Specific tests: `bun test <pattern>`
3. **Follow the three-layer repository architecture**
- BaseRepository: Abstract base classes with common operations (shared and dialect-specific)
- Generated Repositories: Auto-generated from schema files (always overwritten)
- Custom Repositories: Developer extensions (never overwritten)
4. **Understand the project structure**
```
src/
├── cli/ # CLI commands and parsing
├── core/ # Core business logic
│ ├── generators/ # Code generation logic
│ ├── parsers/ # Schema file parsing
│ └── templates/ # Template generation
├── repositories/ # Base repository classes
│ ├── base/ # Abstract base classes
│ ├── dialects/ # Dialect-specific implementations
│ └── types/ # Repository type definitions
├── container/ # DI container setup
├── config/ # Configuration management
└── types/ # Global type definitions
```
5. **Work with multi-dialect support**
- PostgreSQL: Using `Bun.sql` for connections
- MySQL: Bun's built-in MySQL support
- SQLite: Using `bun:sqlite`
6. **Use Bun-specific APIs**
- File operations: `Bun.file` (not `node:fs`)
- Shell commands: `Bun.$` (not external process libraries)
- Environment variables: Automatically loaded from .env
- WebSocket: Built-in (not `ws` library)
7. **Follow code generation patterns**
- Configuration: `repository.codegen.config.ts` with dialect selection, schema paths, output directories
- Templates: Simple template literals (no external dependencies)
- Type-safe generation with proper TypeScript types
8. **Maintain code quality standards**
- Strict TypeScript configuration (ESNext target, module preservation)
- Type safety throughout the codebase
- JSDoc documentation for generated code
- Graceful error handling with informative messages
9. **Test across all database dialects**
- Docker Compose setup for PostgreSQL and MySQL testing
- Unit tests for individual methods
- Integration tests for full database operations
10. **Before committing**
- Do NOT run `git add` until code is reviewed
- Ensure all tests pass
- Verify TypeScript compilation
```bash
bun --hot src/index.ts
bun test --watch
npx drizzle-repo-codegen generate
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/drizzle-repository-codegen/raw