Database Engineering
Purpose
Design and maintain PostgreSQL data models and SQLAlchemy persistence safely.
Project Stack
PostgreSQL, SQLAlchemy 2, Alembic.
Operating Principles
- Inspect existing models and relationships before creating new tables.
- Understand cardinality and ownership of every relationship.
- Use explicit constraints for important invariants.
- Use appropriate indexes based on actual query patterns.
- Do not add indexes blindly.
- Protect referential integrity with foreign keys where appropriate.
- Consider nullability deliberately.
- Use transactions for multi-step state changes.
- Never delete production data as part of exploratory work.
- Do not assume development and production schemas are identical.
- Verify generated SQL and migration behavior for significant changes.
Required Workflow
- Inspect current schema and ORM models.
- Identify affected queries and relationships.
- Design constraints and indexes.
- Implement model changes.
- Create or update migrations.
- Run migrations in a safe environment.
- Run relevant database/API tests.
- Inspect query behavior where necessary.
- Review data-loss and rollback risks.
Evidence Rules
Use the strongest available evidence in this order:
- Runtime behavior
- Automated test results
- Type checking, linting, and build results
- Installed package/source behavior
- Official framework or library documentation
- Repository configuration
- Static code inspection
- General model knowledge
Never report an assumption as a verified result.
Tool Selection
- Use Filesystem MCP for repository exploration and file inspection.
- Use Context7 for current, version-specific library/framework documentation.
- Use Fetch when official documentation or public web resources need to be retrieved.
- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.
- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.
- Prefer the smallest tool set that establishes reliable evidence.
Failure Handling
When something fails:
- Reproduce the failure.
- Capture the exact error.
- Identify the failing layer.
- Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.
- Research uncertain behavior using authoritative sources.
- Apply the smallest appropriate fix.
- Reproduce the original failure again.
- Run regression checks.
- Inspect the final diff.
Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.
Security
- Never expose secrets.
- Never commit credentials.
- Treat all external input as untrusted.
- Preserve authentication and authorization boundaries.
- Avoid leaking internal implementation details through errors.
- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.
Completion Criteria
A task using this skill is complete only when:
- The requested behavior is implemented.
- Existing project conventions are preserved.
- Relevant static checks pass.
- Relevant tests pass or their absence is explicitly reported.
- Browser verification is performed when the task affects user-facing behavior.
- Security implications have been considered.
- The final diff has been inspected.
- Verified facts are clearly distinguished from assumptions or remaining uncertainty.
1---2name: database3description: Database Engineering4---5# Database Engineering67## Purpose89Design and maintain PostgreSQL data models and SQLAlchemy persistence safely.1011## Project Stack1213PostgreSQL, SQLAlchemy 2, Alembic.1415## Operating Principles16171. Inspect existing models and relationships before creating new tables.182. Understand cardinality and ownership of every relationship.193. Use explicit constraints for important invariants.204. Use appropriate indexes based on actual query patterns.215. Do not add indexes blindly.226. Protect referential integrity with foreign keys where appropriate.237. Consider nullability deliberately.248. Use transactions for multi-step state changes.259. Never delete production data as part of exploratory work.2610. Do not assume development and production schemas are identical.2711. Verify generated SQL and migration behavior for significant changes.2829## Required Workflow30311. Inspect current schema and ORM models.322. Identify affected queries and relationships.333. Design constraints and indexes.344. Implement model changes.355. Create or update migrations.366. Run migrations in a safe environment.377. Run relevant database/API tests.388. Inspect query behavior where necessary.399. Review data-loss and rollback risks.4041## Evidence Rules4243Use the strongest available evidence in this order:44451. Runtime behavior462. Automated test results473. Type checking, linting, and build results484. Installed package/source behavior495. Official framework or library documentation506. Repository configuration517. Static code inspection528. General model knowledge5354Never report an assumption as a verified result.5556## Tool Selection5758- Use Filesystem MCP for repository exploration and file inspection.59- Use Context7 for current, version-specific library/framework documentation.60- Use Fetch when official documentation or public web resources need to be retrieved.61- Use Playwright for browser behavior, frontend interaction, forms, authentication flows, and UI verification.62- Use GitHub CLI for repository, branch, pull request, issue, workflow, and CI operations.63- Prefer the smallest tool set that establishes reliable evidence.6465## Failure Handling6667When something fails:68691. Reproduce the failure.702. Capture the exact error.713. Identify the failing layer.724. Check whether the failure is environmental, dependency-related, configuration-related, or caused by application code.735. Research uncertain behavior using authoritative sources.746. Apply the smallest appropriate fix.757. Reproduce the original failure again.768. Run regression checks.779. Inspect the final diff.7879Do not hide failures by weakening tests, suppressing errors, deleting evidence, or claiming success without verification.8081## Security8283- Never expose secrets.84- Never commit credentials.85- Treat all external input as untrusted.86- Preserve authentication and authorization boundaries.87- Avoid leaking internal implementation details through errors.88- Review security implications whenever the skill touches users, data, credentials, networking, or deployment.8990## Completion Criteria9192A task using this skill is complete only when:9394- The requested behavior is implemented.95- Existing project conventions are preserved.96- Relevant static checks pass.97- Relevant tests pass or their absence is explicitly reported.98- Browser verification is performed when the task affects user-facing behavior.99- Security implications have been considered.100- The final diff has been inspected.101- Verified facts are clearly distinguished from assumptions or remaining uncertainty.