后端核心

David-Li04062026-10-25查看 1607复制 1839

生成后端路由,处理请求和响应,并将应用程序连接到数据库。适用于 API 和服务器端开发。

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md1349 chars
---
name: backend-core
description: Generate backend routes, handle requests and responses, and connect applications to databases. Use for API and server-side development.
---

# Backend Core Skill

## Instructions

1. **Routing**
   - Create RESTful routes (GET, POST, PUT, DELETE)
   - Organize routes by feature/module
   - Use clear and meaningful endpoint names

2. **Request & Response Handling**
   - Validate incoming request data
   - Handle headers, params, body, and query
   - Send proper HTTP status codes and JSON responses

3. **Database Connection**
   - Connect to databases (MongoDB, PostgreSQL, MySQL)
   - Use ORM/ODM when needed
   - Handle connection errors safely

4. **Business Logic**
   - Separate logic from routes (controllers/services)
   - Keep code clean and reusable
   - Handle async operations properly

## Best Practices
- Follow MVC or service-based architecture
- Always validate and sanitize user input
- Use environment variables for secrets
- Handle errors with try/catch or middleware
- Keep APIs consistent and predictable

## Example Structure
```js
// routes/user.routes.js
import express from "express";
import { createUser, getUsers } from "../controllers/user.controller.js";

const router = express.Router();

router.post("/users", createUser);
router.get("/users", getUsers);

export default router;
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧