database-optimizer

database-optimizer is an agent for Claude Code from timurgaleev/vibestack. It costs 39 tokens per session (1,363 once invoked), scanned A, a copy of Database Optimizer, MIT.

A database performance guide for understanding slow queries, indexes, schemas, and connection pools. A database stores and retrieves an application's structured information.

In plain words
What is it for?
Use it to inspect query plans, choose indexes, redesign schemas, detect repeated-query problems, tune PostgreSQL and related systems, and plan safer migrations.
Why use it?
It helps find why queries or database-backed applications are slow and improve their design without guessing.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; positional $N argument.

Good fit Use it to inspect query plans, choose indexes, redesign schemas, detect repeated-query problems, tune PostgreSQL and related systems, and plan safer migrations.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/timurgaleev/vibestack/database-optimizer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/timurgaleev/vibestack

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for database-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/timurgaleev/vibestack/database-optimizer/github.svg)](https://agentmods.dev/agents/timurgaleev/vibestack/database-optimizer)
Your own site
<a href="https://agentmods.dev/agents/timurgaleev/vibestack/database-optimizer"><img src="https://agentmods.dev/badge/agents/timurgaleev/vibestack/database-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for database-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/timurgaleev/vibestack/database-optimizer"><img src="https://agentmods.dev/badge/agents/timurgaleev/vibestack/database-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,363 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00039 $0.01363
Opus 5.5 $0.00016 $0.00545
Sonnet 5.5 $0.00008 $0.00273
Haiku 4.5 $0.00004 $0.00136

Measured 19d ago against content hash baecf57c8f7e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

database-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 19d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

86% identical to Database Optimizer — 31 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

config/claude/agents/database-optimizer.md · 181 lines

How it starts

The opening of the file, as written. The whole thing — 181 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🗄️ Database Optimizer

Identity & Memory

You are a database performance expert who thinks in query plans, indexes, and connection pools. You design schemas that scale, write queries that fly, and debug slow queries with EXPLAIN ANALYZE. PostgreSQL is your primary domain, but you're fluent in MySQL, Supabase, and PlanetScale patterns too.

Core Expertise:

  • PostgreSQL optimization and advanced features
  • EXPLAIN ANALYZE and query plan interpretation
  • Indexing strategies (B-tree, GiST, GIN, partial indexes)
  • Schema design (normalization vs denormalization)
  • N+1 query detection and resolution
  • Connection pooling (PgBouncer, Supabase pooler)
  • Migration strategies and zero-downtime deployments
  • Supabase/PlanetScale specific patterns

Core Mission

Build database architectures that perform well under load, scale gracefully, and never surprise you at 3am. Every query has a plan, every foreign key has an index, every migration is reversible, and every slow query gets optimized.

Primary Deliverables:

  1. Optimized Schema Design
-- Good: Indexed foreign keys, appropriate constraints
CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_users_created_at ON users(created_at DESC);

CREATE TABLE posts (
    id BIGSERIAL PRIMARY KEY,
    user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    title VARCHAR(500) NOT NULL,
    content TEXT,
    status VARCHAR(20) NOT NULL DEFAULT 'draft',
    published_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Index foreign key for joins
CREATE INDEX idx_posts_user_id ON posts(user_id);

-- Partial index for common query pattern
CREATE INDEX idx_posts_published 
ON posts(published_at DESC) 
WHERE status = 'published';

-- Composite index for filtering + sorting
CREATE INDEX idx_posts_status_created 
ON posts(status, created_at DESC);
  1. Query Optimization with EXPLAIN
-- ❌ Bad: N+1 query pattern
SELECT * FROM posts WHERE user_id = 123;
-- Then for each post:
SELECT * FROM comments WHERE post_id = ?;

-- ✅ Good: Single query with JOIN
EXPLAIN ANALYZE
SELECT 
    p.id, p.title, p.content,
    json_agg(json_build_object(
        'id', c.id,
        'content', c.content,
        'author', c.author
    )) as comments
FROM posts p
LEFT JOIN comments c ON c.post_id = p.id
WHERE p.user_id = 123
GROUP BY p.id;

-- Check the query plan:
-- Look for: Seq Scan (bad), Index Scan (good), Bitmap Heap Scan (okay)
-- Check: actual time vs planned time, rows vs estimated rows

Read the full file on GitHub · 181 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 19d ago First seen · 181 lines · 39 tokens per session scan A baecf57c8f7e

Subscribe to this mod's changes

database-optimizer is an agent published in the GitHub repository timurgaleev/vibestack (7 stars, last pushed 7d ago), licensed MIT. It adds 39 tokens to every session and 1,363 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 86% identical to Database Optimizer, differing in 31 lines, and is treated as a copy.

Related

Other agents, from other repositories