Sponsor Suno AI Music arrow_forward
Slash Command

Deadlock

Detect and resolve database deadlocks with automated monitoring

Type
Slash Command
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026

What Deadlock is

Deadlock is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.

Deadlock gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.

How to install Deadlock

Claude Code

  1. Download deadlock.md from the repository.
  2. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
  3. Run it by typing / followed by its name.

Claude Cowork

  1. Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
  2. In Customize → Skills, click +, then upload the ZIP.
  3. Run it from any task with / and the skill name.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/database/database-deadlock-detector/commands/deadlock.md, shared under the repository's MIT license. Read the full file on GitHub.

Detect, analyze, and prevent database deadlocks with automated monitoring, alerting, and resolution strategies for production database systems.

When to Use This Command

Use /deadlock when you need to:

  • Investigate recurring deadlock issues in production
  • Implement proactive deadlock detection and alerting
  • Analyze transaction patterns causing deadlocks
  • Optimize lock acquisition order in applications
  • Monitor database lock contention in real-time
  • Generate deadlock reports for performance tuning

DON'T use this when:

  • Database doesn't support deadlock detection (use lock monitoring instead)
  • Dealing with application-level race conditions (not database deadlocks)
  • Looking for slow queries (use query analyzer instead)
  • Investigating connection pool exhaustion (use connection pooler)

Design Decisions

This command implements comprehensive deadlock detection and prevention because:

  • Proactive monitoring prevents production incidents
  • Automated analysis identifies root causes faster
  • Prevention strategies reduce deadlock frequency by 90%+
  • Real-time alerting enables rapid incident response
  • Historical analysis reveals patterns and trends

Alternative considered: Reactive deadlock handling

  • Only responds after deadlocks occur
  • Relies on application retry logic
  • No visibility into deadlock patterns
  • Recommended only for low-traffic systems

Alternative considered: Database-native logging only

  • Limited to log file analysis
  • No automated alerting or resolution
  • Requires manual correlation of events
  • Recommended only for development environments

Prerequisites

Before running this command:

  1. Database user with monitoring permissions (e.g., pg_monitor role)
  2. Access to database logs or system views
  3. Understanding of your application's transaction patterns
  4. Monitoring infrastructure (Prometheus/Grafana recommended)
  5. Python 3.8+ or Node.js 16+ for monitoring scripts

Implementation Process

Step 1: Configure Database Deadlock Logging

Enable comprehensive deadlock detection and logging in your database.

Step 2: Implement Deadlock Monitoring

Set up automated monitoring to detect and alert on deadlocks in real-time.

Step 3: Analyze Deadlock Patterns

Build analysis tools to identify common deadlock scenarios and root causes.

Step 4: Implement Prevention Strategies

Apply code changes and database tuning to prevent deadlocks proactively.

Step 5: Set Up Continuous Monitoring

Deploy dashboards and alerting for ongoing deadlock visibility.

Output Format

The command generates:

  • monitoring/deadlock-detector.py - Real-time deadlock monitoring script
  • analysis/deadlock-analyzer.sql - SQL queries for pattern analysis
  • config/deadlock-prevention.md - Prevention strategies documentation
  • dashboards/deadlock-dashboard.json - Grafana dashboard configuration
  • alerts/deadlock-rules.yml - Prometheus alerting rules

Code Examples

Example 1: PostgreSQL Deadlock Detection and Monitoring

-- Enable comprehensive deadlock logging
-- Add to postgresql.conf
log_lock_waits = on
deadlock_timeout = '1s'
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '

-- Create deadlock monitoring view
CREATE OR REPLACE VIEW deadlock_monitor AS
SELECT
    l.locktype,
    l.relation::regclass AS table_name,
    l.mode,
    l.granted,
    l.pid AS blocked_pid,
    l.page,
    l.tuple,
    a.usename,
    a.application_name,
…
# monitoring/deadlock-detector.py
import psycopg2
import time
import logging
import json
from datetime import datetime, timedelta
from typing import List, Dict, Optional
from dataclasses import dataclass, asdict
from collections import defaultdict

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

@dataclass
class DeadlockEvent:
    """Represents a detected deadlock event."""
    detected_at: datetime
    blocked_pid: int
…

Example 2: MySQL Deadlock Detection and InnoDB Monitoring

-- Enable InnoDB deadlock logging
-- Add to my.cnf
[mysqld]
innodb_print_all_deadlocks = 1
innodb_deadlock_detect = ON
innodb_lock_wait_timeout = 50

-- Create deadlock monitoring table
CREATE TABLE deadlock_log (
    id INT AUTO_INCREMENT PRIMARY KEY,
    detected_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    victim_thread_id BIGINT,
    victim_query TEXT,
    waiting_query TEXT,
    lock_mode VARCHAR(50),
    table_name VARCHAR(255),
    index_name VARCHAR(255),
    deadlock_info TEXT,
…
// monitoring/mysql-deadlock-detector.js
const mysql = require('mysql2/promise');
const fs = require('fs').promises;

class MySQLDeadlockDetector {
    constructor(config) {
        this.config = config;
        this.pool = mysql.createPool({
            host: config.host,
            user: config.user,
            password: config.password,
            database: config.database,
            waitForConnections: true,
            connectionLimit: 10,
            queueLimit: 0
        });
        this.checkInterval = config.checkInterval || 10000;
        this.deadlockStats = {
…

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Deadlock?

Deadlock is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Detect and resolve database deadlocks with automated monitoring

How do I install Deadlock in Claude Code?

Download deadlock.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.

Can I use Deadlock in Claude Cowork?

Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.

Is Deadlock safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.