AGENT SKILL

sql-pro

Use when someone needs help writing or rewriting SQL — authoring complex joins, CTEs, window functions, or recursive queries — or designing a schema from scratch, normalizing an existing one, or migrating queries between database dialects.

License 许可
MIT
最近更新
2026-11-11
Stars
★ 3
Forks
1

01 前言 Front Matter

name
sql-pro
license
MIT
metadata
{ "role": "specialist", "scope": "implementation", "domain": "language", "version": "1.1.0", "triggers": "SQL tuning, slow query, schema design, PostgreSQL, MySQL, SQL Server, Oracle, window functions, CTE, EXPLAIN plan, index design", "output-format": "code", "related-skills": "database-optimizer, connection-pool-tuner, spring-boot-engineer" }
scenarios
[ "Rewrite this slow SQL query that's doing full table scans on a 50M row table", "Help me write a complex analytics query with CTEs, window functions, and aggregations", "Our report query takes 5 minutes — optimize it with proper indexing strategy", "풀 테이블 스캔을 하는 느린 쿼리를 최적화해줘", "윈도우 함수와 CTE를 활용한 복잡한 분석 쿼리를 작성해줘" ]
description
Use when someone needs help writing or rewriting SQL — authoring complex joins, CTEs, window functions, or recursive queries — or designing a schema from scratch, normalizing an existing one, or migrating queries between database dialects.
compatibility
{ "optional": [ "think-tool" ], "recommended": [], "remote_mcp_note": "think-tool이 있으면 쿼리 실행 계획 해석과 인덱스 전략 결정을 더 체계적으로 검토합니다. Claude 설정 → MCP Servers에서 remote SSE 엔드포인트를 추가하세요." }

02 资源文件 21

03 SKILL.md 正文

Standing Mandates

  • NEVER propose a rewrite or index before you have the execution plan and the row counts. A fix written from the query text alone is a guess; the same text can be fast on 10k rows and a full scan on 50M. No plan supplied is [확인 필요: EXPLAIN ANALYZE], and the rewrite is marked unmeasured.
  • NEVER report a speedup you did not see as a before/after number. A claimed gain without both plans is unverified.
  • Target engine and version unknown is [확인 필요: engine/version]; never assume dialect-specific syntax is available.
  • Goal: the final query, its plan before and after, and a closing tally that recounts to the evidence lines (schema or porting tasks: the DDL/query and its caveats; plan lines read n/a).

SQL Pro

Writes and rewrites SQL, designs schemas, and ports queries between dialects, judged by the plan, not by the look of the query.

Not for server-level causes: memory, VACUUM, lock waits (develop:database-optimizer), pool exhaustion (develop:connection-pool-tuner), or transaction scope (develop:transaction-boundary-reviewer).

Process

  1. Context. Read schema, indexes, and the query; confirm engine and version. Read the repo before asking.
  2. Design. Shape the query as set operations: CTEs, window functions, correct join types.
  3. Plan. Read the EXPLAIN first, then optimize: covering indexes, early filters, no big sequential scans.
  4. Verify. Re-run EXPLAIN ANALYZE; compare to the baseline. Stop when the user's latency target is met (absent: [확인 필요: target latency]) or after 3 rounds with no improvement, and report the best plan with the remaining bottleneck.
  5. Document. Index rationale, engine caveats, minimum version. Before sending, recount the tally against the finding/change lines; fix the header if they differ.

Coding rules and worked examples (CTE, window, correlated-subquery rewrite): references/worked-examples.md.

Topic File Read it when
Query shapes references/query-patterns.md Joins, CTEs, recursion, subquery rewrites, pivots, keyset paging
Analytic windows references/window-functions.md Ranking, running totals, LAG/LEAD, frames, gaps-and-islands
Tuning and plans references/optimization.md Plan reading, index choice, statistics, partitioning
Schema design references/database-design.md Normal forms, keys, constraints, history tables, migrations
Porting engines references/dialect-differences.md PostgreSQL, MySQL, SQL Server, Oracle

Output Template

## SQL — <task>

Query: <final query, commented inline>
Indexes: <DDL → why>
Plan: before <cost/time, key node> → after <cost/time, key node>   (or unmeasured: [확인 필요: EXPLAIN ANALYZE])
Caveats: <engine-specific>   Minimum version: <e.g. PostgreSQL >= 10>

<n> queries · <m> measured before/after · <k> unmeasured

What Claude Does / What You Do

Claude You
Writes the set-based query, reads the plan, proposes indexes Provide schema DDL, sample data, actual EXPLAIN ANALYZE
Flags dialect differences Test on your DB version; run CREATE INDEX CONCURRENTLY yourself
Writes up the before/after Check it against production-sized data

Related Skills

  • develop:database-optimizer — server-level tuning after the query is optimized
  • develop:connection-pool-tuner — pool sizing if slow queries are exhausting connections
  • develop:spring-boot-engineer — JPA query methods and @Query

04 同仓库更多 Skills

newkayak12
newkayak12/claude-skills

diagram

Use when something must be drawn as a checked figure, not Mermaid: page layout, B-tree, lock timeline, ER, benchmark chart, architecture, sequence. SVG + PNG. Triggers: "도식화해줘", "그림으로 그려줘", "책에 넣을 그림", "시퀀스 다이어그램", "draw this as a figure".

★ 3
newkayak12
newkayak12/claude-skills

test-master

Use when writing, improving, or auditing tests, or writing case specs with expected results from a spec. Triggers: "테스트 작성", "테스트 케이스 작성", "test case writing", "단위 테스트", "커버리지 분석", "test plan", "defect report".

测试与质量Skill与智能体开发
★ 3
newkayak12
newkayak12/claude-skills

sre-engineer

Use when setting up production reliability practices. Triggers on: "SLO 정하고 싶어", "에러 버짓", "알람 피로", "반복 작업(toil) 줄이기", "golden signals dashboard", "burn-rate alert". Not for active incidents or chaos tests.

Skill与智能体开发
★ 3
newkayak12
newkayak12/claude-skills

spring-boot-engineer

Use when building or extending a Spring Boot 3.x Java backend — REST, Spring Security, JPA, WebFlux, Actuator. Triggers on: "Spring Boot API", "스프링 시큐리티 설정", "JPA 연동". Not for service decomposition or query tuning.

开发工程师后端与接口Skill与智能体开发
★ 3
newkayak12
newkayak12/claude-skills

spec-driven-development

Use when a feature should be specified before it is coded — stories, acceptance criteria, tasks, a per-criterion check. Triggers: "스펙 먼저", "명세부터 쓰고 구현", "수용 기준 먼저", "spec first", "spec-driven development".

Skill与智能体开发
★ 3
newkayak12
newkayak12/claude-skills

like-my-code

Use when a repo's code style must become written policy — harness conventions (coding.md, boundaries.md) backed by repo evidence. Triggers: "내 코드 스타일로 컨벤션 뽑아줘", "이 레포 스타일을 정책으로", "like my code", "extract conventions from this repo".

开发工程师Skill与智能体开发
★ 3