.agents/skills/coding-express-api/SKILL.md
Writes API endpoints with Express.js following layered architecture patterns.To be used for implementing RESTful endpoints with validation, error handling, and business logic.
npx skillsauth add albertobasalo/astro-bookings-express coding-express-apiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Follow a layered architecture with clear separation of concerns between HTTP handling (routes), business logic (services), and data models (types).
The application uses three main layers:
Routes (HTTP Layer)
↓
Services (Business Logic)
↓
Types (Domain Models)
Organize code by technical layer:
src/
├── index.ts # Express app setup, middleware, route registration
├── routes/ # HTTP layer - one file per resource
│ └── resource.ts # Express Router with endpoint definitions
├── services/ # Business logic - one service per domain
│ └── resourceService.ts
├── types/ # Type definitions - one file per domain
│ └── resource.ts # Interfaces, DTOs, and domain types
└── utils/ # Shared utilities (logging, helpers)
└── logger.ts
rockets.ts, launches.ts.ts extension (no .routes suffix needed)Routes instantiate a service and delegate HTTP concerns:
See controller.ts template for complete example implementation.
| Method | Success | Validation Error | Not Found | |--------|---------|------------------|-----------| | GET | 200 | N/A | 404 | | POST | 201 | 400 | N/A | | PUT | 200 | 400 | 404 | | DELETE | 204 | N/A | 404 |
Return validation errors as an array:
res.status(400).json({
errors: [
{ field: 'name', message: 'Name is required' },
{ field: 'price', message: 'Price must be positive' }
]
});
.service suffix: rocket.service.ts, launch.service.tsServices encapsulate all business logic for a resource:
Key patterns:
resource-${incrementingId++}{ field, message } objects, never throw validation errorsupdatedAt timestamp, merge request with existing dataSee service.ts template for complete example implementation.
rocket.ts, launch.tsOrganize types into three categories:
Use literal unions for enums and optional fields for partial updates.
See types.ts template for complete example implementation.
'active' | 'inactive' | 'retired')readonly for immutable propertiesany type - use strict typingUtilities provide cross-cutting concerns like logging and helpers:
// logger.ts
export const logger = {
info(component: string, message: string, data?: unknown): void {
console.log(`[${component}] ${message}`, data ? JSON.stringify(data) : '');
},
error(component: string, message: string, data?: unknown): void {
console.error(`[${component}] ERROR: ${message}`, data ? JSON.stringify(data) : '');
},
warn(component: string, message: string, data?: unknown): void {
console.warn(`[${component}] WARN: ${message}`, data ? JSON.stringify(data) : '');
},
};
Key patterns:
The entry point (src/index.ts) sets up Express with middleware and registers route handlers:
import express from 'express';
import rocketsRouter from './routes/rockets';
import { logger } from './utils/logger';
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.get('/', (req, res) => {
res.status(200).json({ status: 'ok', message: 'AstroBookings API' });
});
app.get('/health', (req, res) => {
res.status(200).json({ status: 'ok' });
});
app.use('/rockets', rocketsRouter);
app.use('/launches', launchesRouter);
app.listen(PORT, () => {
logger.info('Server', `Running on port ${PORT}`);
});
export default app;
Key patterns:
anyresource-${incrementingId}testing
Writes and maintains unit tests using Vitest. To be used for testing business logic in services and utilities.
testing
Writes end-to-end tests with Playwright. To be used for verifying acceptance criteria through automated tests.
testing
Creates a detailed implementation plan for a given feature specification. To be used for planning the implementation of feature specifications.
testing
Writes the specification with problem definition, solution outline, and acceptance criteria. To be used to specify a feature, bug correction, or enhancement.