| íëŠĐ | ëīėĐ |
|---|---|
| Invoke | /serverpod:endpoint |
| Aliases | /backend:endpoint, /api:create |
| Tools | Read, Edit, Write, Glob, Grep |
| Model | sonnet |
| Skills | serverpod |
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:endpointcommand invocation - Called in Step 2 of
/feature:createorchestration
Parameters#
| Parameter | Required | Description |
|---|---|---|
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 => truerequiredScopes => {Scope.admin}- Admin-only methods
Service Pattern#
- Use static methods
- try-catch +
session.log()error handling - Soft delete:
isDeleted: true
DB Query Patterns#
| Operation | Pattern |
|---|---|
| Create | Entity.db.insertRow(session, entity) |
| Read | Entity.db.findById(session, id) |
| List | Entity.db.find(session, where: ..., limit: ...) |
| Update | Entity.db.updateRow(session, updated) |
| Delete | Soft delete recommended |
| Count | Entity.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:generateexecution complete