Agent skill
scaffold-microservice
Scaffold a complete microservice with Controller-Service-Repository pattern for RH-OptimERP
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/scaffold-microservice
SKILL.md
Scaffold Microservice
Generate a complete .NET 8 microservice following the RH-OptimERP Controller-Service-Repository pattern.
What To Do
-
Parse arguments: Extract service name, entity list, and port.
-
Create directory structure:
src/backend/{ServiceName}/ Controllers/ -- One per entity Services/ Interfaces/ -- I{Entity}Service.cs {Entity}Service.cs Repositories/ Interfaces/ -- I{Entity}Repository.cs {Entity}Repository.cs Models/ {Entity}.cs -- Domain models DTOs/ {Entity}Dto.cs -- With ToDomain() and FromDomain() Program.cs -- DI, CORS, Swagger, health checks {ServiceName}.csproj -- .NET 8, CosmosDB SDK 3.54 appsettings.json appsettings.Development.json Dockerfile src/backend/Tests/{ServiceName}Tests/ {Entity}ServiceTests.cs {ServiceName}Tests.csproj -
Generate each file following these patterns:
Controller (HTTP concerns only):
csharp[ApiController] [Route("api/[controller]")] public class {Entity}Controller : ControllerBase { private readonly I{Entity}Service _service; public {Entity}Controller(I{Entity}Service service) => _service = service; [HttpGet("{id}")] public async Task<ActionResult<{Entity}Dto>> GetById(string id) { ... } [HttpGet] public async Task<ActionResult<PagedResult<{Entity}Dto>>> GetAll([FromQuery] int page = 1, [FromQuery] int size = 20) { ... } [HttpPost] public async Task<ActionResult<{Entity}Dto>> Create([FromBody] Create{Entity}Dto dto) { ... } }Service (business logic + validation):
csharppublic class {Entity}Service : I{Entity}Service { private readonly I{Entity}Repository _repository; public {Entity}Service(I{Entity}Repository repository) => _repository = repository; }Repository (CosmosDB SDK 3.54 direct):
csharppublic class {Entity}Repository : I{Entity}Repository { private readonly Container _container; public {Entity}Repository(CosmosClient client, IOptions<CosmosDbSettings> settings) { var db = client.GetDatabase(settings.Value.DatabaseName); _container = db.GetContainer("{entities}"); } }DTO (static mapping methods):
csharppublic class {Entity}Dto { public static {Entity}Dto FromDomain({Entity} entity) => new() { ... }; public {Entity} ToDomain() => new() { ... }; } -
Program.cs must include:
- CosmosClient singleton with direct mode
- All services and repositories registered via DI
- CORS for React frontend (localhost:3000)
- Swagger/OpenAPI
- Health checks endpoint
- Security headers middleware
-
Dockerfile (multi-stage):
dockerfileFROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src COPY . . RUN dotnet publish -c Release -o /app FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app COPY --from=build /app . EXPOSE {port} ENTRYPOINT ["dotnet", "{ServiceName}.dll"] -
Verify:
dotnet buildsucceeds with zero warnings.
GDPR Compliance
For entities containing personal data, add:
AnonymizeXxx()methodIsAnonymizedflag- Exclude PII from ToString() and logging
Arguments
<service-name>: Name of the microservice (PascalCase)--entities=<list>: Comma-separated entity names--port=<n>: HTTP port (default: 5000)--with-gdpr: Add GDPR compliance to all entities--with-tests: Generate test project (default: true)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?