Skip to content

Guide · Agent skill

How to use the Database Optimizer agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The Database Optimizer skill is a set of instructions and reference notes that tells an AI agent how to investigate slow database queries in PostgreSQL and MySQL. It is written for backend developers, DBAs and data engineers who want a structured process rather than guesswork. After this guide you will know what the skill changes about the agent's behaviour, how to install it, how to ask for help in plain language and what to check before applying any suggested change.

Database OptimizerJeffallan/claude-skills · MIT

Quick start

  1. 1Download the ZIP. Get the database-optimizer skill ZIP from the page where you found this guide.
  2. 2Unzip into a skills folder. Extract it into ~/.claude/skills/ for personal use or into .claude/skills/ in a project folder.
  3. 3Or upload in the Claude apps. In the Claude apps, open Settings, go to Capabilities, then Skills, and upload the skill.
  4. 4Prepare your database. Enable pg_stat_statements on PostgreSQL or performance_schema on MySQL, and make sure you have rights to run EXPLAIN ANALYZE.
  5. 5Describe the slow query. Ask in plain language, including the database type, the query and your measured timing.
  6. 6Review the proposed changes. Read each index or config change and its SQL, then test it on a staging copy.
  7. 7Apply and validate one change at a time. Re-run EXPLAIN ANALYZE, compare the results and watch write performance and replication lag.

What the Database Optimizer skill makes the agent do

Once the skill is loaded, the agent follows a fixed workflow for database slowness: capture a baseline, find the bottlenecks, design a fix, apply it one change at a time and validate the result. It is designed for performance work such as reading execution plans, spotting missing indexes or stale statistics, rewriting queries, tuning configuration, planning partitioning and resolving lock contention.

The skill's output is meant to include a baseline with query time, cost and buffer hit ratio, the bottlenecks with EXPLAIN evidence, the SQL or configuration changes, validation queries and monitoring recommendations.

  • Asks for or captures baseline measurements before any change
  • Reads EXPLAIN ANALYZE output and points to specific patterns such as Seq Scan, Nested Loop and external merge sorts
  • Proposes index designs, query rewrites and configuration changes with the SQL to apply them
  • Provides validation queries and a monitoring checklist

Install the skill from the ZIP download

Download the ZIP for the database-optimizer skill from the page where you found this guide. Then choose one of two options depending on where you want the skill to live.

For a personal install available across your projects, unzip it into ~/.claude/skills/. For a single project, unzip it into the .claude/skills/ folder inside that project. Either way the skill's folder should contain SKILL.md and the references folder.

If you use the Claude apps instead, open Settings, go to Capabilities, then Skills, and upload the skill there.

  • Personal: ~/.claude/skills/
  • Project only: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills, then upload
~/.claude/skills/

Trigger the skill with natural requests

You do not need a special command. The skill's description tells the agent when to use it, so ordinary requests about slow queries, execution plans or database performance should trigger it. Describe the symptom and give the agent access to what it needs, such as your connection or pasted EXPLAIN output.

Good requests name the database, the query or endpoint, and what you have already measured. The skill also lists trigger phrases such as slow query, query performance, index optimization and EXPLAIN ANALYZE, so using those words helps.

  • "This orders query takes 4 seconds in PostgreSQL. Here is the EXPLAIN ANALYZE output. Find the bottleneck."
  • "Our MySQL endpoint for customer search is slow. Check the performance_schema for the worst statements and propose indexes."
  • "Review this index plan for the orders table and tell me how to add it without locking production."
  • "Suggest PostgreSQL configuration changes for a server with lock contention during peak hours."

Prerequisites and what the agent needs

The skill itself has no software to install. Its examples depend on the database features they use. The top-slow-query example for PostgreSQL requires the pg_stat_statements extension. The MySQL examples require performance_schema to be enabled.

The agent needs database access with rights to run EXPLAIN ANALYZE and read statistics views. If you cannot give it a connection, paste the relevant output yourself.

  • PostgreSQL with pg_stat_statements for the top-slow-query example
  • MySQL with performance_schema enabled for the MySQL examples
  • Rights to run EXPLAIN ANALYZE and read statistics views, or pasted output
  • The skill runs no scripts and uses no network access, according to its listing

Safety: test first and review every change

The skill says changes should be tested in non-production first, and that you should revert immediately if write performance degrades or replication lag increases. Index and configuration changes can slow writes and affect replication, so treat each suggestion as a proposal.

The skill gives SQL and commands but does not restrict what the agent executes. Do not let the agent run statements against a live database without reviewing them yourself. Where the skill asks for CREATE INDEX CONCURRENTLY on PostgreSQL, that is intended to avoid table locks, but you should still confirm it on a staging copy first.

  • Use a staging copy of the database before applying anything
  • Read each SQL statement before running it
  • Apply one change at a time and measure before and after
  • Watch write performance and replication lag after each change

Tips for better results

Give a baseline up front. The skill is built around measured before-and-after comparisons, so a query time and an EXPLAIN ANALYZE plan will get you much more useful advice than a general description.

Ask for one change at a time. The skill says multiple simultaneous changes make the impact impossible to attribute. Also ask the agent to check for redundant indexes, since the skill warns against them.

  • Include the full EXPLAIN (ANALYZE, BUFFERS) output where possible
  • Ask for validation queries so you can confirm the improvement
  • Ask for a monitoring checklist once the fix is in place

What people use it for

  • Finding the top slow queries in a PostgreSQL database using pg_stat_statements
  • Reading an EXPLAIN ANALYZE plan to find a Seq Scan on a large table and proposing an index
  • Checking MySQL performance_schema for the worst statements and reviewing execution plans with EXPLAIN FORMAT=JSON
  • Planning an index change that is meant to be created without locking production tables
  • Reviewing InnoDB buffer pool settings and cache hit ratios on a MySQL server

Frequently asked questions

Is the Database Optimizer skill free?

The skill is published under the MIT licence, as stated on its listing. Check the licence file in the download for the full terms. You still need your own agent access and database.

What databases does the skill support?

It covers PostgreSQL and MySQL. The skill does not cover other databases such as SQL Server or Oracle, so do not rely on it for those.

Do I need pg_stat_statements?

Only for the PostgreSQL top-slow-query example. The skill's listing says that example requires the pg_stat_statements extension. Other techniques like EXPLAIN ANALYZE do not depend on it.

Does the skill run scripts or access the internet?

According to its listing, the skill runs no scripts and uses no network access. The agent still needs database access, which you provide, to read plans and statistics.

How is this different from just asking an AI for index advice?

The skill gives the agent a fixed workflow: baseline first, one change at a time, validation queries and monitoring. It also includes reference notes on PostgreSQL tuning, MySQL tuning, index strategies, query optimization and monitoring.

Can the agent change my production database by itself?

The skill does not restrict what the agent executes, so it could try to run statements if you allow it. Keep a human in the loop, test on a staging copy and review every statement first.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you are a backend developer, DBA or data engineer working on slow queries or index and config tuning in PostgreSQL or MySQL, and you want a disciplined, measured process. Pick something else if your database is SQL Server, Oracle or another system, or if you want an agent to run changes on production without review.

Download the skill