xiaohongshu
xiaohongshu
create-repository
Create repository interface for data access abstraction. Use when adding a new resource that needs database operations, defining CRUD interface, or setting up repository pattern. Triggers on "new repository", "repository interface", "data access layer", "create repository".
Full skill instructions
Creates the repository interface that defines data access operations for an entity. Implementations (MockDB, MongoDB, etc.) will implement this interface.
Location: src/repositories/{entity-name}.repository.ts
Naming: Singular, kebab-case (e.g., note.repository.ts, course.repository.ts)
Create src/repositories/{entity-name}.repository.ts
import type {
{Entity}Type,
Create{Entity}Type,
Update{Entity}Type,
{Entity}QueryParamsType,
{Entity}IdType,
} from "@/schemas/{entity-name}.schema";
import type { PaginatedResultType } from "@/schemas/shared.schema";
import type { UserIdType } from "@/schemas/user.schemas";
export interface I{Entity}Repository {
findAll(params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
findById(id: {Entity}IdType): Promise<{Entity}Type | null>;
create(data: Create{Entity}Type, createdByUserId: UserIdType): Promise<{Entity}Type>;
update(id: {Entity}IdType, data: Update{Entity}Type): Promise<{Entity}Type | null>;
remove(id: {Entity}IdType): Promise<boolean>;
}
Every repository interface should include these standard CRUD methods:
| Method | Parameters | Returns | Description |
|---|---|---|---|
findAll | params: QueryParamsType | Promise<PaginatedResultType<EntityType>> | List with pagination/filtering |
findById | id: EntityIdType | Promise<EntityType | null> | Single entity or null |
create | data: CreateType, userId | Promise<EntityType> | Create and return new entity |
update | id, data: UpdateType | Promise<EntityType | null> | Update and return, or null |
remove | id: EntityIdType | Promise<boolean> | True if deleted |
I{Entity}Repository (e.g., INoteRepository, ICourseRepository){entity-name}.repository.ts (singular, kebab-case)EntityType | null (null if not found)PaginatedResultType<EntityType> (always, even if empty)EntityType (with generated ID and timestamps)EntityType | null (null if entity doesn't exist)boolean (true if deleted, false if not found)Create{Entity}Type + createdByUserId: UserIdTypeid separately (from URL) + Update{Entity}Type (from body){Entity}QueryParamsType for filtering/pagination@/schemas/..., @/repositories/...import type { ... } for type-only importsAdd custom methods based on your system's requirements. Common patterns include:
findByX)Find entities by a specific attribute:
findByStatus(status: StatusType, params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
findByOwner(ownerId: UserIdType, params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
findByCategory(categoryId: CategoryIdType, params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
Operate on multiple entities at once:
// Batch queries
findAllByIds(ids: {Entity}IdType[], params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
findAllByStatus(status: StatusType, params: {Entity}QueryParamsType): Promise<PaginatedResultType<{Entity}Type>>;
// Batch mutations
createMany(data: Create{Entity}Type[], createdByUserId: UserIdType): Promise<{Entity}Type[]>;
updateMany(ids: {Entity}IdType[], data: Update{Entity}Type): Promise<number>; // returns count updated
removeMany(ids: {Entity}IdType[]): Promise<number>; // returns count deleted
removeByOwner(ownerId: UserIdType): Promise<number>; // returns count deleted
Get counts or summaries without fetching full entities:
countByStatus(status: StatusType): Promise<number>;
countByOwner(ownerId: UserIdType): Promise<number>;
import type {
NoteType,
CreateNoteType,
UpdateNoteType,
NoteQueryParamsType,
NoteIdType,
} from "@/schemas/note.schema";
import type { PaginatedResultType } from "@/schemas/shared.schema";
import type { UserIdType } from "@/schemas/user.schemas";
export interface INoteRepository {
// Standard CRUD
findAll(params: NoteQueryParamsType): Promise<PaginatedResultType<NoteType>>;
findById(id: NoteIdType): Promise<NoteType | null>;
create(data: CreateNoteType, createdByUserId: UserIdType): Promise<NoteType>;
update(id: NoteIdType, data: UpdateNoteType): Promise<NoteType | null>;
remove(id: NoteIdType): Promise<boolean>;
// Custom methods (assuming it was needed)
findAllByIds(
ids: NoteIdType[],
params: NoteQueryParamsType,
): Promise<PaginatedResultType<NoteType>>;
}
After creating the interface, create an implementation:
create-mockdb-repository skillcreate-mongodb-repository skillnotes.repository.ts) - use singular (note.repository.ts)xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience