agentleFS
rx-chenxiangrx-chenxiang/monorepo-workflow/.cursor/rules/project-workflow-api.mdc

monorepo-workflow / rules

Cursor rule1 starsChanged 4 months agoMITView on GitHub

后端 API 开发流程(通用 api 子项目)

The file

Files
project-workflow-api.mdc
---
description: 后端 API 开发流程(通用 api 子项目)
globs: api/**,docs/general/**/coding-plan/**,docs/general/**/技术设计方案/**
---

# 后端 API Workflow

## 当前文件说明

本规则用于 `api/` 后端子项目的接口、领域服务、数据访问、鉴权、安全、任务队列与文档同步工作。具体技术栈、目录结构与启动命令以 `api/AGENTS.md`、`api/docs/README.md` 和实际代码为准。

## 触发条件

用户提到 `后端`、`API`、`接口`、`服务端`、`Controller`、`Service`、`Domain`、`Laravel`、`PHP` 等后端开发语义时,加载本规则。

## 编码前必读

1. 根目录 `AGENTS.md`:确认当前任务是否命中 `api/`。
2. `api/AGENTS.md`:确认后端子项目边界。
3. `api/docs/README.md`:确认后端文档入口。
4. `api/docs/modules/README.md`:通过实际索引定位模块文档。
5. `api/docs/codebase/README.md` 与 `api/docs/rules/README.md`:按任务读取相关专题。
6. 若有需求文档,读取 `docs/general/{需求名称}/需求文档/` 与 `技术设计方案/` 下相关文件。

## 实现原则

1. 遵循 KISS 与 SOLID,优先使用项目已有分层、工具类和异常处理方式。
2. 接口参数、响应结构、错误码、鉴权方式以现有契约为准,禁止擅自新增不兼容字段。
3. 不主动修改全局中间件、鉴权链路、数据库连接、队列配置,除非需求明确要求。
4. 涉及数据库变更时,补充迁移、回滚策略与基础验证说明。
5. 涉及前端联调时,优先更新或确认接口契约,再通知对应前端目录。

## 开发流程

1. 定位路由、Controller、Service、Model、Repository 或等价代码位置。
2. 读取目标模块上下文,确认输入、输出、权限、状态流和异常分支。
3. 做最小范围实现,保持命名和分层与现有代码一致。
4. 补充必要中文注释,避免无意义注释。
5. 执行可用的后端自测命令;无法执行时说明原因。
6. 同步 `api/docs/modules/` 或 `api/docs/codebase/` 中实际存在的相关文档。

## 自检清单

- [ ] 是否只修改 `api/` 或本次明确要求的相关文档。
- [ ] 是否保持接口契约稳定,或已说明兼容影响。
- [ ] 是否覆盖权限、参数校验、异常分支和幂等性。
- [ ] 是否完成可执行的基础验证。
- [ ] 是否同步模块文档或说明无需同步的原因。

<!-- AIGC:cursor|author:沉香|lines:约65|dates:2026-07|功能说明:后端workflow初始化为通用api子项目规则,移除旧业务项目Domain映射 -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.