A Codex skill for designing, implementing, and reviewing Mongoose models in strict TypeScript projects.
The skill emphasizes schema-driven type inference, typed methods and statics, safe population, intentional indexes, and the places where Mongoose inference needs help.
- Automatic schema and hydrated-document inference
- Explicit, inferred ObjectId
_idfields - Literal-union enums from const tuples or const objects
- DTO and input types derived without duplicating schema fields
- Methods, statics, virtuals, query helpers, and middleware
- ObjectId references and typed
populate() - Lean query results
- Index design and production index management
- Model caching in hot-reload and test environments
- Cases that need explicit types, including plugins and post-construction schema changes
The detailed worked example is loaded only when needed, keeping the main skill compact.
Install directly from GitHub with the Codex skill installer:
Install the skill from https://github.com/HamStudy/mongoose-typescript-skill
Or copy mongoose-typescript/ into your Codex skills directory.
Invoke the skill explicitly:
Use $mongoose-typescript to create a Course model with a teacher reference,
typed methods, timestamps, and appropriate indexes.
It should also trigger for Mongoose schema, model, populate, virtual, middleware, and index work in TypeScript projects.
mongoose-typescript/
├── SKILL.md
├── agents/
│ └── openai.yaml
└── references/
└── example.md
The guidance targets Mongoose 9.x with TypeScript strict mode enabled. For an older Mongoose release, check that release's documentation and existing project patterns before applying newer inference behavior.
Keep SKILL.md focused on the decision-making workflow. Put extended examples
and details in references/, link them directly from SKILL.md, and run the
skill validator before submitting changes.
Mongoose behavior changes over time, so verify version-sensitive advice against the official Mongoose TypeScript documentation.