.agents/skills/new-model/SKILL.md
Scaffold a new Mongoose model and its CRUD service for the WealthWise API. Triggers when asked to "create a model", "add a Mongoose schema", or add the data layer for a new entity without a full endpoint. Does NOT scaffold routes, controllers, or frontend code. Use $api-endpoint for the full stack.
npx skillsauth add hoangsonww/WealthWise-Finance-Tracker new-modelInstall 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.
Scaffold a new Mongoose model with its full CRUD service.
The entity name is provided in the task prompt.
apps/api/src/models/<entity>.model.tsimport { Schema, model, Document, Types } from 'mongoose';
export interface I<Entity> extends Document {
userId: Types.ObjectId;
// entity-specific fields
createdAt: Date;
updatedAt: Date;
}
const <entity>Schema = new Schema<I<Entity>>(
{
userId: {
type: Schema.Types.ObjectId,
ref: 'User',
required: true,
index: true,
},
// entity fields
},
{
timestamps: true, // handles createdAt/updatedAt automatically
toJSON: { virtuals: true },
toObject: { virtuals: true },
}
);
// All indexes defined here — never outside the schema file
<entity>Schema.index({ userId: 1, createdAt: -1 });
export const <Entity>Model = model<I<Entity>>('<Entity>', <entity>Schema);
apps/api/src/services/<entity>.service.tsFive methods, fully typed:
get<Entity>s(userId: string): Promise<I<Entity>[]>
{ userId: new Types.ObjectId(userId) }get<Entity>ById(id: string, userId: string): Promise<I<Entity>>
ApiError.notFound('<Entity> not found') if not found — never return nullcreate<Entity>(userId: string, data: Create<Entity>Input): Promise<I<Entity>>
userId to the document before savingupdate<Entity>(id: string, userId: string, data: Update<Entity>Input): Promise<I<Entity>>
_id and userId — throw ApiError.notFound if missing{ new: true } in findOneAndUpdatedelete<Entity>(id: string, userId: string): Promise<void>
_id and userId — throw ApiError.notFound if missingApiError from utils/api-error.ts — never throw new Error(...)userId as a filter — no cross-user accessnew Types.ObjectId(userId) when building ObjectId filtersApiError.internal(...)any.npx turbo lint --filter=@wealthwise/api
List all created file paths and the five service method signatures.
development
Run the WealthWise test suite with coverage reporting and summarize the results. Triggers when asked to "run tests with coverage", "check test coverage", "show coverage report", or "how many tests pass". Can be scoped to api, web, or types.
testing
Run the full WealthWise pre-PR checklist and report a pass/fail for each gate. Triggers when asked to "run pre-PR checks", "check if this is ready to merge", "validate before opening a PR", or "run the full check". Does NOT trigger implicitly.
development
Scaffold a complete new Next.js dashboard page for the WealthWise web app. Triggers when asked to "add a page", "create a dashboard screen", "build a UI for <feature>", or scaffold any new frontend feature end-to-end. Does not trigger for API-only or backend tasks.
development
Check the health of the running WealthWise API, web app, and MongoDB services. Triggers when asked to "check if the app is running", "verify the API is up", "is the server healthy", or "show service status".