Skip to content
Agentmart
Submit a tool

backend-service

Skill by davidleonmayor

IndexedMIT★ 3
Write a review

Chalk Labs

Need help deploying backend-service?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/davidleonmayor-backend-service

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

The publisher has not written a description yet.

Use cases: backend

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions: not checked yet.

What's inside

Skill name
backend-service
Description
None
License
MIT
Instructions
224 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Agent Skills spec issues

  • missing YAML frontmatter
  • name: missing
  • description: missing

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Backend Service

## Overview
This skill defines the convention for backend service classes that interact with external resources (Database, Email, Redis, Webhooks, External APIs, etc.). Services encapsulate business logic and data access, keeping controllers thin and focused on HTTP concerns.

## Trigger
When creating or updating service classes for backend features (e.g., `auth.service.ts`, `webhook.service.ts`, `email.service.ts`).

## Do's

- **Use Classes**: Define services as classes (e.g., `AuthService`, `WebhookService`). Export a single class per file.
- **Singleton or Instance**: For database services, import `prisma` singleton from `../config/prisma`. For external services, initialize in constructor or import configured clients.
- **Try-Catch Every Public Method**: Wrap ALL external calls (DB, API, Email) in `try-catch` blocks. Log the raw error with context and throw a user-friendly error message.
- **Use Logger**: Import `logger` from `../config` and log errors properly: `logger.error("Error doing X:", error)`. Never use `console.log` or `console.error` in production code.
- **Specific Error Messages**: Throw errors with clear, user-facing messages in Spanish. For known error codes (like Prisma's `P2002`), check `error.code` and provide specific messages.
- **Async/Await**: Use `async/await` for all methods that perform I/O operations. Mark method signatures with `async` and return `Promise<T>`.
- **Single Responsibility**: A service method should do ONE thing (e.g., `findUserByEmail`, `createUser`). Don't mix concerns.
- **Type Safety**: Define proper return types. If using Prisma, use `Prisma.modelGetPayload<{}>`, `Prisma.modelWhereUniqueInput`, or the resulting model type. Avoid `any`.
- **Dependency Injection**: Receive dependencies (like `prisma`, email clients, redis) via constructor parameters or import them as singletons from `config/`.

## Don'ts

- **Don't handle HTTP/Response logic**: Services must NEVER call `res.status()`, `res.json()`, or send HTTP responses. That's the Controller's job.
- **Don't import Express types**: Services should not import `Request` or `Response` from `express`.
- **Don't have empty catch blocks**: Always log the error and re-throw (or throw a new meaningful error).
- **Don't return `any` type**: Define proper return types. Use TypeScript strict mode.
- **Don't put validation logic**: Data validation (types, lengths, formats) belongs in `*.schema.ts` (using `express-validator`), not in the service.
- **Don't use `console.log/error`**: Always use the `logger` from `config/`.
- **Don't mix service types**: A service should focus on ONE type of external resource (DB, Email, Redis). Don't mix DB calls with email sending in the same method unless it's orchestration.

## Example Structure

### Database Service (e.g., AuthService)

```typescript
import { prisma } from "../config/prisma";
import { logger } from "../config";
import type { Prisma } from "@prisma/client";

export class AuthService {
  /**
   * Creates a new user in the database.
   * @param email - User's email address
   * @param password - Plain text password (will be hashed)
   * @returns The created user object
   */
  async createUser(email: string, password: string): Promise<Prisma.personaGetPayload<{}>> {
    try {
      const hashedPassword = await hashPassword(password);
      
      const user = await prisma.persona.create({
        data: {
          correo_electronico: email.toLowerCase().trim(),
          password: hashedPassword,
          // ... other fields
        },
      });
      
      return user;
    } catch (error: any) {
      logger.error("Error al crear usuario:", error);
      
      // Handle specific Prisma errors
      if (error.code === "P2002") {
        throw new Error("El correo electrónico ya está registrado.");
      }
      
      throw new Error("Error al crear el usuario en la base de datos.");
    }
  }

  /**
   * Finds a user by their email address.
   * @param email - Email to search for
   * @returns User object or null if not found
   */
  async findUserByEmail(email: string): Promise<Prisma.personaGetPayload<{}> | null> {
    try {
      return await prisma.persona.findUnique({
        where: { correo_electronico: email },
      });
    } catch (error) {
      logger.error("Error al buscar usuario por email:", error);
      throw new Error("Error al consultar el usuario en la base de datos.");
    }
  }
}
```

### External Service (e.g., WebhookService, EmailService)

```typescript
import { logger } from "../config";
import { prisma } from "../config/prisma";
import type { WebhookSubscription } from "@prisma/client";

export class WebhookService {
  private readonly timeout: number = 5000;

  /**
   * Dispatches an event to all active webhook subscriptions.
   * @param topic - The event topic (e.g., "MESSAGE_CREATED")
   * @param payload - The event payload to send
   */
  async dispatch(topic: string, payload: Record<string, unknown>): Promise<void> {
    try {
      const subscriptions = await prisma.webhook_subscription.findMany({
        where: { topic, is_active: true },
      });

      if (subscriptions.length === 0) {
        logger.info(`[WebhookService] No active subscriptions for topic: ${topic}`);
        return;
      }

      logger.info(`[WebhookService] Dispatching ${topic} to ${subscriptions.length} subscribers`);

      // Fire and forget with error handling
      for (const sub of subscriptions) {
        this.sendPayload(sub.url, payload, sub.secret).catch((err) => {

From davidleonmayor/proyecto-grado-unimayor, MIT.

Signals

Stars
3
Forks
0
Open issues
1
Last commit (this folder)
May 2, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from davidleonmayor

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get backend-service running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying backend-service?

CallGet help
Cite this page

backend-service skill. Agent Mart. https://agentmart.dev/skills/davidleonmayor-backend-service (last updated 2026-10-24)