| name | Create Service |
| description | Scaffold a new microservice that follows project architecture patterns |
| triggers | ["create service","new service","scaffold service","add service"] |
Create Service Skill
Generate a new service that follows our architecture patterns.
Architecture
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā YOUR SERVICE ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā SERVER (server.ts) ā ā
ā ā - Express/Fastify entry point ā ā
ā ā - Defines routes ā ā
ā ā - NEVER contains business logic ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā HANDLERS (handlers/) ā ā
ā ā - Business logic lives here ā ā
ā ā - One file per domain ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ā
ā ā¼ ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ADAPTERS (adapters/) ā ā
ā ā - External service wrappers ā ā
ā ā - Database, APIs, etc. ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Directory Structure
packages/{name}/
āāā src/
ā āāā server.ts # Entry point ā routes only
ā āāā handlers/ # Business logic
ā ā āāā index.ts
ā āāā adapters/ # External service wrappers
ā ā āāā index.ts
ā āāā types.ts # TypeScript types
āāā tests/
ā āāā handlers.test.ts
āāā package.json
āāā tsconfig.json
āāā CLAUDE.md # Service-specific instructions
Template: package.json
{
"name": "@project/{name}",
"version": "1.0.0",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx watch src/server.ts",
"start": "node dist/server.js",
"test": "vitest run"
},
"dependencies": {
"express": "^4.21.0"
},
"devDependencies": {
"tsx": "^4.0.0",
"typescript": "^5.7.0",
"vitest": "^3.0.0",
"@types/express": "^5.0.0"
}
}
Template: src/server.ts
import express from 'express';
import { handlers } from './handlers/index.js';
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.get('/health', (_req, res) => {
res.json({ status: 'ok', service: '{name}' });
});
app.post('/api/v1/:action', handlers.handleAction);
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection:', reason);
process.exit(1);
});
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
process.exit(1);
});
app.listen(PORT, () => {
console.log(`{name} running on port ${PORT}`);
});
Template: src/types.ts
export interface ServiceConfig {
port: number;
name: string;
environment: 'development' | 'staging' | 'production';
}
Template: tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "tests"]
}
Auto-Branch (if on main)
Before scaffolding a new service, check the current branch:
git branch --show-current
Default behavior (auto_branch = true in claude-mastery-project.conf):
To disable: Set auto_branch = false in claude-mastery-project.conf. When disabled, warn and ask the user before proceeding on main.
After Creating ā Checklist
RuleCatch Report
After the service is scaffolded, check RuleCatch:
- If the RuleCatch MCP server is available: query for violations in the new service files
- Report any violations found
- If no MCP: suggest checking the RuleCatch dashboard