Agent skill
implementing-service-layer
Defines a pattern for abstracting Appwrite database calls into dedicated service files. Use to keep components clean and reusable.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/implementing-service-layer
SKILL.md
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.tsservices/bookings.tsservices/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.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?