Add MongoDB skill to skills folder and update skill index

This commit is contained in:
Connor Rhodes 2026-04-19 01:32:28 +00:00
parent dc26b7fb40
commit e487b28c44
3 changed files with 158 additions and 0 deletions

View file

@ -29,6 +29,7 @@ description: Master index of all skills in your robot assistant system. Your ass
| "review voice notes," "what voice notes do I have," "show me today's voice notes," "review my dictations" | **review-voice-notes** | | "review voice notes," "what voice notes do I have," "show me today's voice notes," "review my dictations" | **review-voice-notes** |
| "proofread this," "proofread my email," "clean up this dictation," "polish this email" | **proofread-business-writing** | | "proofread this," "proofread my email," "clean up this dictation," "polish this email" | **proofread-business-writing** |
| "polish my LinkedIn post," "clean up my LinkedIn draft," "turn this into a LinkedIn post," "edit my LinkedIn post" | **linkedin-post** | | "polish my LinkedIn post," "clean up my LinkedIn draft," "turn this into a LinkedIn post," "edit my LinkedIn post" | **linkedin-post** |
| "use mongodb," "query my database," "add to mongo," "mongo," "database," "docdb" | **mongodb** |
--- ---
@ -136,6 +137,12 @@ description: Master index of all skills in your robot assistant system. Your ass
**File:** `skills/linkedin-post/SKILL.md` **File:** `skills/linkedin-post/SKILL.md`
**Dependencies:** None **Dependencies:** None
### MongoDB
**Purpose:** Interact with the MongoDB instance at docdb.connorrhodes.com. Use this skill whenever the user wants to query, insert, update, or delete data in MongoDB, list databases or collections, explore schema, run aggregations, or do anything involving their database.
**Triggers:** "use mongodb," "query my database," "add to mongo," "mongo," "database," "docdb"
**File:** `skills/mongodb/SKILL.md`
**Dependencies:** Python with `pymongo`, `uv` CLI for dependency management
--- ---
## Adding New Skills ## Adding New Skills

118
mongodb/SKILL.md Normal file
View file

@ -0,0 +1,118 @@
---
name: mongodb
description: Interact with the MongoDB instance at docdb.connorrhodes.com. Use this skill whenever the user wants to query, insert, update, or delete data in MongoDB, list databases or collections, explore schema, run aggregations, or do anything involving their database. Also trigger when the user mentions "mongo", "docdb", or "database" in a context that could involve their self-hosted instance.
version: 1.0.0
---
# MongoDB Interaction
Connect to and interact with the MongoDB instance using Python (`pymongo`) with `uv` for dependency management.
## Connection Details
- **Host**: `docdb.connorrhodes.com`
- **Port**: `35563`
- **Username**: `root`
- **Password**: `3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl`
- **Connection string**: `mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563`
## How to Run Scripts
Always use `uv` with an inline dependency declaration so there's no project setup needed:
```bash
uv run --with pymongo script.py
```
This handles installing pymongo automatically. No venv or requirements.txt needed.
## Pattern for Scripts
Every script should follow this structure. The connection helper at `scripts/connect.py` can be imported to avoid repeating boilerplate — read it and copy it into a standalone script or import it directly:
```python
from pymongo import MongoClient
client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563")
```
### Exploring the database
When the user asks exploratory questions (e.g., "what's in my database?", "show me the data"), start by listing databases and collections to understand what's there before running targeted queries:
```python
from pymongo import MongoClient
client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563")
for db_name in client.list_database_names():
print(f"Database: {db_name}")
db = client[db_name]
for coll_name in db.list_collection_names():
count = db[coll_name].estimated_document_count()
print(f" {coll_name} ({count} docs)")
```
### Querying documents
```python
from pymongo import MongoClient
client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563")
db = client["database_name"]
collection = db["collection_name"]
for doc in collection.find({"field": "value"}).limit(10):
print(doc)
```
### Inserting documents
```python
result = collection.insert_one({"key": "value"})
print(f"Inserted: {result.inserted_id}")
```
For bulk inserts:
```python
result = collection.insert_many([{"key": f"val{i}"} for i in range(100)])
print(f"Inserted {len(result.inserted_ids)} documents")
```
### Updating documents
```python
result = collection.update_one(
{"field": "match_value"},
{"$set": {"field": "new_value"}}
)
print(f"Matched: {result.matched_count}, Modified: {result.modified_count}")
```
### Deleting documents
```python
result = collection.delete_many({"field": "value"})
print(f"Deleted: {result.deleted_count}")
```
### Aggregation pipeline
```python
pipeline = [
{"$group": {"_id": "$category", "count": {"$sum": 1}}},
{"$sort": {"count": -1}}
]
for doc in collection.aggregate(pipeline):
print(doc)
```
## Guidelines
- Always use `uv run --with pymongo` to execute scripts — no manual venv or pip.
- For one-off queries, write the script inline and run it directly. Don't create persistent files unless the user asks.
- When exploring an unfamiliar database, list databases and collections first with document counts, then sample a few documents from relevant collections before running the user's actual query.
- Use `.limit()` when previewing data to avoid dumping huge result sets.
- For large results, consider using `.count_documents(filter)` first to warn the user about scale.
- Pretty-print documents with `pprint` or JSON formatting for readability.
- Close the client when done: `client.close()` — though for short scripts this isn't strictly necessary.

View file

@ -0,0 +1,33 @@
from pymongo import MongoClient
MONGODB_URI = "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563"
def get_client():
return MongoClient(MONGODB_URI)
def get_db(db_name):
return MongoClient(MONGODB_URI)[db_name]
def get_collection(db_name, collection_name):
return MongoClient(MONGODB_URI)[db_name][collection_name]
def list_databases():
client = get_client()
for db_name in client.list_database_names():
db = client[db_name]
collections = []
for coll_name in db.list_collection_names():
count = db[coll_name].estimated_document_count()
collections.append(f"{coll_name} ({count} docs)")
print(f"Database: {db_name}")
for c in collections:
print(f" {c}")
client.close()
if __name__ == "__main__":
list_databases()