public-mongodb-expert-base
Skill25 starsChanged 4 months agoApache-2.0View on GitHub
MongoDB 知识基座。覆盖 Document Model、Aggregation Pipeline、Indexes、Replica Sets、Change Streams。供 devlab-mongodb-usage 通过 extends 继承。
In this repository57 other files it gives its agents.
- base-cn-registry-mirror-strategySkill
- base-manual-captureSkill
- devlab-ai-agent-engineeringSkill
- devlab-ai-kit-minerSkill
- devlab-cicd-onboardSkill
- devlab-contract-web-serverSkill
- devlab-dao-sql-compatSkill
- devlab-db-data-migrationSkill
- devlab-eval-driven-agentSkill
- devlab-integration-fullstackSkill
- devlab-srv-test-apiSkill
- devlab-tech-debt-opsSkill
- devlab-test-expertSkill
- devlab-test-onboardSkill
- devlab-web-contextSkill
- devlab-web-deep-acceptanceSkill
- devlab-web-echarts-usageSkill
- devlab-web-engineeringSkill
- devlab-web-extension-bootstrapSkill
- devlab-web-skywalking-rum-usageSkill
- devlab-web-test-e2eSkill
- devlab-web-visual-opsSkill
- devlab-web-xyflow-usageSkill
- diag-container-oomSkill
- diag-k8s-node-pressureSkill
- diag-k8s-pod-crashloopSkill
- diag-mysql-deadlockSkill
- diag-mysql-replicationSkill
- diag-mysql-slow-querySkill
- diag-network-port-unreachSkill
- infra-dify-opsSkill
- infra-harbor-opsSkill
- infra-jenkins-pipeline-opsSkill
- infra-nexus-opsSkill
- infra-ragflow-opsSkill
- infra-sonarqube-opsSkill
- infra-system-env-opsSkill
- infra-woodpecker-pipeline-opsSkill
- markitdownSkill
- patent-disclosure-workflowSkill
- patent-reviewSkill
- patent-specification-writerSkill
- public-git-workflow-expert-baseSkill
- public-kafka-expert-baseSkill
- public-mysql-expert-baseSkill
- public-nl2sql-expert-baseSkill
- public-oracle-expert-baseSkill
- public-postgres-expert-baseSkill
- public-rabbitmq-expert-baseSkill
- public-redis-expert-baseSkill
- work-convertSkill
- work-exportSkill
- work-markitdownSkill
- work-sc-document-sop-builderSkill
- work-sc-docx-comment-replySkill
- work-sc-patent-specification-writerSkill
- work-sc-software-copyright-writerSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use arrays for ordered collections.
- Distinctive: line 17
Avoid anti-patterns: unbounded arrays, massive documents (>16MB), excessive nesting.
- Very specific: line 32
Use explain() to verify index usage (look for IXSCAN, avoid COLLSCAN).
- Very specific: line 41
Use $project early to reduce document size through the pipeline.
- Distinctive: line 46
Use connection pooling (built into all official drivers).
- Very specific: line 49
Use retryWrites=true and retryReads=true.
- Distinctive: line 53
Read from secondaries for analytics/reporting (eventual consistency).
- Distinctive: line 55
Never change shard key after collection is sharded (pre-6.0).
- Very specific: line 59
Use watch() on collection or database level.
- Distinctive: line 64
Never store unbounded arrays in a single document.
- Very specific: line 65
Always index fields used in queries — verify with explain().
- Very specific: line 66
Use w=majority for critical writes.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MongoDB Knowledge Base
Foundational guidance for building applications with MongoDB.
Source: Adapted from mongodb/agent-skills (schema-design + query-optimizer + connection).
Document Model
- Design documents around access patterns, not normalization.
- Embed related data that's always read together (1:1, 1:few).
- Reference (DBRef or manual ID) for data that grows unbounded or is accessed independently.
- Use arrays for ordered collections; use sub-documents for named fields.
- Avoid anti-patterns: unbounded arrays, massive documents (>16MB), excessive nesting.
Schema Design Patterns
| Pattern | Use for |
| Embedding | 1:1, 1:few relationships, always-read-together data |
| Referencing | 1:many (unbounded), independent access |
| Bucket | Time-series data (group by time window) |
| Tree | Hierarchical data (materialized paths, nested sets) |
| Outlier | Handle occasional large documents separately |
| Extended Reference | Embed frequently accessed fields, reference the rest |
Indexing
- Index fields used in queries, sorts, and aggregation
$match/$sortstages. - Compound index order matters: equality first, then range, then sort.
- Use
explain()to verify index usage (look forIXSCAN, avoidCOLLSCAN). - Text indexes for full-text search; 2dsphere for geospatial queries.
- TTL indexes for auto-expiring documents.
- Monitor with
$indexStats— drop unused indexes.
Aggregation Pipeline
- Order stages for efficiency:
$matchand$sortfirst (use indexes). $lookupfor joins (prefer embedding when possible).$groupfor aggregation;$unwindto flatten arrays before grouping.- Use
$projectearly to reduce document size through the pipeline. $facetfor multiple aggregations in one query.
Connection & Configuration
- Connection string:
mongodb://host:port/db?options - Use connection pooling (built into all official drivers).
- Set
w=majorityfor write concern (durability). - Set
readPreference=secondaryPreferredfor read scaling. - Use
retryWrites=trueandretryReads=true.
Replica Sets & Sharding
- Replica sets: 3 members minimum (primary + 2 secondaries).
- Read from secondaries for analytics/reporting (eventual consistency).
- Sharding: shard key choice is critical — high cardinality, frequently in queries.
- Never change shard key after collection is sharded (pre-6.0).
Change Streams
- Real-time event processing from oplog.
- Use
watch()on collection or database level. - Resume with
resumeAfterorstartAftertoken. - Filter with aggregation pipeline match.
Guardrails
- Never store unbounded arrays in a single document.
- Always index fields used in queries — verify with
explain(). - Use
w=majorityfor critical writes. - Set document TTL for temporary data.
- Monitor slow queries with profiler (
db.setProfilingLevel(1, {slowms: 100})).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

