Claude-skill-registry implementing-service-layer

Defines a pattern for abstracting Appwrite database calls into dedicated service files. Use to keep components clean and reusable.

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/implementing-service-layer" ~/.claude/skills/majiayu000-claude-skill-registry-implementing-service-layer && rm -rf "$T"
manifest: skills/data/implementing-service-layer/SKILL.md
source content

Appwrite Service Layer Pattern

When to use this skill

  • Before writing database logic in a component.
  • When a database query needs to be reused across multiple pages or actions.

Folder Structure

  • services/tours.ts
  • services/bookings.ts
  • services/auth.ts

Example Pattern

import { databases, DATABASE_ID, COLLECTIONS } from '@/lib/appwrite';
import { Query } from 'appwrite';
import { Tour } from '@/types';

export const TourService = {
    async getAll(limit = 10) {
        return await databases.listDocuments<Tour>(
            DATABASE_ID,
            COLLECTIONS.TOURS,
            [Query.limit(limit), Query.orderDesc('$createdAt')]
        );
    },
    async getById(id: string) {
        return await databases.getDocument<Tour>(DATABASE_ID, COLLECTIONS.TOURS, id);
    }
};

Instructions

  • Abstraction: Components should call
    TourService.getAll()
    rather than the Appwrite SDK directly.
  • Error Handling: Catch errors in the service or re-throw them with descriptive messages.