@lessup/awesome-cursorrules-zh-9
AABP Framework .cursorrules 提示文件
Install
agr install @lessup/awesome-cursorrules-zh-9 --target cursorWrites 1 file into .cursor/rules/, pinned to git-623ac66f.
- .cursorrules
Document
ABP Framework .cursorrules 提示文件
你是 ABP Framework、.NET 和领域驱动设计(DDD)方面的专家。
核心原则
- 遵循领域驱动设计(DDD)原则
- 使用 SOLID 原则构建可维护代码
- 实现清晰的分层架构
- 使用现代 C# 特性
- 关注模块化和代码复用
技术栈
- 运行时:.NET 8.0+
- 框架:ABP Framework
- ORM:Entity Framework Core
- Web:ASP.NET Core
- 前端:Blazor / Angular / React
- 微服务:Dapr(可选)
最佳实践
命名约定
| 类型 | 规范 | 示例 |
|---|---|---|
| 项目名 | PascalCase | MyProject |
| 类名 | PascalCase | UserManager |
| 接口名 | I + PascalCase | IUserAppService |
| 方法名 | PascalCase | GetUserAsync |
| 变量名 | camelCase | userRepository |
| 常量 | PascalCase / UPPER_SNAKE_CASE | MaxRetryCount |
项目结构
src/
├── MyProject.Domain/ # 领域层
│ ├── Entities/ # 实体和聚合根
│ ├── Repositories/ # 仓储接口
│ ├── ValueObjects/ # 值对象
│ └── DomainServices/ # 领域服务
├── MyProject.Domain.Shared/ # 共享领域
│ └── Enums/ # 枚举定义
├── MyProject.Application/ # 应用层
│ ├── Services/ # 应用服务
│ ├── DTOs/ # 数据传输对象
│ └── AutoMapper/ # 对象映射配置
├── MyProject.Application.Contracts/
│ ├── Services/ # 服务接口
│ └── DTOs/ # DTO 定义
├── MyProject.EntityFrameworkCore/
│ ├── EntityConfigurations/ # EF Core 配置
│ └── Migrations/ # 数据库迁移
├── MyProject.HttpApi/ # HTTP API
│ └── Controllers/ # API 控制器
└── MyProject.Web/ # Web 层
├── Pages/ # Razor Pages
└── Components/ # 视图组件
领域层示例
// 聚合根
public class User : AggregateRoot<Guid>
{
public string UserName { get; private set; }
public string Email { get; private set; }
private User() { } // ORM 需要
public User(Guid id, string userName, string email) : base(id)
{
UserName = userName;
Email = email;
}
public void UpdateEmail(string email)
{
Email = email;
AddLocalEvent(new UserEmailChangedEvent(Id, email));
}
}
// 值对象
public class EmailAddress : ValueObject
{
public string Address { get; private set; }
private EmailAddress() { }
public EmailAddress(string address)
{
Address = address; // 验证逻辑
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return Address;
}
}
应用层示例
// DTO (使用 record 类型)
public record CreateUpdateUserDto(
string UserName,
string Email,
string? PhoneNumber
);
// 应用服务
[Authorize(MyProjectPermissions.Users.Create)]
public class UserAppService(
IUserRepository userRepository,
UserManager<User> userManager) : ApplicationService, IUserAppService
{
public async Task<UserDto> CreateAsync(CreateUpdateUserDto input)
{
var user = new User(GuidGenerator.Create(), input.UserName, input.Email);
await userRepository.InsertAsync(user);
return ObjectMapper.Map<User, UserDto>(user);
}
public async Task<UserDto> GetAsync(Guid id)
{
var user = await userRepository.FindAsync(id)
?? throw new EntityNotFoundException(typeof(User), id);
return ObjectMapper.Map<User, UserDto>(user);
}
}
实体配置
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.ToTable("Users");
builder.HasKey(x => x.Id);
builder.Property(x => x.UserName).IsRequired().HasMaxLength(256);
builder.Property(x => x.Email).IsRequired().HasMaxLength(256);
builder.HasIndex(x => x.Email).IsUnique();
}
}
关键约定
-
领域层
- 实体继承
Entity或AggregateRoot - 使用值对象封装复杂类型
- 定义领域服务和仓储接口
- 使用领域事件解耦业务逻辑
- 实体继承
-
应用层
- 应用服务实现
IApplicationService - 使用 DTO 进行数据传输
- 使用 AutoMapper 进行对象映射
- 实现权限授权
- 应用服务实现
-
基础设施层
- 实现
IRepository<TEntity>接口 - 使用 EF Core 配置映射
- 实现数据库迁移
- 实现
-
表现层
- 使用 Auto API Controllers
- 实现动态 C# API 客户端
- 使用 ABP 的 Bundling 系统
测试规范
- 使用 xUnit 进行单元测试
- 使用 ABP 测试基础设施
- 模拟依赖项进行隔离测试
- 测试应用服务和领域逻辑
模块化
- 定义模块依赖关系
- 使用 Volo.Abp.Modularity
- 实现模块初始化逻辑
- 支持模块热插拔
Repository README
Describes LessUp/awesome-cursorrules-zh as a whole, which may contain artifacts other than this one. Where this artifact had no useful description of its own, its summary was taken from here.
Awesome Cursor Rules 中文版
为中文开发者打造的 Cursor AI 编程规则集合 Chinese localized version of Awesome Cursor Rules
132 个规则文件 · 32 个技术领域 · 190 个技术文档 · 6,500+ 行代码
🚀 快速开始 · 📂 规则目录 · 💡 使用指南 · 📚 官网 · 🤝 贡献
📋 目录
这是什么?
Awesome Cursor Rules 是优秀的 Cursor AI 编程助手规则集合。本项目是其中文本地化版本,专为中文开发者优化:
- 🎯 精准翻译 — 高质量中文翻译,技术术语准确专业
- 📂 结构清晰 — 按技术领域分类,便于快速查找
- 🚀 开箱即用 — 复制
.cursorrules文件即可开始使用 - 🌍 双语支持 — 完整的中英文文档对照
- ⚡ 132 个规则 — 涵盖前端、后端、移动端、AI、DevOps 等
🌐 在线文档: awesome-cursorrules-zh.js.org
什么是 .cursorrules?
.cursorrules 是 Cursor AI 编辑器的项目级配置文件,用于定义 AI 如何协助你的编程:
| 功能 | 说明 | 示例 |
|---|---|---|
| 编码规范 | 定义代码风格、命名约定 | PascalCase 组件名、camelCase 函数名 |
| 技术栈 | 指定框架、库、工具链 | React + TypeScript + Tailwind CSS |
| 最佳实践 | 自动应用行业标准 | 错误处理、性能优化、安全策略 |
| AI 行为 | 定制 AI 回复和代码生成风格 | 详细注释、函数式编程 |
💡 本质:给 AI 助手的"项目工作手册",确保代码生成的一致性和高质量
✨ 特性亮点
🏆 热门技术栈
📊 覆盖领域
- 🌐 应用开发: 前端、后端、移动端、数据库、系统编程
- 🤖 AI 与数据: 机器学习、数据科学、数据工程
- ☁️ 基础设施: DevOps、云服务、边缘计算、安全
- 🔬 专业领域: 区块链、物联网、量子计算、生物科技
🚀 快速开始
安装使用
# 克隆仓库
git clone https://github.com/LessUp/awesome-cursorrules-zh.git
# 浏览可用规则
cd awesome-cursorrules-zh
ls rules/frontend/react/
使用方法
# 复制规则到你的项目
cp rules/frontend/react/nextjs-typescript/.cursorrules /你的项目路径/
完成!在 Cursor 中打开项目,AI 将自动遵循规则。
热门规则示例
| 技术栈 | 规则 | 命令 |
|---|---|---|
| Next.js + TypeScript | nextjs-typescript | cp rules/frontend/react/nextjs-typescript/.cursorrules ./ |
| Vue 3 | composition-api | cp rules/frontend/vue/composition-api/.cursorrules ./ |
| FastAPI | fastapi-api-example | cp rules/backend/python/fastapi-api-example/.cursorrules ./ |
| Flutter | flutter-app-expert | cp rules/mobile/flutter/flutter-app-expert/.cursorrules ./ |
📖 完整快速开始指南
📂 规则目录
| 领域 | 目录 | 技术 |
|---|---|---|
| 前端 | frontend/ | React, Vue, Angular, Svelte, SolidJS, TypeScript |
| 后端 | backend/ | Node.js, Python, Go, Java, PHP, .NET, Elixir |
| 移动端 | mobile/ | Flutter, React Native, SwiftUI, Jetpack Compose |
| 数据库 | database/ | 云原生、时空数据库 |
| 系统编程 | systems/ | C++ 现代规范、Rust |
| 领域 | 目录 | 技术 |
|---|---|---|
| AI/ML | ai/ | 计算机视觉、MLOps、知识图谱、边缘 AI |
| 数据科学 | data-science/ | Pandas, PyTorch, TensorFlow, Scikit-learn |
| 数据工程 | data/ | Kafka, Spark, Flink, 数据仓库 |
| 领域 | 目录 | 技术 |
|---|---|---|
| DevOps | devops/ | Docker, Kubernetes, Terraform, CI/CD |
| 云服务 | cloud/ | 中间件、无服务器 |
| 边缘计算 | edge/ | AI 推理、模型压缩 |
| 安全 | security/ | 零信任、隐私计算、同态加密 |
| 领域 | 目录 | 技术 |
|---|---|---|
| 区块链 | blockchain/ | Solidity, Web3, 智能合约, Foundry |
| 物联网 | iot/ | 嵌入式、数字孪生 |
| 量子计算 | quantum/ | 量子纠错、超导计算 |
| 生物科技 | bio/ | 生物电子、生物传感器 |
| 硬件 | hardware/ | 神经形态芯片、光子计算 |
| 游戏开发 | gaming/ | DragonRuby, 云游戏 |
| 领域 | 目录 | 技术 |
|---|---|---|
| 开发工具 | tools/ | Convex, GitHub Quality |
| 通用规范 | general/ | 代码规范、风格一致性、测试 |
完整目录请查看 rules/ 文件夹
💡 使用指南
单技术栈项目
cp rules/frontend/react/nextjs-typescript/.cursorrules ./
多技术栈项目
方案一:合并规则
cat rules/frontend/react/nextjs-typescript/.cursorrules > .cursorrules
echo "" >> .cursorrules
cat rules/backend/python/fastapi-api-example/.cursorrules >> .cursorrules
方案二:目录级规则(推荐用于单体仓库)
project/
├── .cursorrules # 通用规则
├── frontend/
│ └── .cursorrules # 前端规则
└── backend/
└── .cursorrules # 后端规则
自定义规则
# 追加项目特定规则
cat >> .cursorrules << 'EOF'
## 项目自定义规则
- API 路由使用 /api/v1 前缀
- 所有模型必须包含 created_at 和 updated_at 字段
- 优先使用函数组件而非类组件
EOF
📖 完整最佳实践指南
📊 数据统计
| 指标 | 数值 |
|---|---|
| 规则文件 | 132 个 .cursorrules |
| 技术领域 | 32 个分类 |
| 技术文档 | 190 个 Markdown 文件 |
| 总行数 | 6,500+ 行 |
| 翻译进度 | 100% 中英双语 |
| 覆盖范围 | 前端、后端、移动端、AI、DevOps、区块链、物联网等 |
热门技术
TypeScript ████████████████████████████████ 29 个规则
React ██████████████████████ 19 个规则
Tailwind ███████████████ 13 个规则
Python █████████████ 11 个规则
Next.js ██████████ 8 个规则
Node.js █████████ 7 个规则
Docker █████████ 7 个规则
📚 文档
| 文档 | 说明 | 链接 |
|---|---|---|
| 🚀 快速开始 | 5 分钟上手指南 | 在线阅读 · GitHub |
| 📖 安装指南 | 详细安装配置 | 在线阅读 · GitHub |
| 💡 最佳实践 | 配置和使用建议 | 在线阅读 · GitHub |
| 🔧 故障排除 | 问题诊断解决 | 在线阅读 · GitHub |
| 📋 API 参考 | 规则格式参考 | 在线阅读 · GitHub |
| 📝 更新日志 | 版本历史 | 中文 · English |
🤝 贡献
欢迎所有形式的贡献:
- 🐛 报告问题 — 提交 Issue
- 🔧 改进内容 — 提交 Pull Request
- 🔄 同步上游 — 帮助与原项目保持同步
- 📝 完善文档 — 优化使用指南
详见 贡献指南
🙏 致谢
本项目是 PatrickJS/awesome-cursorrules 的中文本地化版本。感谢原作者和所有贡献者。
📄 许可证
如果这个项目对你有帮助,请给一个 ⭐ Star!
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-623ac66fec252026-08-04