Nestjs 标志

Nestjs

组织
nestjs
nestjs

NestJS, the TypeScript framework for Node.js backends. How to start a project non-interactively with the Nest CLI, the project layout and module system, where the current docs are, and the mistakes agents make in Nest apps that still pass their tests. Use when creating or extending a NestJS application.

概览

发布者nestjs
代码仓库agent-skills
技能名称nestjs
星标数
176
复刻数
5
附带文件
1
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 nestjs 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Nestjs AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/nestjs/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/plugins/nestjs/skills/nestjs .claude/skills/nestjs
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Nestjs,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Nestjs。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Nestjs 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

NestJS

Nest's APIs move faster than model training data, so what you remember may be a major version behind. Check before relying on memory:

  • Which version you're on: npm ls @nestjs/core in a project, npm view @nestjs/core version for the latest. Use the latest for a new project.

  • https://docs.nestjs.com/llms.txt indexes every chapter. Each chapter is plain markdown at its URL plus .md, e.g. https://docs.nestjs.com/controllers.md. Fetch the one chapter you need, not llms-full.txt. Find the page in the index rather than from memory: remembered paths (/techniques/...) are from older versions; most redirect to the current chapter, but some topics moved or split.

  • Nest has first-party packages for most backend needs (auth, permissions, databases, config, rate limiting, OpenAPI, health checks, queues, scheduling). Check them before writing your own or adding another library. The other skills in this package cover the common ones.

Start a project

In an empty folder:

bash
npx @nestjs/cli new . --skip-git --package-manager npm

Without a TTY (an agent's shell) it asks nothing: it creates an ESM project with Vitest and installs dependencies. --minimal creates a one-file app (src/main.ts). npm start runs nest start, which compiles first.

It also sets up @nestjs/observe (--no-observe skips it), which sends nothing until the project is linked. Once the project exists, tell the user to run npx @nestjs/observe link in it: they approve a code in the browser (signing up for free if needed), and it writes the key pair into .env. If they ask you to run it, run it with --no-browser in the background and pass on the address and the code it prints. Never write the keys yourself.

Write modules, controllers and services as files yourself (nestjs-feature shows the shape); register each in its module. nest generate is optional: npx nest g module|controller|service <name> --no-spec creates a stub and registers it, which helps when you're unsure where it goes. nest g resource makes a CRUD scaffold of stubs, DTOs and an entity class; use it only when you want exactly that, and pass --type rest --crud so it doesn't prompt.

The scaffold comes with an AGENTS.md; read it in an existing project, along with package.json and nest-cli.json.

Layout and module system

  • src/main.ts bootstraps (NestFactory.create(AppModule), global pipes, app.listen(process.env.PORT ?? 3000)); src/app.module.ts imports the feature modules.
  • One folder per feature: src/notes/notes.module.ts, notes.controller.ts (HTTP only), notes.service.ts (rules), a repository (queries), DTOs (CreateNoteDto) or schemas next to them. Share a provider by adding it to its module's exports and importing that module. Where code goes, how to split modules and what to avoid: nestjs-feature's references/structure.md.
  • Projects from nest new are ESM ("type": "module"), and Nest's packages are ESM only: relative imports end in .js (import { NotesService } from './notes.service.js'), there's no __dirname (use import.meta.dirname), tests use vi.fn(), not jest.fn(). Follow what an existing project uses.
  • Run through the Nest CLI or tsc, not tsx: tsx emits no decorator metadata, so providers injected by type arrive as undefined.
  • Never import type a class you inject. Dependency injection reads the constructor's parameter types at run time; a type-only import erases them, and the app stops at startup with Nest can't resolve dependencies of the NotesService (?). Linters and auto-fixers (consistent-type-imports) make this change on their own. The opposite holds for plain types in decorated signatures (Request from express, RawBodyRequest): with isolatedModules, TypeScript requires import type there (error TS1272).

Mistakes that pass tests

Coding agents make these in Nest apps whose tests all pass:

  • Sign-in leaks which emails exist. Hand-assembled sign-in (@nestjs/jwt + bcrypt) returns early for an unknown email (if (!user || !(await bcrypt.compare(...))) throw), so unknown emails answer faster. Use @nestjs/authentication's PasswordHasher.verify(password, user?.passwordHash), which checks a dummy hash when there's no user. See the nestjs-auth skill.
  • @Post() answers 201. A POST that creates nothing (sign-in, actions, searches) needs @HttpCode(200) or the code it means.
  • @IsOptional() lets null through. class-validator skips every rule for null, so {"title": null} reaches the database and fails with a 500. For "may be left out, not null", use @ValidateIf((_, value) => value !== undefined) instead. Zod's .optional() doesn't have this problem.
  • A short HS256 secret. @nestjs/authentication's accessToken.key needs at least 32 bytes and stops the app at startup otherwise. Never hash or pad a secret to fit: tokens are then signed with a different key and whatever verifies them with the real secret rejects them. The nestjs-auth skill covers a secret the task fixes.
  • The OpenAPI document leaves out its own route. SwaggerModule.setup() serves the document outside Nest's router, so it isn't listed. Add it if the contract says every route is documented (nestjs-production).
  • Stopping servers. Start a server in the background, note its PID (npm start > server.log 2>&1 & echo $!), and stop it with kill <pid>, or by its port: kill $(lsof -ti tcp:3000 -sTCP:LISTEN). Never pkill -f nest or pkill -f "npm start": they match other projects' processes on the machine.

A contract the task fixes (status codes, error bodies, secrets, field names) wins over a package's defaults. Adapt the package, or say what you couldn't do.

When a task says how to test, follow it. When it says nothing, cover the behaviour you change with focused tests rather than broad e2e suites.

Other skills in this package

  • nestjs-feature: modules, controllers, services, validation (Zod with @Body({ schema }), or class-validator), status codes, error bodies, Server-Sent Events.
  • nestjs-auth: @nestjs/authentication and @nestjs/authorization.
  • nestjs-data: @nestjs/drizzle and @nestjs/typeorm.
  • nestjs-testing: unit and e2e tests.
  • nestjs-production: config, logging, observability (NestJS Observe), health checks, rate limiting, OpenAPI, shutdown, deployment.

More detail: references/docs-map.md lists the docs chapter for each topic.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Nestjs AI 技能有什么作用?

NestJS, the TypeScript framework for Node.js backends. How to start a project non-interactively with the Nest CLI, the project layout and module system, where the current docs are, and the mistakes agents make in Nest apps that still pass their tests. Use when creating or extending a NestJS application.

为什么在 TypingMind 中使用 Nestjs?

因为您只需安装一次,就能搭配任何模型使用。Nestjs 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Nestjs?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/nestjs/agent-skills/tree/master/plugins/nestjs/skills/nestjs。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Nestjs?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Nestjs 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Nestjs 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Nestjs AI 技能免费吗?

是的。nestjs 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇