agentleFS
seed-forgeseed-forge/harness-ai-kit/skills/public-mongodb-expert-base/SKILL.md

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 继承。

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
  1. Distinctive:

    Use arrays for ordered collections.

    line 16
  2. Distinctive:

    Avoid anti-patterns: unbounded arrays, massive documents (>16MB), excessive nesting.

    line 17
  3. Very specific:

    Use explain() to verify index usage (look for IXSCAN, avoid COLLSCAN).

    line 32
  4. Very specific:

    Use $project early to reduce document size through the pipeline.

    line 41
  5. Distinctive:

    Use connection pooling (built into all official drivers).

    line 46
  6. Very specific:

    Use retryWrites=true and retryReads=true.

    line 49
  7. Distinctive:

    Read from secondaries for analytics/reporting (eventual consistency).

    line 53
  8. Distinctive:

    Never change shard key after collection is sharded (pre-6.0).

    line 55
  9. Very specific:

    Use watch() on collection or database level.

    line 59
  10. Distinctive:

    Never store unbounded arrays in a single document.

    line 64
  11. Very specific:

    Always index fields used in queries — verify with explain().

    line 65
  12. Very specific:

    Use w=majority for critical writes.

    line 66

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

PatternUse for
Embedding1:1, 1:few relationships, always-read-together data
Referencing1:many (unbounded), independent access
BucketTime-series data (group by time window)
TreeHierarchical data (materialized paths, nested sets)
OutlierHandle occasional large documents separately
Extended ReferenceEmbed frequently accessed fields, reference the rest

Indexing

  • Index fields used in queries, sorts, and aggregation $match/$sort stages.
  • Compound index order matters: equality first, then range, then sort.
  • Use explain() to verify index usage (look for IXSCAN, avoid COLLSCAN).
  • 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: $match and $sort first (use indexes).
  • $lookup for joins (prefer embedding when possible).
  • $group for aggregation; $unwind to flatten arrays before grouping.
  • Use $project early to reduce document size through the pipeline.
  • $facet for multiple aggregations in one query.

Connection & Configuration

  • Connection string: mongodb://host:port/db?options
  • Use connection pooling (built into all official drivers).
  • Set w=majority for write concern (durability).
  • Set readPreference=secondaryPreferred for read scaling.
  • Use retryWrites=true and retryReads=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 resumeAfter or startAfter token.
  • 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=majority for critical writes.
  • Set document TTL for temporary data.
  • Monitor slow queries with profiler (db.setProfilingLevel(1, {slowms: 100})).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.