Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计异常

mongodbMongoDB 数据库

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

606

周安装

25

GitHub Stars

12

下载量

198
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:mongodb(MongoDB 数据库)
来源仓库:https://github.com/claude-dev-suite/claude-dev-suite
仓库路径:skills/mongodb
安装命令:
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill mongodb
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill mongodb

简介

mongodb 用于辅助数据库表结构、查询语句和数据维护任务,适合分析 schema 和编写聚合操作。

  • 它提供 CRUD 操作示例、索引优化和事务处理模式,支持复杂的数据分析和报表需求。
  • 使用时需明确连接环境和目标集合,区分只读分析与写入变更;涉及批量删除时应优先事务保护。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。
  • mongodb 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

MongoDB Core Knowledge

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: mongodb for comprehensive documentation.

CRUD Operations

// Create
db.users.insertOne({
  name: "John",
  email: "john@example.com",
  createdAt: new Date()
});

// Read
db.users.find({ isActive: true })
  .sort({ createdAt: -1 })
  .limit(20);

db.users.findOne({ _id: ObjectId("...") });

// Update
db.users.updateOne(
  { _id: ObjectId("...") },
  { $set: { name: "Jane" } }
);

// Delete
db.users.deleteOne({ _id: ObjectId("...") });

Query Operators

// Comparison
{ age: { $gt: 18, $lt: 65 } }
{ status: { $in: ["active", "pending"] } }

// Logical
{ $and: [{ age: { $gt: 18 } }, { isActive: true }] }
{ $or: [{ status: "admin" }, { role: "moderator" }] }

// Array
{ tags: { $all: ["tech", "news"] } }
{ "scores.0": { $gt: 90 } }

Aggregation Pipeline

db.orders.aggregate([
  { $match: { status: "completed" } },
  { $group: {
      _id: "$userId",
      totalSpent: { $sum: "$amount" },
      orderCount: { $count: {} }
  }},
  { $sort: { totalSpent: -1 } },
  { $limit: 10 }
]);

Indexes

db.users.createIndex({ email: 1 }, { unique: true });
db.users.createIndex({ createdAt: -1 });
db.users.createIndex({ name: "text" }); // Text search

Production Readiness

Security Configuration

// Enable authentication (mongod.conf)
// security:
//   authorization: enabled

// Create admin user
use admin
db.createUser({
  user: "admin",
  pwd: "secure_password",
  roles: ["root"]
});

// Create application user with limited privileges
use mydb
db.createUser({
  user: "app_user",
  pwd: "app_password",
  roles: [
    { role: "readWrite", db: "mydb" }
  ]
});

// Create read-only user for reporting
db.createUser({
  user: "reporter",
  pwd: "reporter_password",
  roles: [{ role: "read", db: "mydb" }]
});
# mongod.conf - Security settings
security:
  authorization: enabled

net:
  ssl:
    mode: requireSSL
    PEMKeyFile: /path/to/mongodb.pem
    CAFile: /path/to/ca.pem

Connection with SSL

// Node.js connection with SSL
const { MongoClient } = require('mongodb');

const client = new MongoClient('mongodb://host:27017', {
  ssl: true,
  sslCA: fs.readFileSync('/path/to/ca.pem'),
  sslCert: fs.readFileSync('/path/to/client.pem'),
  sslKey: fs.readFileSync('/path/to/client.key'),
  authSource: 'admin',
});

Replica Set (High Availability)

// Initialize replica set
rs.initiate({
  _id: "myReplicaSet",
  members: [
    { _id: 0, host: "mongo1:27017", priority: 2 },
    { _id: 1, host: "mongo2:27017", priority: 1 },
    { _id: 2, host: "mongo3:27017", priority: 1 }
  ]
});

// Connection string for replica set
mongodb://mongo1:27017,mongo2:27017,mongo3:27017/mydb?replicaSet=myReplicaSet&readPreference=secondaryPreferred

Backup & Recovery

# mongodump backup
mongodump --uri="mongodb://user:pass@host:27017/mydb" \
  --out=/backup/$(date +%Y%m%d) \
  --gzip

# mongorestore
mongorestore --uri="mongodb://user:pass@host:27017/mydb" \
  --gzip /backup/20240115

# Continuous backup with oplog
mongodump --oplog --out=/backup/full

# Point-in-time recovery
mongorestore --oplogReplay --oplogLimit=1705315200 /backup/full

Performance Tuning

// Index best practices
db.collection.createIndex({ field: 1 }, { background: true });

// Compound indexes for common queries
db.orders.createIndex({ userId: 1, createdAt: -1 });

// TTL index for automatic expiration
db.sessions.createIndex({ createdAt: 1 }, { expireAfterSeconds: 3600 });

// Partial indexes for filtered queries
db.orders.createIndex(
  { status: 1 },
  { partialFilterExpression: { status: { $in: ["pending", "processing"] } } }
);

// Analyze query performance
db.orders.find({ userId: "123" }).explain("executionStats");

Monitoring Metrics

MetricAlert Threshold
Connection count> 80% max
Replication lag> 10 seconds
Query targeting> 1000 docs examined/returned
Cache hit ratio< 95%
Oplog window< 24 hours
Disk usage> 80%

Monitoring Commands

// Server status
db.serverStatus();

// Current operations
db.currentOp({ "active": true, "secs_running": { "$gt": 5 } });

// Replication status
rs.status();

// Index usage stats
db.collection.aggregate([{ $indexStats: {} }]);

// Collection stats
db.collection.stats();

// Database profiler (slow queries)
db.setProfilingLevel(1, { slowms: 100 });
db.system.profile.find().sort({ ts: -1 }).limit(10);

Read/Write Concerns

// Write concern for durability
db.orders.insertOne(order, {
  writeConcern: { w: "majority", j: true, wtimeout: 5000 }
});

// Read concern for consistency
db.orders.find({ userId: "123" }).readConcern("majority");

// Read preference for scaling reads
db.orders.find().readPref("secondaryPreferred");

Sharding (Horizontal Scaling)

// Enable sharding on database
sh.enableSharding("mydb");

// Shard collection with hashed key
sh.shardCollection("mydb.orders", { _id: "hashed" });

// Shard collection with range key
sh.shardCollection("mydb.logs", { timestamp: 1 });

// Check sharding status
sh.status();

Checklist

  • Authentication enabled
  • TLS/SSL encryption enabled
  • Least-privilege user accounts
  • Replica set configured (3+ nodes)
  • Regular mongodump backups
  • Oplog size adequate for recovery window
  • Indexes on query fields
  • Query profiler enabled (slow queries)
  • Write concern: majority + journal
  • Connection pooling configured
  • Monitoring alerts configured
  • Sharding (if > 100GB or high throughput)

When NOT to Use This Skill

  • Relational data with complex joins - Use postgresql or mysql for relational databases
  • Transactions across multiple tables - Use SQL databases with ACID guarantees
  • Full-text search - Use elasticsearch for advanced search features
  • Caching - Use redis for in-memory caching
  • Graph relationships - Consider Neo4j or graph databases

Anti-Patterns

Anti-PatternIssueSolution
Unbounded array growthDocument size limit (16MB), performance degradationUse separate collection or capped arrays
Missing indexes on queriesCollection scans, slow performanceCreate indexes on query fields
Using $lookup excessivelyPoor performance, not optimized for joinsDenormalize data or redesign schema
Storing large binary dataExceeds 16MB limit, slow queriesUse GridFS for files > 16MB
Not using projectionTransfers unnecessary dataSpecify needed fields in projection
Ignoring write concernData loss riskUse majority write concern for important data
Not using read preferenceOverloading primaryUse secondary reads for analytics
Massive embedded documentsHard to query, update complexitySplit into separate collections
Not handling connection poolingConnection exhaustionConfigure proper pool size
Using count() on large collectionsSlow, scans collectionUse countDocuments() or estimatedDocumentCount()

Quick Troubleshooting

ProblemDiagnosticFix
Slow queriesdb.collection.explain("executionStats")Add indexes, check query pattern
High memory usagedb.serverStatus().memIncrease RAM, optimize indexes
Connection pool exhaustedCheck connection countIncrease pool size, fix connection leaks
Replication lagrs.status() and check optimeDateIncrease resources, tune oplog size
Disk space fulldb.stats()Compact collections, increase storage
Index not being usedexplain() shows COLLSCANVerify index exists, check query shape
Write conflictsCheck error logs for writeConflictRetry logic, reduce concurrent updates
Document too largeError: "document is larger than 16MB"Use GridFS or split document

Reference Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.67%
按下载量换算67

Claude

31.1%
按下载量换算62

Cursor

18.66%
按下载量换算37

Gemini CLI

8.77%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills