
encore-service
โ 25by encoredev ยท part of encoredev/skills
Structures an Encore.ts app into services: how to lay out one service, several services, or groups of related services, and how they call each other over the network instead of importing code directly.
WHEN YOUR AGENT SHOULD USE IT
A QUICK BOUNDARYUSE FOR
- Add a new service to an existing Encore.ts application.
- Call an endpoint in another service instead of importing its code directly.
- Group a large application's many services into logical systems, like commerce or identity.
- Give a service its own dedicated database inside one Encore.ts app.
DO NOT USE FOR
- Deciding where the boundaries between services should be in the first place.
This is the playbook your agent receives when the skill activates โ you don't need to read it to use the skill, but it's here to audit before installing.
Encore Service Structure
Instructions
Creating a Service
Every Encore service needs an encore.service.ts file:
// encore.service.ts
import { Service } from "encore.dev/service";
export default new Service("my-service");Minimal Service Structure
my-service/
โโโ encore.service.ts # Service definition (required)
โโโ api.ts # API endpoints
โโโ db.ts # Database (if needed)Application Patterns
Single Service
A service can be defined at the application root:
my-app/
โโโ package.json
โโโ encore.app
โโโ encore.service.ts
โโโ api.ts
โโโ db.ts
โโโ migrations/
โโโ 001_initial.up.sqlMulti-Service
Each service lives in its own directory:
my-app/
โโโ encore.app
โโโ package.json
โโโ user/
โ โโโ encore.service.ts
โ โโโ api.ts
โ โโโ db.ts
โโโ order/
โ โโโ encore.service.ts
โ โโโ api.ts
โ โโโ db.ts
โโโ notification/
โโโ encore.service.ts
โโโ api.tsLarge Application (System-based)
Group related services into systems:
my-app/
โโโ encore.app
โโโ commerce/
โ โโโ order/
โ โ โโโ encore.service.ts
โ โโโ cart/
โ โ โโโ encore.service.ts
โ โโโ payment/
โ โโโ encore.service.ts
โโโ identity/
โ โโโ user/
โ โ โโโ encore.service.ts
โ โโโ auth/
โ โโโ encore.service.ts
โโโ comms/
โโโ email/
โ โโโ encore.service.ts
โโโ push/
โโโ encore.service.tsService-to-Service Calls
Import other services from ~encore/clients:
import { user } from "~encore/clients";
export const getOrderWithUser = api(
{ method: "GET", path: "/orders/:id", expose: true },
async ({ id }): Promise<OrderWithUser> => {
const order = await getOrder(id);
const orderUser = await user.get({ id: order.userId });
return { ...order, user: orderUser };
}
);Guidelines
- Services cannot be nested within other services
- Use
~encore/clientsfor cross-service calls (never direct imports) - Each service can have its own database
- Service names should be lowercase, descriptive
- Don't create services just for code organization - use folders instead
- Use
encore-architecturewhen the service boundaries have not been decided
npx skills add encoredev/skills --skill "encore-service" --full-depthRun this in your project โ your agent picks the skill up automatically.
BEFORE IT WILL WORK
Nothing โ it works as soon as it is installed.
Licensed under Apache-2.0โ you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub โ