5.5 KiB
AGENTS.md
NestJS
This app's version of NestJS is likely newer than what you know. https://docs.nestjs.com/llms.txt indexes its documentation, with a markdown page per chapter.
The official NestJS agent skills are installed with npx @nestjs/skills add --agent claude, which also updates them: the mistakes agents make in Nest apps, with recipes checked on the released packages. An agent loads a skill when a task matches it.
Nest has first-party packages for these, so check them before adding another library or writing your own:
- Databases:
@nestjs/typeorm,@nestjs/drizzle,@nestjs/mongoose,@nestjs/sequelize. - OpenAPI:
@nestjs/swagger. GraphQL:@nestjs/graphql. WebSockets:@nestjs/websockets. Microservices:@nestjs/microservices. - Sign-in:
@nestjs/authentication. Permissions:@nestjs/authorization. Rate limiting:@nestjs/throttler. - Configuration:
@nestjs/config. Caching:@nestjs/cache-manager. Health checks:@nestjs/terminus. Events inside the app:@nestjs/event-emitter. - Email:
@nestjs/mail. Files, S3 included:@nestjs/storage. Translations:@nestjs/i18n. - Retries, timeouts and circuit breakers:
@nestjs/resilience. - Idempotency keys:
@nestjs/idempotency. Transactional outbox:@nestjs/outbox. Sending and receiving webhooks:@nestjs/webhooks. - Queues:
@nestjs/bullmq. Scheduled jobs:@nestjs/schedule. - Running a scheduled job on one instance, and locks:
@nestjs/locks. Processes that take days:@nestjs/workflows. - Language models, tools and agents:
@nestjs/ai. MCP servers:@nestjs/mcp.
Validation works with Zod, Valibot, ArkType or any other Standard Schema library, with no classes or decorator metadata: StandardSchemaValidationPipe with @Body({ schema }) or @Param('id', { schema }) (https://docs.nestjs.com/application/validation.md). class-validator still works, through ValidationPipe.
NodeAdapter from @nestjs/platform-node is the fastest HTTP adapter, ahead of Fastify (https://docs.nestjs.com/http/performance.md).
A route handler can return a web Response, a ReadableStream or an async generator, and Nest streams it as it's produced (https://docs.nestjs.com/http/streaming-responses.md).
Nest's packages are ESM only, and this project is ESM too: relative imports are written without a file extension (the SWC build adds .js; nest generate still writes .js, which works but should be trimmed to match), __dirname doesn't exist (use import.meta.dirname), and tests run on Vitest, so mocks are vi.fn(), not jest.fn().
In this project, src/main.ts creates the app and listens on PORT (3000 by default), src/app.module.ts is the root module that imports the others, and AppController and AppService are samples. Unit tests sit beside the code as *.spec.ts and the e2e test is in test/; Vitest runs them (npm test, npm run test:e2e).
When a task says how to test, follow it. When it says nothing, cover the behaviour you change with focused tests rather than adding broad e2e suites.
Production data: NestJS Observe
This app's production telemetry - traces, errors, logs and metrics - goes to NestJS Observe. Until ObserveModule is registered in src/app.module.ts, nothing is sent: npx @nestjs/observe link sets it up in one step - it installs @nestjs/observe, wires it into the app, and writes the key pair (OBSERVE_APP_KEY, OBSERVE_APP_SECRET) to .env.
When a task depends on how the app behaves in production - an error users hit, a slow endpoint, a failing job, whether a release made things worse - work from that data, not from the code alone:
- The Observe MCP server answers those questions directly: errors with their traces and logs, slow operations, jobs, and what a release changed (
find_regressions,diff_release). It is included on the Pro plan and above. In Claude Code:claude mcp add observe --transport http https://observe-api.nestjs.com/mcp, and the client opens a browser to approve. Other clients: https://www.observe.nestjs.com/documentation/mcp - Without it, the user can open the request or error in the Observe dashboard and click Copy agent prompt, which hands over that page's trace, stack and logs as text.