/microsoft-sql-admin:sql-agent-job-failure-investigator [JobName] [LookbackHours] [TopN]from Microsoft SQL administration
Investigates SQL Server Agent job failures, cancellations, retries, stuck runs, or missed schedules. Queries msdb to identify the failing step and error, and checks job ownership, schedule, retry settings, and database dependencies.
Ships in Microsoft SQL administration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill to identify why a SQL Server Agent job failed and produce an evidence-based investigation report. The workflow answers:
This is a diagnostic skill. Do not start, stop, alter, enable, disable, or rerun a job unless the user explicitly requests that action after reviewing the findings.
microsoft-sql-admin plugin (mssql_list_database_connections,
mssql_connect_database, then mssql_execute_query); any other SQL tool the agent host provides
for running T-SQL and reading result sets;
sqlcmd from a terminal. If the
SQL Tools MCP server is not connected or lists no connections, follow the sql-tools-mcp-setup
skill, which asks before installing or configuring anything. If no SQL tool can be made available,
give the user the T-SQL to run and ask for the results.VIEW SERVER PERFORMANCE STATE (VIEW SERVER STATE before SQL Server 2022) or, on Azure
SQL Database, VIEW DATABASE PERFORMANCE STATE or ##MS_ServerStateReader##, plus any other read
permission these queries need. A tool is only as read-only as the login it connects with.SELECT @@SERVERNAME, DB_NAME(), SUSER_SNAME(), SERVERPROPERTY('EngineEdition')); if not connected, ask the user for the target.master or the affected job-step database; all SQL Server Agent metadata
is queried with fully qualified msdb object names.sysadmin can inspect all
jobs; members of SQLAgentReaderRole can inspect all jobs but may not have access to every
target database or subsystem.VIEW SERVER STATE is required to inspect SQL Server Agent service state on SQL Server. Managed
Instance does not expose service state.| Parameter | Default | Description |
|---|---|---|
| JobName | empty | Exact job name for drill-down. Leave empty to inventory recent failures first. |
| LookbackHours | 24 | Number of hours of job outcome and step history to inspect. |
| TopN | 20 | Maximum number of jobs or history rows returned per query. |
| EngineEdition | Platform | Support |
|---|---|---|
| 2, 3 | SQL Server Standard or Enterprise on-premises / Azure VM | Supported |
| 4 | SQL Server Express on-premises / Azure VM | Not supported; Express does not include SQL Server Agent |
| 8 | Azure SQL Managed Instance | Supported |
| 5 | Azure SQL Database | SQL Server Agent is not supported; if the workload uses Azure SQL Elastic Jobs, investigate the Elastic Job agent and job execution history instead |
| 9 | Azure SQL Edge | Not supported |
| 11, 12 | Fabric Warehouse / Fabric SQL Database | SQL Server Agent and Elastic Jobs are not supported; use the configured scheduler, such as Data Factory or Airflow, for diagnostics |
| 6 | Azure Synapse dedicated SQL pool | Not supported |
| any other value | Unknown engine edition | Stop and report the platform as unverified; do not query msdb |
Do not run the msdb queries against unsupported platforms. The Azure SQL Elastic Jobs alternative
is a separate diagnostic path and must not be represented as SQL Server Agent history.
For the full platform, edition, and version matrix — including EngineEdition values, Express and
Managed Instance feature limitations, msdb metadata tables, and status/schedule code tables — read
references/platform-and-edition-reference.md.
Read references/queries.md and execute each applicable step with the SQL query tool. Escape job names and validate numeric bounds exactly as required at the top of the query reference. Never substitute unvalidated user text into a SQL batch.
Run Step 1 before querying msdb. Stop when is_supported = 0. Agent service state is returned
only on SQL Server (engine_edition 2 or 3); on Azure SQL Managed Instance the Agent is
platform-managed and always running, so no service row is expected. If the platform is supported
and the Agent service is stopped, report that as a likely systemic cause and continue with
historical steps when permissions allow. Use
references/platform-and-edition-reference.md to
map the EngineEdition result to the correct platform, confirm the edition supports SQL Server
Agent, and route Azure SQL Database, Synapse, and Fabric to their non-Agent alternatives.
Run Step 2 when JobName is empty or when the user does not know which job failed. It returns the
latest job-level outcome (step_id = 0) for jobs that failed, were canceled, retried, or remained
in progress during the lookback window.
If no rows are returned, state that no unsuccessful job outcomes were retained in the selected
window. Increase LookbackHours only with the user's agreement because SQL Agent history may be
purged or capped.
Set JobName to the exact job name and run Step 3. Use instance_id ordering to reconstruct the
execution. The job-level row has step_id = 0; step rows identify the actionable failure.
Do not infer success from a successful final step alone. Use the job-level outcome and account for step flow actions such as quit-with-success, retries, or branching to another step.
Run Step 4 to determine whether the selected job is currently running and which step last completed.
An unfinished row can indicate a genuinely long execution, a blocked step, or stale activity after
an Agent restart. Correlate agent_start_date and run_requested_date before classifying it. Do
not claim that the inferred next sequential step is active when branching, retries, or restart-step
configuration could alter execution flow.
Run Step 5. Check disabled jobs/schedules, unexpected owners, missing schedules, schedule windows, and notification levels. A job can fail correctly but remain unnoticed when no failure notification is configured. Cached next-run data and missing history do not prove that a schedule occurrence was missed; correlate Agent uptime, schedule definition, activity, and external monitoring, and report an evidence gap when the expected occurrence cannot be reconstructed reliably.
Run Step 6. Check each step's subsystem, target database, proxy, retries, output logging, and on-failure action. Command text is intentionally omitted. Never retrieve or display step commands unless the user explicitly approves that sensitive evidence collection because even a short prefix can contain credentials, tokens, or connection-string values.
Run Step 7 to find the last retained successful job outcome, verify that the owner resolves to an enabled login, inspect the target database state and accessibility, and determine the local Availability Group replica role when applicable. Do not recommend execution on a secondary or an unknown replica unless the job is intentionally designed for that role.
Run the applicable Step 8 queries for the narrow failure window. Correlate by timestamp, job name, step name, message ID, database, and subsystem. Redact secrets and connection-string values from all excerpts. A log match is supporting evidence; do not attribute unrelated messages solely because they occurred nearby. Obtain explicit approval before retrieving raw error-log rows.
Use Step 9 to inspect current blocking and resource state, then use retained Query Store, Extended Events, monitoring, or platform telemetry for historical evidence. Current DMVs do not prove what happened during a past failure. Classify deadlock, timeout, disk, log, tempdb, CPU, memory, or I/O pressure only when timestamped evidence overlaps the failure window.
Use Step 10's non-revealing indicators to identify likely files, shares, linked servers, Database Mail, packages, executables, replication components, or external endpoints. Validate each dependency under the effective execution identity through an approved, non-destructive check. Never reveal credential values or retrieve command text merely to discover dependencies.
Read references/root-cause-guide.md and classify the dominant failure category only when the collected evidence supports it. List unresolved evidence gaps.
Read references/report-template.md and use it for the final answer.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub microsoft/microsoft-sql --plugin microsoft-sql-admin47 skills in this plugin
/active-connectionsUse when the user asks who is connected, which sessions are idle or hold the oldest open transaction, or how connections split by login or app. If a client can't connect, use `connectivity-troubleshoot`./always-encrypted-columnsUse when the user asks which plaintext columns can or should use Always Encrypted, or why a column is disqualified. Eligibility only: not for listing already-encrypted columns or their keys./authentication-diagnosticsUse when a login fails (18456, 'Login failed for user'), a user can't open a database, a permission is denied, or an Entra or managed identity login fails. For network errors, use `connectivity-troubleshoot`./backup-history-azuresqlUse when the user asks for backup history, the latest backups or backup retention on Azure SQL Database or Fabric SQL Database. For SQL Server or Managed Instance, use `backup-strategy-sqlserver`./backup-strategy-sqlserverUse when the user asks to review or design a SQL Server or Managed Instance backup strategy, or whether the recovery model and backup schedule meet an RPO. For Azure SQL Database, use `backup-history-azuresql`./blocking-root-cause-analysisUse when the user asks what caused blocking that already ended (yesterday's incident, intermittent lock waits) or who is behind a supplied blocking chain. For blocking happening now, use `check-live-blocking`.Other plugins' skills for the same job