express-js/skills/skills/reference-field-manager/SKILL.md
Manage embedded reference fields between Express.js + MongoDB resources. Creates Mongoose ref schemas, Yup ref schemas, trail update/remove functions, usage check configs, and wires up normalizeDropdownValues middleware. Use this skill whenever the user wants to add a relationship between models, embed a reference, link two resources, add a dropdown field that references another model, or says things like "product should reference category" or "add author to articles". This skill prevents the data integrity bugs that come from missing any part of the reference lifecycle.
npx skillsauth add spuneiartur/claude-agent-specs reference-field-managerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Handles the full lifecycle of adding an embedded reference field between two resources in the Express.js + MongoDB API. When resource A references resource B, there are 5-7 files to create/modify — missing any one causes data integrity bugs that are hard to trace.
Gather:
_id, name, and optionally slug)Read references/ref-schema-examples.md for complete patterns.
models/schemas/ref-{referenced}.jsOnly create if it doesn't already exist. Check first.
import { Types } from 'mongoose';
const {referenced}ModelRef = {
_id: {
type: Types.ObjectId,
ref: '{referenced}',
required: true,
},
name: {
type: String,
required: true,
},
// add other embedded fields as needed
};
export default {referenced}ModelRef;
schemas/ref-{referenced}.jsOnly create if it doesn't already exist.
import * as yup from 'yup';
const {referenced}Ref = yup.object().shape({
_id: yup.string().required('{Referenced} ID is required'),
name: yup.string().required('{Referenced} name is required'),
});
export default {referenced}Ref;
In models/{referencing}.js:
import {referenced}ModelRef from './schemas/ref-{referenced}';{referenced}: {referenced}ModelRef{referenced}s: [{referenced}ModelRef]In schemas/schema-{referencing}.js:
import {referenced}Ref from './ref-{referenced}';{referenced}: {referenced}Ref.required('{Referenced} is required'){referenced}s: yup.array().of({referenced}Ref)Read references/trail-examples.md for complete patterns.
functions/update-{referenced}-trails.jsPropagates changes when the referenced document is updated.
import { {Referencing} } from '../models';
const update{Referenced}Trails = async ({referenced}) => {
for (const Model of [{Referencing}]) {
await Model.updateMany(
{ '{referenced}._id': {referenced}?._id },
{
'{referenced}.$.name': {referenced}?.name,
// update other embedded fields
}
);
}
};
export default update{Referenced}Trails;
For array refs, use the $ positional operator as shown above. For single refs, use direct field assignment:
await Model.updateMany(
{ '{referenced}._id': {referenced}?._id },
{
'{referenced}.name': {referenced}?.name,
}
);
functions/remove-{referenced}-trails.jsCleans up when the referenced document is deleted.
import { {Referencing} } from '../models';
const remove{Referenced}Trails = async ({referenced}Id) => {
for (const Model of [{Referencing}]) {
await Model.updateMany(
{ '{referenced}._id': {referenced}Id },
{ $pull: { {referenced}s: { _id: {referenced}Id } } }
);
}
};
export default remove{Referenced}Trails;
For single refs (not arrays), set the field to null instead of using $pull:
await Model.updateMany(
{ '{referenced}._id': {referenced}Id },
{ '{referenced}': null }
);
In controllers/{referenced}/update.js, add the trail update call after findByIdAndUpdate:
import { update{Referenced}Trails } from '@functions';
// ... after update:
await update{Referenced}Trails(updated);
In controllers/{referenced}/delete.js, add the trail remove call after findByIdAndDelete:
import { remove{Referenced}Trails } from '@functions';
// ... after delete:
await remove{Referenced}Trails(id);
Read references/usage-check-guide.md for the full pattern.
In functions/check-usage.js, add a new entry to USAGE_CONFIGS:
{referenced}: {
entityName: '{Referenced}',
entityNameForError: 'the {referenced}',
modelChecks: [
{
modelName: '{Referencing}',
checks: [
{
queryField: '{referenced}._id',
displayName: '{Referencing}s',
description: 'as {referenced} for {referencing}s',
},
],
},
],
},
Then call checkUsage in controllers/{referenced}/delete.js before deleting:
import { checkUsage } from '@functions';
await checkUsage('{referenced}', id);
In routes/{referencing}.js, add the middleware to POST and PUT routes:
import { normalizeDropdownValues, validate } from '@middleware';
import { {Referenced} } from '@models';
router.post(
'/admin/{referencing}s',
normalizeDropdownValues([{ field: '{referenced}', model: {Referenced} }]),
validate({referencing}Schema),
{Referencing}.create
);
router.put(
'/admin/{referencing}s/:id',
normalizeDropdownValues([{ field: '{referenced}', model: {Referenced} }]),
validate({referencing}Schema),
{Referencing}.update
);
If there are already existing normalizeDropdownValues entries, add to the existing array.
schemas/index.js — add ref schema under // ===== REFERENCE SCHEMAS =====functions/index.js — add trail function exports in A-Z orderreferences/ref-schema-examples.md — Mongoose + Yup ref schemas side by sidereferences/trail-examples.md — Update + remove trail function examplesreferences/usage-check-guide.md — How USAGE_CONFIGS works in check-usage.jstools
Replace with description of the skill and when Claude should use it.
tools
Comprehensive website performance audit and optimization skill. Identifies and automatically fixes performance issues including image optimization, video compression, lazy loading, Core Web Vitals, bundle size, and rendering strategy. Uses Lighthouse (via CLI or MCP when available), ffmpeg for media processing, and the project's existing Image component with blur-up lazy loading. Use this skill whenever the user mentions: website speed, page load time, performance audit, Core Web Vitals, Lighthouse, optimize images, compress videos, lazy loading, LCP, CLS, FID, INP, slow website, speed up, performance optimization, image compression, video optimization, blur placeholder, WebP conversion, media audit, bundle size, or wants to improve their website's loading performance. Also trigger when the user says "my site is slow", "optimize for speed", "reduce load time", "improve performance", or asks about image/video optimization in any context.
tools
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
tools
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.