Agent skill
mongoid
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/mongoid
SKILL.md
Skill: mongoid
What I do
- Document Modelling: Design document structures using fields, embedding, and referencing.
- Querying: Build complex queries and aggregations using Mongoid's criteria API.
- Associations: Manage relationships (embeds_one/many, has_many, belongs_to).
- Atomic Operations: Perform efficient updates (inc, set, push, pull) without full document rewrites.
- Optimisation: Design indices and implement eager loading (includes) to prevent N+1 queries.
When to use me
- Building Ruby/Rails applications with MongoDB.
- Storing hierarchical or flexible-schema data.
- Implementing complex aggregations or geospatial queries.
- Optimising MongoDB performance in a Ruby environment.
Core principles
- Embedding vs Referencing: Prefer embedding for 1-to-few/static data; reference for 1-to-many/unbounded data.
- ActiveModel Integration: Leverage Rails-style validations and callbacks for data integrity.
- Atomic Persistence: Use
inc,set, andpushto avoid race conditions. - Index Strategy: Ensure all frequent query patterns are covered by background indices.
Patterns & examples
Document Definition (Ruby)
class Order
include Mongoid::Document
include Mongoid::Timestamps
field :status, type: String, default: 'pending'
field :total, type: BigDecimal
belongs_to :user
embeds_many :line_items
index({ user_id: 1, created_at: -1 }, { background: true })
end
Anti-patterns to avoid
❌ Over-Embedding: Unbounded document growth causing performance degradation.
❌ N+1 Queries: Not using .includes(:association) for referenced documents.
❌ Missing Indices: Performing full collection scans on frequent queries.
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Database-Persistence/Mongoid.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?