Menu

Post image 1
Post image 2
1 / 2
0

CLAUDE.md for MongoDB: 13 Rules That Make AI Write Safe, Scalable Document Queries

DEV Community·Olivia Craft·28 days ago
#4HW4qnld
Reading 0:00
15s threshold

You ask Claude to "store the user and their last 10 orders," and 30 seconds later you ship something that looks fine in review: Orders embedded in the user document — until a power user has 9,000 of them and you hit the 16 MB document limit at 3 a.m. A find({ email }) query with no index — COLLSCAN over 50 million docs every login. new MongoClient(uri) inside the request handler — your Atlas dashboard shows 4,000 connections and the cluster starts dropping new ones. db.users.find({ role: req.query.role }) — and someone passes { "$ne": null } to dump every user in the database. The model didn't fail. It pattern-matched on tutorials where MongoDB is a toy with twelve documents and zero ops concerns. Production makes each one a real incident. A CLAUDE.md at the root of your repo fixes this. Claude Code reads it on every task. Cursor, Aider, and Copilot do the same. Below are four of the thirteen rules I drop into every MongoDB project — full set in the free gist linked at the end.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More