Guide · Agent skill
How to use the Fix Slow Database Queries agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The fix-slow-queries skill is an instruction package for an AI coding agent, such as Claude, that is designed to find and fix slow PostgreSQL queries in the Paperclip codebase. It is written for Paperclip maintainers and contributors, and for engineers on Neon-hosted PostgreSQL who need to map a slow endpoint to its database. After reading this guide you will know what the skill makes the agent do, how to install it, how to ask for it in natural language, and what it needs before you start.
Quick start
- 1Download the ZIP. Download the fix-slow-queries ZIP from this page.
- 2Unzip the skill. Unzip it into ~/.claude/skills/ for personal use or into the project's .claude/skills/ folder for one project.
- 3Or upload in the Claude apps. Open Settings, go to Capabilities, choose Skills and upload the package.
- 4Check the prerequisites. Confirm you have a local Paperclip checkout, local PostgreSQL, ripgrep (rg) and, for hosted work, access to paperclip-cloud and Neon.
- 5Describe the slow request. Ask in plain language, naming the slow endpoint, environment and observation time.
- 6Review the evidence and PR. Read the baseline, the output comparison and the test results before you accept the pull request.
What is an agent skill?
An agent skill is a folder containing a SKILL.md file and optional reference files and scripts. When the skill is installed, the agent reads its description and loads the full instructions when a request matches. The skill tells the agent how to work, in what order, and what counts as finished.
This skill's SKILL.md says it applies to costly queries, repeated database work, or slow requests with a suspected database cause.
What does the skill make the agent do?
The skill sets a structured, evidence-first workflow. The agent starts from production evidence such as query statistics and Neon database metadata, traces each slow query back to the code that generates it, reproduces the slowness on a local PostgreSQL with synthetic data, and only then makes a change.
Each change must be shown to be faster and to return identical results. The skill also expects regression tests and passing checks before a pull request is considered done. A list of suspicious SQL is treated as an intermediate result, not a finished job.
- Identify the target URL, environment, deployed revision and owning repository
- Rank the top two or three query families by cost and frequency
- Reproduce the baseline locally with EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) output saved
- Compare baseline and treatment for both performance and correct results
- Verify the blast radius with regression tests and the repository's pre-PR checks
How do you install the skill?
Download the ZIP for fix-slow-queries from this page. Unzip it into one of two locations. For a personal install, use ~/.claude/skills/. For a single project, use the .claude/skills/ folder inside that project.
If you use the Claude apps instead, open Settings, go to Capabilities, and upload the skill under Skills. The package contains agents/openai.yaml, references/cloud-discovery.md, references/local-proof.md and SKILL.md.
- Personal: unzip into ~/.claude/skills/
- Project: unzip into the project's .claude/skills/
- Claude apps: Settings → Capabilities → Skills, then upload
How do you trigger the skill with a natural request?
You do not need a special command. Describe the problem in plain language and mention the slow thing you observed. The skill's description matches requests about costly queries, repeated database work, or slow requests with a suspected database cause.
If you only want an answer and not a fix, say so. The skill says to respect a narrower request for diagnosis only.
- "This workspace task endpoint is slow. Find the database queries behind it and fix them."
- "Investigate the top costly queries in our Paperclip Neon project and propose a measured fix with a PR."
- "Only diagnose the slow history request. Do not change code yet."
What does it need before you run it?
The skill needs a local Git checkout of the Paperclip repository, local PostgreSQL for disposable benchmark databases, and ripgrep (rg) for code search. Hosted diagnosis also requires access to the private paperclip-cloud control plane and the Neon project. The source does not say how those credentials are supplied, so check with your team.
Use it on Paperclip itself. Its paths, rules and tooling are specific to that repository and its private control plane, so it will mislead on other projects.
- Git and a local checkout of the Paperclip repository
- Local PostgreSQL for disposable benchmark databases
- ripgrep (rg)
- Access to paperclip-cloud and the Neon project, for hosted diagnosis only
What are the safety notes for scripts and network use?
This skill runs scripts and uses the network. The benchmark harnesses live in scripts/benchmark-*.ts and packages/db/src. The skill says to inspect a harness before running it, and to use disposable synthetic fixtures.
The skill can involve migrations, schema changes and access to hosted infrastructure. Do not let an agent change a production database directly. Migrations that exceed the roughly one-to-two-minute budget must be flagged for human review, and the skill forbids adding startup scripts, boot-time DDL or recurring backfills to avoid a migration constraint.
- Inspect scripts/benchmark-*.ts before running them
- Run benchmarks only against disposable local PostgreSQL
- Keep human review on any migration, schema change or production-touching step
- Do not treat an interrupted test suite as a pass
What tips help you get good results?
Give the agent the reported URL, environment and a representative slow request, since the skill starts there. Expect a long run: the workflow expects a full fix, branch and pull request, and it will record deferred candidates rather than rewrite everything.
Keep the checkout that runs a live server separate from branch switching and benchmark setup. The skill recommends a dedicated branch or worktree.
- Provide UTC observation times and a specific slow endpoint
- Ask for a bounded batch, such as the top two or three query families
- Read the saved baseline and EXPLAIN output before accepting a fix
- Check that the final commit of the PR passes its checks
What people use it for
- Investigating a slow Paperclip workspace request that the agent maps to its Neon database branch and role
- Ranking the most expensive queries in a hosted window and choosing a bounded batch to fix
- Reproducing a slow query locally with synthetic data and saving EXPLAIN ANALYZE output
- Checking that a query rewrite returns the same columns, ordering and redaction as before
- Preparing a reviewable pull request whose final commit passes the repository's checks
Frequently asked questions
How do I install the fix-slow-queries agent skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. In the Claude apps, you can instead upload it under Settings → Capabilities → Skills.
What do I need to run the fix-slow-queries skill?
You need Git and a local checkout of the Paperclip repository, local PostgreSQL for disposable benchmarks, and ripgrep (rg) for code search. Hosted diagnosis also needs access to the private paperclip-cloud control plane and the Neon project.
Is the fix-slow-queries skill free to use?
The source lists the licence as MIT. Check the repository licence file for the full terms before reuse.
Can I use this skill on a project other than Paperclip?
The source says no. Its paths, rules and tooling are specific to the Paperclip repository and its private control plane, so it would mislead on other projects.
Does the skill change my production database?
The skill involves migrations, schema changes and hosted infrastructure, which carry risk without human review. Treat production changes as something a person must review, and flag any migration that exceeds the timing budget.
What if I only want a diagnosis and not a fix?
Say so in your request. The skill says to respect a narrower request for diagnosis only, though its full workflow is designed for a complete fix, branch and pull request.
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 maintain or contribute to Paperclip and want evidence-first query fixes backed by baseline timings, output comparisons and regression tests. Pick something else for other codebases, quick one-off SQL questions, or any work that would change a production database without human review.
Download the skill