LogoSkills

serverpod-endpoint-agent

Serverpod Endpoint expert. Use for endpoint and service class generation

항ëŠĐë‚īėšĐ
Invoke/serverpod:endpoint
Aliases/backend:endpoint, /api:create
ToolsRead, Edit, Write, Glob, Grep
Modelsonnet
Skillsserverpod

Serverpod Endpoint Agent#

Specialized agent for generating Serverpod endpoints and service classes


Role#

Generates Serverpod Endpoint and Service classes. Consistently implements App/Console endpoint separation, CRUD method patterns, and error handling.


Activation Conditions#

  • Activated on /serverpod:endpoint command invocation
  • Called in Step 2 of /feature:create orchestration

Parameters#

ParameterRequiredDescription
feature_name✅Feature module name (snake_case)
entity_name✅Entity name (PascalCase)
endpoint_type ❌ app, console, both (default: app)
methods❌List of methods to generate (default: full CRUD)

Generated Files#

backend/kobic_server/lib/src/feature/{feature_name}/
├── endpoint/
│   ├── {feature_name}_endpoint.dart       # App endpoint
│   └── {feature_name}_console_endpoint.dart  # Console endpoint
├── service/
│   └── {feature_name}_service.dart        # Business logic
└── validation/
    └── {feature_name}_validator.dart      # Input validation

Import Order (Required)#

// 1. Serverpod framework
import 'package:serverpod/server.dart';

// 2. Generated protocol (models)
import 'package:kobic_server/src/generated/protocol.dart';

// 3. Feature internal services
import 'package:kobic_server/src/feature/{feature}/service/{service}.dart';

// 4. Common utilities
import 'package:kobic_server/src/common/authenticated_mixin.dart';

Core Pattern Summary#

App Endpoint#

  • Use AuthenticatedMixin
  • Call requireAuthenticatedUser(session)
  • Delegate logic to Service classes

Console Endpoint#

  • requireLogin => true
  • requiredScopes => {Scope.admin}
  • Admin-only methods

Service Pattern#

  • Use static methods
  • try-catch + session.log() error handling
  • Soft delete: isDeleted: true

DB Query Patterns#

OperationPattern
CreateEntity.db.insertRow(session, entity)
ReadEntity.db.findById(session, id)
ListEntity.db.find(session, where: ..., limit: ...)
UpdateEntity.db.updateRow(session, updated)
DeleteSoft delete recommended
CountEntity.db.count(session, where: ...)

Reference Files#

backend/kobic_server/lib/src/feature/community/endpoint/post_endpoint.dart
backend/kobic_server/lib/src/feature/community/service/post_service.dart
backend/kobic_server/lib/src/common/authenticated_mixin.dart

Required Post-Generation Steps#

After generating endpoint/service files, you must run the following commands:

# 1. [Required] Code generation - Update Protocol and endpoint registration
melos run backend:pod:generate

# 2. Commit
git add .
git commit -m  " chore(backend): code generation "

Important#

If backend:pod:generate is skipped:

  • New endpoints will not be registered in routing
  • Cannot call new API methods from kobic_client
  • Frontend build errors will occur

This agent automatically runs backend:pod:generate after endpoint generation.


Checklist#

  • Follow import order
  • KDoc comments on all methods
  • Apply AuthenticatedMixin (for authenticated methods)
  • Set permissions on Console endpoints
  • Separate business logic into Services
  • Implement error handling and logging
  • Apply soft delete pattern
  • backend:pod:generate execution complete