Borrowing it
Nothing to install: this file belongs to MisonL/Ling. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/MisonL/Ling/main/.agents/skills/nodejs-best-practices/SKILL.mdgit clone --depth 1 https://github.com/MisonL/LingWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/misonl/ling/nodejs-best-practices)<a href="https://agentmods.dev/skills/misonl/ling/nodejs-best-practices"><img src="https://agentmods.dev/badge/skills/misonl/ling/nodejs-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/misonl/ling/nodejs-best-practices"><img src="https://agentmods.dev/badge/skills/misonl/ling/nodejs-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00041 | $0.02449 |
| Opus 5.5 | $0.00016 | $0.00980 |
| Sonnet 5.5 | $0.00008 | $0.00490 |
| Haiku 4.5 | $0.00004 | $0.00245 |
Grade A, and why
nodejs-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 334 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Node.js 最佳实践
面向 2025 的 Node.js 开发原则与决策方法。
学习如何思考,不要只记代码套路。
[WARN] 本技能使用方式
本技能教授的是决策原则,不是固定代码模板。
- 需求不明确时,先向用户确认偏好
- 根据上下文(Context)选择框架与模式
- 不要每次都默认同一套方案
1. 框架选型(2025)
决策树
你要构建什么?
|
+-- Edge/Serverless(边缘/无服务器,Cloudflare、Vercel)
| +-- Hono(零依赖、冷启动极快)
|
+-- 高性能 API
| +-- Fastify(通常比 Express 快 2-3 倍)
|
+-- 企业协作/团队熟悉度优先
| +-- NestJS(结构化、DI、装饰器)
|
+-- 传统/稳定/生态最大化
| +-- Express(成熟、middleware 最多)
|
+-- 前后端一体
+-- Next.js API Routes 或 tRPC
对比原则
| 维度 | Hono | Fastify | Express |
|---|---|---|---|
| 适用场景 | Edge、serverless | 性能优先 | 传统、学习 |
| 冷启动 | 最快 | 快 | 中等 |
| 生态 | 成长中 | 较好 | 最大 |
| TypeScript | 原生支持 | 优秀 | 良好 |
| 学习曲线 | 低 | 中 | 低 |
选型前必须询问:
- 部署目标是什么?
- 冷启动时间是否关键?
- 团队是否有既有经验?
- 是否存在需要维护的遗留代码?
2. 运行时考量(2025)
原生 TypeScript
Node.js 22+: --experimental-strip-types
+-- 可直接运行 .ts 文件
+-- 简单项目可免构建步骤
+-- 适用:脚本、简单 API
模块系统决策
ESM(import/export)
+-- 现代标准
+-- 更好的 tree-shaking
+-- 异步模块加载
+-- 适用:新项目
CommonJS(require)
+-- 遗留兼容性更好
+-- 对部分 npm 包支持更成熟
+-- 适用:既有代码库、特定边界场景
Runtime 选择
| Runtime | 适用场景 |
|---|---|
| Node.js | 通用场景、生态最大 |
| Bun | 性能优先、内置 bundler |
| Deno | 安全优先、内置 TypeScript |
3. 架构原则
分层结构概念
请求流(Request Flow):
|
+-- Controller/Route 层
| +-- 处理 HTTP 细节
| +-- 在边界做输入校验
| +-- 调用 service 层
|
+-- Service 层
| +-- 承载业务逻辑
| +-- 与框架解耦
| +-- 调用 repository 层
|
+-- Repository 层
+-- 仅处理数据访问
+-- 数据库查询
+-- ORM 交互
为什么重要
- 可测性(Testability): 可独立 mock 每一层
- 灵活性(Flexibility): 更换数据库不影响业务层
- 清晰性(Clarity): 每层职责单一
何时简化
- 小型脚本 -> 单文件可接受
- 原型验证 -> 可降低结构复杂度
- 始终追问:“这个项目会继续增长吗?”
4. 错误处理原则
集中式错误处理
Pattern:
+-- 定义自定义错误类
+-- 各层都可 throw
+-- 在顶层统一 catch(middleware)
+-- 输出一致的响应格式
错误响应哲学
Client gets:
+-- 合理的 HTTP 状态码
+-- 可程序化处理的错误码
+-- 对用户友好的提示
+-- 不暴露内部细节(安全要求)
Logs get:
+-- 完整堆栈信息
+-- 请求上下文
+-- 用户 ID(如适用)
+-- 时间戳
状态码选择
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 334 lines · 41 tokens per session scan A afd79a57be0c
nodejs-best-practices is a skill published in the GitHub repository MisonL/Ling (8 stars, last pushed 7mo ago), licensed MIT. It adds 41 tokens to every session and 2,449 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
agui-dotnet-streaming-chat
Get started with the AG-UI .NET SDK: bootstrap and run your first streaming-chat app (client + server) with the AG-UI .NET NuGet packages (AGUI.Client, AGUI.Server, AGUI.Formatting, AGUI.Abstractions). USE FOR: which packages to install and how to wire them; constructing an AGUIChatClient against an endpoint and…
azure-mgmt-apicenter-dotnet
Azure API Center SDK for .NET. Centralized API inventory management with governance, versioning, and discovery. Use for creating API services, workspaces, APIs, versions, definitions, environments, deployments, and metadata schemas. Triggers: "API Center", "ApiCenterService", "ApiCenterWorkspace", "ApiCenterApi", "API…
azure-communication-chat-java
Build real-time chat applications with Azure Communication Services Chat Java SDK. Use when implementing chat threads, messaging, participants, read receipts, typing notifications, or real-time chat features.
conventions
Spring Boot project conventions and mandatory rules. Auto-loads when working with Spring Boot, Java, or Maven projects. Enforces No-Lombok, constructor injection, RestClient, Flyway for relational databases, Problem Details errors, and other standards; adds OpenAPI contract rules when the API is built for a UI.
grpc
Build or review gRPC services and clients in .NET. USE FOR: ASP.NET Core gRPC, protobuf contracts, unary or streaming RPC, gRPC client factory, interceptors, deadlines, cancellation, channel reuse, backend service integration. DO NOT USE FOR: broad browser-facing APIs without gRPC-Web tradeoff review, SignalR realtime…
azure-messaging-webpubsubservice-py
Real-time messaging with WebSocket connections at scale.