assets/skills/feature/api/SKILL.md
API integration workflow for adding new endpoints or integrating external APIs. Use when adding API endpoints, integrating third-party APIs, or when user says "integrate api", "add endpoint", "new api", "connect api", "api integration".
npx skillsauth add phuthuycoding/moicle feature-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.
End-to-end workflow for designing, implementing, testing, and documenting APIs — both internal endpoints and third-party integrations.
/research-web first/feature-new (which calls this skill internally for the API surface)DESIGN → IMPLEMENT → TEST → DOCUMENT → REVIEW LOOP
Before any phase, read:
~/.claude/architecture/ddd-architecture.md (core DDD)go-backend.md, nodejs-nestjs.md, etc.)Goal: lock the API contract before writing any code.
openapi: 3.0.0
info: { title: <name>, version: 1.0.0 }
servers: [{ url: https://api.example.com/v1 }]
components:
securitySchemes:
BearerAuth: { type: http, scheme: bearer }
schemas:
Error: { type: object, properties: { code: { type: string }, message: { type: string } } }
paths:
/resource:
post:
summary: Create resource
security: [{ BearerAuth: [] }]
requestBody: { content: { application/json: { schema: { $ref: '#/components/schemas/CreateInput' } } } }
responses:
'201': { description: Created, content: { application/json: { schema: { $ref: '#/components/schemas/Resource' } } } }
'400': { description: Validation error, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
Goal: implement the contract per stack conventions, respecting DDD layers.
| Concern | Layer | Notes |
|---------|-------|-------|
| Route definition | application/ports/http/ | Thin handler: parse → service → respond |
| Request / Response DTOs | application/ports/http/dto/ | NOT domain types |
| Validation | Handler or domain (depending on stack) | Reject bad input before reaching usecase |
| Business logic | domain/{domain}/usecases/ | NEVER in the handler |
| External API client | infrastructure/adapters/ | Implements a port in domain/{domain}/ports/ |
| Auth check | Middleware / decorator | NOT inline in handler |
All endpoints return errors in the same shape:
{ "error": { "code": "STRING", "message": "human-readable", "details": {} } }
code is stable across versions; message may change. Map domain errors → HTTP codes in ONE place (middleware / interceptor).
GET /resource?cursor=<opaque>&limit=<int 1..100, default 20>
→
{
"data": [...],
"pagination": { "next_cursor": "..." | null }
}
{stack_build_command}Goal: verify the contract holds and breaks safely.
| Layer | Type | What |
|-------|------|------|
| Handler | Unit | Validation, error mapping (mock service) |
| UseCase | Unit | Business logic (mock port) |
| Adapter (external API) | Integration | Real HTTP call to sandbox OR contract test with nock / WireMock |
| End-to-end | Integration | Full request → response, real DB |
{stack_test_command}Goal: update API docs so consumers can use it without reading code.
openapi.yaml or per-resource files)/docs-write skill for full re-author)### POST /resource
Create a resource. Idempotent via `Idempotency-Key` header.
**Auth:** Bearer
**Request**
```json
{ "field": "value" }
Response 201
{ "id": "...", "field": "value" }
Errors
| Code | HTTP | Meaning |
|------|------|---------|
| invalid_field | 400 | field failed validation |
| unauthorized | 401 | Token missing or invalid |
| already_exists | 409 | Same idempotency key with different body |
### Gate
- [ ] OpenAPI spec updated and lints
- [ ] API.md entry added
- [ ] CHANGELOG entry
- [ ] At least 1 example request runs successfully (curl / Postman)
---
## Phase 5: REVIEW LOOP
Run `/review-architect` for the touched domain. Loop until score ≥ B.
LOOP:
---
## Final Report
```markdown
## API Integration Complete
### Endpoints Added / Changed
| Method | Path | Purpose |
|--------|------|---------|
| POST | /v1/resource | Create resource |
### Files Created
- `application/ports/http/resource_handler.{ext}`
- `domain/{domain}/usecases/create_resource.{ext}`
- `infrastructure/adapters/{external_service}.{ext}` (if applicable)
### Tests
- {N} test files, {M} test cases
- Coverage: handler, usecase, adapter, e2e
### Documentation
- [x] OpenAPI spec updated
- [x] API.md entry added
- [x] CHANGELOG entry
### Review Score: {A/B}
| When | Use |
|------|-----|
| Designing the API contract from scratch | @api-designer agent |
| Adding the endpoint as part of a larger feature | /feature-new (calls this internally) |
| Writing tests for the endpoint | /review-tdd |
| Documenting the full API surface | /docs-write |
| Reviewing architecture compliance | /review-architect |
| Phase | Agent | Purpose |
|-------|-------|---------|
| DESIGN | @api-designer | API contract design (OpenAPI / GraphQL) |
| DESIGN | @clean-architect | Ensure DDD compliance |
| IMPLEMENT | Stack-specific dev agent | Implementation |
| IMPLEMENT | @db-designer | DB schema if new tables needed |
| TEST | @test-writer | Unit + integration tests |
| TEST | @security-audit | Auth / injection / rate-limit checks |
| DOCUMENT | @docs-writer | OpenAPI + API.md |
development
Test-Driven Development workflow. Use when doing TDD, writing tests first, or when user says "tdd", "test first", "test driven", "red green refactor".
development
Thorough pull request review workflow with architecture compliance checks. Use when reviewing pull requests, checking code changes, or when user says "review pr", "check pr", "review code", "pr review", "review pull request".
development
Review local branch changes for architecture compliance, conventions, and code quality before pushing/PR. Stack-aware — detects the project stack and applies the matching rules. Use when user says "review changes", "review branch", "check branch", "check changes", "review my code", "review before pr".
testing
DDD architecture compliance review with automated checks and review loop. Use when user says "architect-review", "architecture review", "review architecture", "check architecture", "review ddd", "ddd review".