reference-field-manager

Automate embedded reference field lifecycle between Express.js and MongoDB resources.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/spuneiartur/claude-agent-specs --skill reference-field-manager
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: reference-field-manager
Source: https://github.com/spuneiartur/claude-agent-specs/tree/main/express-js/skills/skills/reference-field-manager
Command: npx skills add https://github.com/spuneiartur/claude-agent-specs --skill reference-field-manager

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill ensures data integrity by managing the full lifecycle of embedded reference fields between two Express.js + MongoDB resources. When a referencing model uses fields from a referenced model, missing any part of the reference lifecycle (schemas, validation, trails, usage checks) can lead to hard-to-trace data inconsistencies.

Core Features & Use Cases

  • Generate and wire Mongoose ref schemas (models/schemas) and Yup ref schemas for the referenced entity.
  • Update the referencing model validation and trails to propagate changes when the referenced document is updated or deleted.
  • Add usage checks and route groundwork (normalization) to prevent orphaned references across controllers.
  • Real-world use: connect Product and Category by embedding a category reference with id, name, and slug, and keep all dependent docs in sync.

Quick Start

Identify the Referencing model (A) and Referenced model (B), then generate the ref schemas, trail functions, and controller wiring following the workflow.

Frequently Asked Questions about reference-field-manager

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage embedded Mongoose references across multiple Express models?

To maintain data integrity for embedded references, you need to wire Mongoose ref schemas, apply Yup validations, and implement trail functions. This ensures referencing models stay synchronized when a referenced document is updated or deleted.

How do I prevent orphaned references in MongoDB when a referenced document is deleted?

To prevent orphaned references, you implement usage checks and route middleware groundwork across controllers. This normalizes deletion workflows and automatically cleans up dependent document trails when a referenced MongoDB collection entry is removed.

How does Yup validation work with Mongoose ref schemas for embedded fields?

Yup validation works alongside Mongoose ref schemas by enforcing structural integrity for embedded reference fields. Generating Yup ref schemas for the referenced entity ensures incoming data matches the expected shape before reaching the MongoDB database layer.

Can I use this approach to keep a Product model in sync with a Category reference?

Yes, you can connect Product and Category resources by embedding a category reference with id, name, and slug. The workflow automatically updates validation trails and propagates changes to all dependent documents when the Category data changes.

What is the best way to update reference trails when a MongoDB document changes?

The best way to update reference trails is by coordinating lifecycle events between two Express.js and MongoDB resources. You generate specific trail functions that automatically propagate field updates from the referenced model to all referencing models.