Db Explore
by Andrew1326
MongoDB database exploration for understanding game data, debugging, and investigation. Auto-applies when discussing database structure or debugging data issues.
Skill Details
Repository Files
1 file in this skill directory
name: db-explore description: MongoDB database exploration for understanding game data, debugging, and investigation. Auto-applies when discussing database structure or debugging data issues. allowed-tools: Bash, Read
DB Explore Skill
MongoDB exploration for OpenCivilizations game.
Database Collections
| Collection | Purpose |
|---|---|
| users | Player accounts and authentication |
| bases | Player base layouts and buildings |
| clans | Alliance/clan data |
| battles | Battle replays and results |
| leaderboards | Rankings cache |
MongoDB Shell Commands
Connect
mongosh "mongodb://localhost:27017/dominations"
List Collections
db.getCollectionNames()
Sample Documents
// Get sample user
db.users.findOne()
// Get sample base with buildings
db.bases.findOne({}, { buildings: { $slice: 5 } })
// Get recent battles
db.battles.find().sort({ createdAt: -1 }).limit(5)
Count Documents
// Total users
db.users.countDocuments()
// Active players (last 7 days)
db.users.countDocuments({ lastLogin: { $gte: new Date(Date.now() - 7*24*60*60*1000) } })
Find Documents
// Find user by name
db.users.findOne({ username: "player1" })
// Find bases with specific building
db.bases.find({ "buildings.type": "townCenter" })
// Find clan members
db.clans.findOne({ name: "Warriors" }, { members: 1 })
Aggregations
// Count buildings by type across all bases
db.bases.aggregate([
{ $unwind: "$buildings" },
{ $group: { _id: "$buildings.type", count: { $sum: 1 } } },
{ $sort: { count: -1 } }
])
// Average resources per player
db.users.aggregate([
{ $group: {
_id: null,
avgGold: { $avg: "$resources.gold" },
avgFood: { $avg: "$resources.food" }
}}
])
Common Queries
Player Investigation
// Get player with full base
db.users.aggregate([
{ $match: { username: "player1" } },
{ $lookup: {
from: "bases",
localField: "_id",
foreignField: "userId",
as: "base"
}}
])
Battle Analysis
// Get battle with attacker and defender info
db.battles.aggregate([
{ $match: { _id: ObjectId("...") } },
{ $lookup: { from: "users", localField: "attackerId", foreignField: "_id", as: "attacker" } },
{ $lookup: { from: "users", localField: "defenderId", foreignField: "_id", as: "defender" } }
])
Leaderboard
// Top 10 by trophies
db.users.find({}, { username: 1, trophies: 1 })
.sort({ trophies: -1 })
.limit(10)
Important Notes
- Read-only - Never modify production data
- Use limits - Large collections need
.limit() - Index awareness - Check indexes before heavy queries
- Redis for sessions - Active game state is in Redis, not MongoDB
Related Skills
Xlsx
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
Clickhouse Io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
Clickhouse Io
ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
Analyzing Financial Statements
This skill calculates key financial ratios and metrics from financial statement data for investment analysis
Data Storytelling
Transform data into compelling narratives using visualization, context, and persuasive structure. Use when presenting analytics to stakeholders, creating data reports, or building executive presentations.
Kpi Dashboard Design
Design effective KPI dashboards with metrics selection, visualization best practices, and real-time monitoring patterns. Use when building business dashboards, selecting metrics, or designing data visualization layouts.
Dbt Transformation Patterns
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.
Sql Optimization Patterns
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.
Anndata
This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.
Xlsx
Spreadsheet toolkit (.xlsx/.csv). Create/edit with formulas/formatting, analyze data, visualization, recalculate formulas, for spreadsheet processing and analysis.
