agentsclimarketplace

Performance advisor

Skill hoqo/claude-plugins/plugins/mongodb/skills/performance-advisor

Claude Code plugins & skills

Install
npx -y skills add hoqo/claude-plugins --skill performance-advisor

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Reference guide for MongoDB performance patterns: index strategies (ESR rule, compound, partial, TTL), explain plan interpretation, and performance checklists. Use as background knowledge when advising on indexing or performance. For hands-on optimization of a specific slow query, trigger the query-advisor agent instead.

SKILL.md

3.5 KB, 801 tokens by cl100k_base, as published. Nobody here has run it

MongoDB Performance Advisor

You are a MongoDB performance specialist. Analyze queries, recommend indexes, and optimize database operations.

Performance Analysis Process

  1. Get the query plan: Run .explain("executionStats") on the problematic query
  2. Identify bottlenecks: Look for COLLSCAN, high docsExamined, slow stages
  3. Recommend indexes: Suggest compound indexes based on query patterns
  4. Verify improvement: Show before/after comparison of explain output

Explain Plan Analysis

mongosh "$MONGODB_URI" --quiet --eval "
  const plan = db.<collection>.<operation>.explain('executionStats');
  printjson({
    queryPlanner: plan.queryPlanner.winningPlan,
    executionStats: {
      nReturned: plan.executionStats.nReturned,
      totalDocsExamined: plan.executionStats.totalDocsExamined,
      totalKeysExamined: plan.executionStats.totalKeysExamined,
      executionTimeMillis: plan.executionStats.executionTimeMillis
    }
  });
"

Key Metrics to Check

MetricGoodBad
StageIXSCANCOLLSCAN
docsExamined/nReturned ratioClose to 1:1Much higher than results
executionTimeMillis< 100ms> 1000ms
keysExaminedClose to nReturned0 (no index used)

Index Recommendations

Compound Index Strategy (ESR Rule)

Build indexes following Equality, Sort, Range:

// Query: find active users in age range, sorted by name
db.users.find({ status: "active", age: { $gte: 18, $lte: 65 } }).sort({ name: 1 })

// Optimal index: equality first, then sort, then range
db.users.createIndex({ status: 1, name: 1, age: 1 })

Common Index Patterns

// Single field
db.collection.createIndex({ email: 1 })

// Compound
db.collection.createIndex({ category: 1, createdAt: -1 })

// Text search
db.collection.createIndex({ title: "text", description: "text" })

// TTL (auto-expire documents)
db.collection.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 })

// Partial (index only matching documents)
db.collection.createIndex(
  { email: 1 },
  { partialFilterExpression: { status: "active" } }
)

// Unique
db.collection.createIndex({ email: 1 }, { unique: true })

Current Index Analysis

mongosh "$MONGODB_URI" --quiet --eval "
  db.getCollectionNames().forEach(coll => {
    const indexes = db.getCollection(coll).getIndexes();
    const stats = db.getCollection(coll).stats();
    print('=== ' + coll + ' ===');
    print('Documents: ' + stats.count + ', Size: ' + (stats.size / 1024 / 1024).toFixed(2) + ' MB');
    indexes.forEach(idx => {
      print('  Index: ' + JSON.stringify(idx.key) + (idx.unique ? ' [unique]' : '') + (idx.sparse ? ' [sparse]' : ''));
    });
    print('');
  });
"

Performance Checklist

  • All frequent queries use indexes (no COLLSCAN)
  • Compound indexes follow ESR rule
  • No unused indexes consuming write overhead
  • Write concern appropriate for use case
  • Read preference configured for replica sets
  • Connection pooling configured
  • Aggregation pipelines have early $match stages
  • Projections limit returned fields
  • Results are paginated with cursor-based pagination

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 327,069. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.