sqltrace-review — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited sqltrace-review (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Analyze workload-level diagnostic data from SQL Server Profiler traces (.trc), Extended Events sessions (.xel), sys.fn_trace_gettable() output, or XE session query results. Produce a ranked summary of top resource consumers and a prioritized findings report covering 25 checks (X1–X25) across event patterns and cross-event workload aggregates.
Trace analysis reveals patterns that no single-query artifact can show: which queries run thousands of times per minute, which have wildly inconsistent durations (parameter sniffing), how many recompilations are happening globally, and whether spill or lock events correlate with slow periods.
Accept any of:
sys.fn_trace_gettable() query results — paste the tabular output (tab-separated, CSV, or grid).trc or .xel file path (describe what to extract if the file cannot be read directly)Duration units: SQL Profiler .trc Duration column = microseconds. Extended Events duration = microseconds. CPU units differ by event class: for SQL:BatchCompleted (EventClass 12), CPU is in milliseconds; for RPC:Completed (EventClass 10), CPU is in microseconds beginning with SQL Server 2012 (11.x), and in milliseconds in earlier versions. On SQL Server 2008 R2 and earlier, all trace CPU values were in milliseconds. Normalize all duration values to milliseconds before applying thresholds and displaying results.
Query normalization: Group events by normalized query text — replace literal values and parameter values with placeholders to identify the same logical query across executions. Example: SELECT * FROM Orders WHERE Id = 42 and SELECT * FROM Orders WHERE Id = 99 normalize to the same pattern.
event_class, sql_text, duration_us, cpu_ms, logical_reads, writes, spid, app_name, login_name, db_name, start_time.SQL:BatchCompleted and RPC:Completed events by normalized query pattern. Compute per-pattern: execution count, total/avg/min/max for duration, CPU, reads.| Profiler Class | XE Event Name | Category |
|---|---|---|
| 10 | rpc_completed | Query |
| 12 | sql_batch_completed | Query |
| 13 | sql_batch_starting | Query |
| 16 | attention | Connection |
| 20 | error_reported (login fail) | Security |
| 37 | sql_statement_recompile | Recompile |
| 50 | sql_statement_recompile | Recompile |
| 54 | lock_timeout | Locking |
| 59 | xml_deadlock_report | Locking |
| 65 | hash_warning | Warning |
| 69 | sort_warning | Warning |
| 79 | missing_column_statistics | Statistics |
| 80 | missing_join_predicate | Warning |
| 92 | data_file_auto_grow | Storage |
| 93 | log_file_auto_grow | Storage |
| 146 | query_post_execution_showplan | Plan |
| Metric | Value |
|---|---|
| Long duration — warning | duration ≥ 5,000 ms |
| Long duration — critical | duration ≥ 30,000 ms |
| High CPU — warning | cpu ≥ 5,000 ms |
| High reads — warning | logical_reads ≥ 100,000 |
| High reads — critical | logical_reads ≥ 1,000,000 |
| High writes — warning | writes ≥ 10,000 pages |
| Error severity — critical | error severity ≥ 20 |
| Recompile threshold | ≥ 3 recompile events for the same object/query in trace window |
| High-frequency query | ≥ 1,000 executions of the same normalized query |
| Parameter sniffing signal | max duration > 10× min duration, same normalized query, ≥ 10 executions |
| Global recompile ratio | recompile events > 5% of (SQL:BatchCompleted + RPC:Completed) events |
| Workload concentration | top 3 normalized queries > 80% of total CPU |
| Ad-hoc ratio | distinct query texts / total query events > 80% |
Evaluate per-event rows. A check fires if any single event meets its trigger condition.
SQL:BatchCompleted, RPC:Completed, or sql_statement_completed event where duration ≥ 5,000 ms (warning) or ≥ 30,000 ms (critical). Duration column is in microseconds — divide by 1,000 before comparing./sqlplan-review. Run /sqlstats-review on SET STATISTICS IO, TIME ON output. Identify whether the query is CPU-bound (X2) or wait-bound (high duration, low CPU).cpu ≥ 5,000 ms/sqlplan-review to find the dominant operator. Use /sqlindex-advisor for covering index recommendations.logical_reads ≥ 100,000 (warning) or ≥ 1,000,000 (critical)/sqlstats-review on this query's STATISTICS IO output to identify the highest-read table. Run /sqlindex-advisor to get a covering index. Each 8 KB page read = ~8 MB of data accessed.writes ≥ 10,000 pages/tsql-review W7).Attention) or XE event attention/sqlplan-review on the query to understand why it runs long. Consider increasing timeout only after optimizing the query.Lock:Timeout) or XE event lock_timeout/sqldeadlock-review if deadlock graphs are also present.sql_statement_recompile) for the same stored procedure or normalized query within the trace windowOPTION(RECOMPILE) in a hot path, or statistics updates. See /tsql-review T28 for OPTION(RECOMPILE) trade-offs.error_reported where severity < 20 (warning) or ≥ 20 (critical)Sort Warnings) or XE sort_warningsqlplan-review checks N41–N43. Fix: update statistics (stale stats → bad row estimate → wrong grant), add an index that pre-sorts the data (eliminating the Sort operator), or use OPTION (MIN_GRANT_PERCENT = n) to force a larger grant.Hash Warning) or XE hash_warning/sqlplan-review to identify the spilling Hash Match operator (N41).Missing Column Statistics) or XE missing_column_statisticsCREATE STATISTICS stat_name ON dbo.TableName (ColumnName). For indexed columns, statistics are auto-created — check whether auto-create statistics is enabled at the database level.Missing Join Predicate) or XE missing_join_predicaterows_left × rows_right output rows. See /tsql-review T10 (CROSS JOIN without comment). Confirm the join condition is correct in the source query.Evaluate aggregated patterns across all events in the trace.
max(duration) > 10 × min(duration)OPTION(RECOMPILE) on the query — per-execution plan, eliminates sniffing; (2) OPTION(OPTIMIZE FOR (@param = typical_value)) — pins a representative plan; (3) separate stored procedures for high/low cardinality paths; (4) use Query Store to force the good plan. Use /sqlplan-compare to diff the fast and slow plans.WHERE Id = 1, WHERE Id = 2, ..., WHERE Id = N)sp_executesql with bound parameters, or ORM parameterization. Enable "optimize for ad hoc workloads" as a short-term mitigation (sp_configure 'optimize for ad hoc workloads', 1).OPTION(KEEP PLAN))./sqlplan-review and /sqlindex-advisor on the top 1–3 entries.Data File Auto Grow) or 93 (Log File Auto Grow), or XE database_file_size_change with is_auto_grow = 1SE_MANAGE_VOLUME_NAME) to eliminate file zeroing on data file growth (not applicable to log files). For log files: either pre-size or investigate what is driving high log volume (large uncommitted transactions, bulk inserts without minimal logging, log backup frequency). If auto-grow duration exceeds 1,000 ms (slow auto-grow), the file system or storage subsystem cannot allocate space quickly enough — pre-size the file immediately. For any auto-grow that uses percent growth (the default on older SQL Server versions) rather than fixed-size growth, switch to fixed-size growth to avoid geometrically increasing growth amounts.Showplan XML) or XE query_post_execution_showplan/sqlplan-review on them directly — this is a richer artifact than trace metrics alone. Note that capturing Showplan XML for every query significantly increases trace overhead; disable this event class on production traces after initial diagnosis.query_hash appears with ≥ 2 distinct plan_handle values AND duration variance ratio > 5× — SQL 2022+; flag as possible PSP variant switching if query_hash recurrence patterns show sub-second plan handle changesSELECT * FROM sys.query_store_plan WHERE query_id = (SELECT query_id FROM sys.query_store_query WHERE query_hash = 0x<hash>). If PSP variant plans are causing instability, consider OPTION(OPTIMIZE FOR UNKNOWN) or a Query Store hint to pin one plan.query_post_execution_showplan account for > 15% of total trace event count AND the trace window has > 1,000 events per minuteWHERE sqlserver.query_hash = 0x<hash>. After capturing one representative plan per query of interest, remove the Showplan event from the session. On production, prefer capturing plans via Query Store rather than inline XE Showplan.columnstore_delta_store_flush events appear > 10 times within the trace window — SQL 2012+ledger_block_generated events present in trace — SQL 2022+ only; skip if event is absentSELECT * FROM sys.database_ledger_blocks ORDER BY block_id DESC. No tuning action unless ledger overhead is contributing to CPU contention.hadr_db_partner_set_sync_state or pvs_garbage_collection events with duration_ms > 5000 — SQL 2019+; skip if events absentSELECT * FROM sys.dm_tran_active_transactions WHERE transaction_begin_time < DATEADD(MINUTE,-5,GETUTCDATE()). Check PVS size: SELECT * FROM sys.dm_tran_persistent_version_store_stats. Commit or roll back idle transactions to unblock cleanup.If the SQL Server version is stated by the user, read VERSION_COMPATIBILITY.md (~/.claude/skills/VERSION_COMPATIBILITY.md if installed, or skills/VERSION_COMPATIBILITY.md from the repo). If unavailable, skip silently. For checks whose minimum version exceeds the instance version: verbose mode → log as SKIP (version: requires SQL 20XX+, instance is SQL 20YY); standard report → omit entirely. Do not suppress NOT ASSESSED rows from missing input — only suppress version-inapplicable checks.
Structure your report as follows:
## Trace Analysis
### Input Summary
- Source: [sys.fn_trace_gettable / XE session / Profiler grid / description]
- Trace window: [start_time] – [end_time] ([N] minutes)
- Total events captured: N
- Distinct normalized queries: N
- Event types present: SQL:BatchCompleted, RPC:Completed, Attention, Sort Warnings, ...
---
### Top Resource Consumers
**By Total CPU** (top 5)
| # | Query (first 80 chars, for display only) | Executions | Avg CPU ms | Total CPU ms | % of Workload |
|---|------------------------|-----------|-----------|-------------|---------------|
| 1 | SELECT o.OrderId FROM dbo.Orders... | 12,841 | 18 | 231,138 | 42.1% |
**By Total Logical Reads** (top 5)
| # | Query | Executions | Avg Reads | Total Reads |
...
**By Max Duration** (top 5)
| # | Query | Executions | Avg ms | Max ms | Min ms |
...
---
### Performance Findings
#### Critical Issues
**[C1 — Row 47 (SPID 52, 14:23:01)] Issue Name** (X<N>) ← event-level (X1–X12)
**[C1 — Pattern 3] Issue Name** (X<N>) ← workload aggregate (X13–X20)
- Observed: [query text snippet, metric value, SPID, timestamp or frequency]
- Impact: [why this matters]
- Fix: [concrete action]
#### Warnings
[same format]
#### Info
[same format]
### Passed Checks
X5 ✓ (brief reason), X6 ✓ (brief reason) [list every check verified clean with a reason in parens — e.g., X2 ✓ (individual non-report CPU < 5,000 ms)]
---
*Analyzed by: [state the AI model and version you are running as, e.g. "Claude Sonnet 4.6", "DeepSeek R1", "GPT-4o"] · [current date and time in the user's local timezone, or UTC if timezone is unknown, e.g. "2026-05-16 20:15 NZST"]*[C1 — Row 47 (SPID 52, 14:23:01)]). For workload aggregate findings (X13–X20), include the normalized query pattern number or query hash (e.g., [C1 — Pattern 3])..trc / XE) or milliseconds (some XE configurations) — confirm the unit from column headers or context before applying thresholds.?, replace multi-value IN lists with IN (?,?,?), preserve object names and structure. Two queries that differ only in parameter values should be grouped as the same pattern.xml_deadlock_report) in the trace should be extracted and passed to /sqldeadlock-review — do not attempt full deadlock analysis within this skill.`--brief` — Omit the Passed Checks table and attribution footer. Output the Summary, Findings, and Prioritized Fix Sequence sections only. Use when a quick scan of what fired is all that's needed.
`--critical-only` — Suppress Warning and Info findings. Show only Critical findings. The Passed Checks table is also omitted. Use when triaging an incident and only actionable blockers matter.
Both flags can be combined: --brief --critical-only produces the Summary section plus Critical findings only.
When neither flag is present, produce the full report as documented above.
When the user's request includes --verbose, --trace, or the word verbose:
1. Append a `## Check Evaluation Log` section after the Passed Checks table.
Include one row for every check in this skill's ruleset, in check-ID order:
| Check | Evidence | Threshold | Result |
|---|---|---|---|
| [ID — Name] | [key attribute(s) and value found, or "absent"] | [threshold or condition] | PASS / FIRE → [severity] / NOT ASSESSED |
Result conventions:
PASS — attribute present, threshold not met**FIRE → Critical/Warning/Info** — threshold met; bold to distinguish from passesNOT ASSESSED — required attribute absent from input2. Save both files to the current working directory using the Write tool:
output/<skill-name>/<YYYY-MM-DD-HHmmss>-<input-prefix>/analysis.md ← full report output/<skill-name>/<YYYY-MM-DD-HHmmss>-<input-prefix>/trace.md ← Check Evaluation Log
Derive <input-prefix>:
horrible.sqlplan → horrible)runSanitize: alphanumeric + hyphens/underscores only, max 32 chars.
File headers: analysis.md → # Analysis — <skill-name> / # Input: <first 80 chars> / # Generated: <UTC timestamp> trace.md → # Check Evaluation Log — <skill-name> / # Input: <first 80 chars> / # Generated: <UTC timestamp>
Create directories as needed. When --verbose is not present, write nothing to disk.
Ctrl+M in SSMS or from ShowPlan XML events in the trace itself (X20).CREATE INDEX recommendations from execution plans of the top resource consumers.SET STATISTICS IO, TIME ON on the top-CPU or top-reads query identified here for per-table I/O breakdown..sqlplan files and batch-analyze with this skill.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.