tlabs-xyz/tbtc-v2-performance
Overview
This skill guides writing efficient, secure database queries and data-access logic in TypeScript backends. It emphasizes parameterized queries, eager loading, transaction safety, and query performance optimizations to reduce latency and prevent common pitfalls like N+1 queries and SQL injection. Use it to standardize repository/DAO code and ORM usage across services.
How this skill works
The skill inspects query intent and suggests concrete query patterns: parameterized SQL, ORM query-builder calls, eager-loading or join strategies, and pagination/caching techniques. It recommends specific performance improvements such as indexing hints, selecting only needed columns, using transactions where required, and applying query timeouts or monitoring. Outputs include code snippets, refactor suggestions, and checklist-style validations tailored to TypeScript ORMs like Prisma, TypeORM, and Sequelize.
When to use it
- Writing or refactoring SQL or ORM-based data retrieval logic
- Implementing eager loading or joins to avoid N+1 problems
- Adding filters, sorting, pagination, or search features
- Protecting queries against SQL injection with parameterization
- Optimizing slow queries, adding indexes, or caching results
Best practices
- Always use parameterized queries or ORM parameter binding to prevent SQL injection
- Load only required columns and prefer eager loading or explicit joins to prevent N+1 queries
- Wrap multi-step updates in transactions and handle rollbacks on failure
- Add pagination, limits, and sensible defaults for list endpoints
- Measure query plans and add indexes based on real slow-query evidence, not guesses
- Cache expensive, read-heavy queries and invalidate on writes
Example use cases
- Refactor a REST endpoint from multiple per-record queries into a single eager-loaded ORM query to eliminate N+1
- Implement cursor-based pagination for large result sets with stable sort keys
- Convert string interpolation SQL into parameterized prepared statements to remove injection risk
- Add a transactional update across multiple tables with rollback on any constraint failure
- Instrument and optimize a slow JOIN by analyzing EXPLAIN output and adding an index
FAQ
Prefer eager loading when you know related data is required for the response to avoid N+1 queries. Use lazy loading only when related data is rarely needed to reduce unnecessary joins.
How do I choose pagination style?
Use offset/limit for simple UIs and small datasets. Use cursor-based pagination for large or frequently changing datasets to ensure stable and performant paging.
18 skills
This skill helps you write secure, efficient backend queries using parameterized queries, ORM builders, and proper optimization strategies.
This skill helps you write tests by applying the Agent OS standard for test-writing across unit and integration tests.
This skill enforces global conventions by applying the Agent OS standard across codebases, ensuring consistency and quality.
This skill helps you design and implement consistent RESTful APIs across frameworks, enforcing naming, versioning, authentication, and documentation.
This skill guides you to write maintainable, performant CSS across frameworks using design tokens, methodologies like BEM, CSS modules, and utility classes.
This skill helps implement backend models following the Agent OS standard, ensuring consistency and quality across TypeScript backend components.
This skill helps you design and refactor reusable UI components across frameworks with clear interfaces and robust state management.
This skill enforces global error handling standards across the codebase, ensuring consistent responses and reliable observability.
This skill enforces frontend accessibility standards by applying agent-os guidelines to components, pages, and interactions for inclusive user interfaces.
This skill helps you apply the Agent OS standard for backend migrations, ensuring consistent practices across databases and deployment environments.
This skill helps you apply the Agent OS standard for backend queries across TypeScript projects, ensuring consistent patterns and reliable data access.
This skill helps enforce the Agent OS frontend CSS standard across projects, improving consistency, accessibility, and maintainability.
This skill guides you to implement robust error handling across code, API boundaries, and user-facing messages with fail-fast and graceful degradation.
This skill enforces global project conventions, guiding structure, docs, config, dependencies, and workflows to improve consistency and collaboration.
This skill helps ensure frontend components follow the Agent OS standard, improving consistency, quality, and maintainability across projects.
This skill helps maintain project-wide tech stack consistency by guiding dependency choices, tooling, and configurations across frontend, backend, and infra.
This skill applies the Agent OS global tech stack standard to ensure consistent architecture and tooling across projects.
This skill guides frontend responsive practices to create mobile-first, fluid layouts with adaptive typography and accessible, performant UI across devices.