MongoDB taste — промпт для ChatGPT: установка
Промпт MongoDB taste для ChatGPT задаёт правила моделирования MongoDB вокруг запросов, индексов и схем. Подключается к Claude Code через файл команды.
CC0-1.0 ★ 178 201 обновлён 2026-10-24
Открыть на GitHubЧто делает MongoDB taste
Промпт MongoDB taste задаёт подход к проектированию MongoDB вокруг шаблонов чтения приложения. Он помогает решить, какие данные встраивать, какие выносить в отдельную коллекцию, как ограничивать массивы и где добавлять $jsonSchema, версии схемы и TTL-индексы.
Отдельные правила касаются compound indexes, проекций, пагинации по индексированному полю и проверки запросов через explain("executionStats"). Для изменений используются атомарные операторы $inc, $set и $push с $slice, а для отчётов предлагается aggregation pipeline с ранними $match и $project.
Промпт также требует единого клиента с пулом соединений, аутентификации, TLS и ролей с минимальными правами. Локальные тесты должны обращаться к реальному MongoDB в контейнере или replica set, а не к in-memory fake. В Claude Code файл размещается по пути .claude/commands/prompts.csv.md.
Какие задачи решает
- спроектировать коллекции по шаблонам чтения
- решить, какие данные embed, а какие reference
- найти причины COLLSCAN и медленных запросов
- настроить индексы, валидаторы и TTL-очистку
- проверить безопасность подключения к MongoDB
Примеры запросов агенту
- Спроектируй коллекции MongoDB для этих запросов и объясни, что встраивать, а что выносить в ссылки.
- Проверь этот запрос MongoDB: предложи compound index по правилу equality, sort, range и добавь подходящую проекцию.
- Составь правила для production MongoDB с
$jsonSchema, TTL-индексами,w: "majority"и ролями с минимальными правами.
Как установить MongoDB taste
Как использовать
Вставьте текст в начало диалога или в инструкции проекта
Вручную: положить файлы
.claude/commands/prompts.csv.mdВопросы о MongoDB taste
Как установить MongoDB taste в Claude Code?
Разместите файл по пути .claude/commands/prompts.csv.md.
Что делает MongoDB taste?
Промпт помогает проектировать MongoDB вокруг шаблонов чтения, выбирать между embedding и references, задавать валидаторы и индексы, а также проверять запросы и обновления.
Какие требования MongoDB taste предъявляет к локальной разработке?
Локальная разработка и тесты должны использовать реальный MongoDB в контейнере или replica set. In-memory fake не подходит.
Исходный текст
prompts.csv · CC0-1.0
# MongoDB taste of a backend engineer who models documents around queries
- Design each collection around the application's read patterns first, then decide what to embed and what to reference. Confidence: 0.90
- Embed data that is always read together and bounded in size; reference data that grows without limit or is shared widely. Confidence: 0.90
- Never let an array grow unbounded inside a document; move comments, events or logs to their own collection. Confidence: 0.90
- Define a `$jsonSchema` validator on every collection so bad writes fail at the database, not in a report weeks later. Confidence: 0.80
- Store dates as BSON `Date` and money as `Decimal128` or integer minor units, never as strings or doubles. Confidence: 0.90
- Build compound indexes following the equality, sort, range rule and check every hot query with `explain("executionStats")`. Confidence: 0.85
- Treat a `COLLSCAN` on a production query path as a bug, and alert on slow queries from the profiler or Atlas. Confidence: 0.80
- Drop unused and redundant indexes regularly, because each one slows every write and eats memory. Confidence: 0.75
- Use projections in every query so services fetch only the fields they need. Confidence: 0.80
- Paginate with a range on an indexed field such as `_id` or `createdAt`, not with large `skip` values. Confidence: 0.85
- Use `w: "majority"` write concern for important data and `majority` read concern where stale reads would hurt. Confidence: 0.80
- Reach for multi-document transactions only when the model truly needs them; a well-shaped document usually makes the write atomic. Confidence: 0.80
- Prefer atomic update operators like `$inc`, `$set` and `$push` with `$slice` over read-modify-write loops in application code. Confidence: 0.85
- Use the aggregation pipeline for reporting, and put `$match` and `$project` as early as possible so indexes can help. Confidence: 0.80
- Add a `schemaVersion` field and migrate documents lazily on read or with a background job, instead of one risky big-bang script. Confidence: 0.70
- Use TTL indexes for sessions, tokens and temporary data rather than cron jobs that delete old documents. Confidence: 0.85
- Choose shard keys with high cardinality that match the main query filter, and avoid monotonically increasing keys alone. Confidence: 0.75
- Create indexes and validators through versioned migration code in the repo, not by hand in a shell. Confidence: 0.80
- Run local development and tests against a real MongoDB in a container or replica set, not an in-memory fake. Confidence: 0.75
- Keep a single shared client per process with a tuned connection pool instead of opening connections per request. Confidence: 0.90
- Enable authentication, TLS and least-privilege roles everywhere, and never expose port 27017 to the public internet. Confidence: 0.95
- Test restores from backups on a schedule, because a backup nobody has restored is only a hope. Confidence: 0.85
© f · CC0-1.0 · f/prompts.chat