人工智能编码规则
用于AI原生全栈开发的生产级规则、文档和模式。适用于 光标 和 克劳德代码.
15条工程规则+9个文档模板+技能指南+代理模式+MCP设置。加入任何项目——你的人工智能编码工具会立即像高级工程师一样思考。
快速开始
光标
curl -fsSL https://raw.githubusercontent.com/aiagentwithdhruv/ai-coding-rules/main/install.sh | bash克劳德代码
curl -fsSL https://raw.githubusercontent.com/aiagentwithdhruv/ai-coding-rules/main/claude/CLAUDE.md -o CLAUDE.md两者(推荐)
curl -fsSL https://raw.githubusercontent.com/aiagentwithdhruv/ai-coding-rules/main/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/aiagentwithdhruv/ai-coding-rules/main/claude/CLAUDE.md -o CLAUDE.md里面是什么
ai-coding-rules/
├── rules/ # 15 Cursor rules (.mdc)
├── claude/ # Claude Code setup
│ ├── CLAUDE.md # All 15 rules in one file
│ ├── compose.sh # Build custom CLAUDE.md
│ ├── rules/ # 15 individual rule files
│ └── .claude/settings.json # Permission config template
├── docs/ # 9 project templates
│ ├── PRD.md # Product requirements
│ ├── ARCHITECTURE.md # System architecture + data flow
│ ├── API_SPEC.md # API endpoints + response format
│ ├── DB_SCHEMA.md # Tables, columns, indexes
│ ├── DEPLOYMENT.md # Local + AWS + Vercel + VPS + CI/CD
│ ├── SKILLS.md # How to create and use skills
│ ├── AGENTS.md # Subagent patterns and templates
│ ├── LOADOUT.md # Project manifest template
│ └── MCP.md # MCP server setup guide
├── install.sh # One-liner installer
└── LICENSE15条规则
| # | 规则 | 它执行什么 |
|---|---|---|
| 00 | 全球建筑师 | 先考虑建筑师。干净的建筑。关注点分离。 |
| 10 | 后端FastAPI | 稀疏的路线。逻辑服务。DB的存储库。 |
| 20 | 前端Next.js | TypeScript。小部件。集中式API客户端。 |
| 30 | 数据库PostgreSQL | 移民。索引。外键。路由中没有原始SQL。 |
| 35 | API合同 | 版本API。类型化架构。一致的错误格式。 |
| 40 | 缓存Redis | 有意TTL。稳定的钥匙。封闭式通道。 |
| 45 | 环境配置 | 启动时验证。.env.示例。秘密经理。 |
| 50 | RAG系统 | 将摄入与世代分开。分块元数据。 |
| 55 | 数据和模型版本控制 | 版本数据集。命名检查点。再现性。 |
| 60 | 代理 | 工具模式。验证输出。主管模式。 |
| 70 | 安全 | 没有硬编码的秘密。快速注射阻力。 |
| 80 | 测试与质量 | 关键路径测试。确定性单位。林。 |
| 85 | 误差和可观测性 | 结构性错误。请求跟踪。健康检查。 |
| 90 | DevOps与部署 | Docker。AWS。Vercel。VPS。CI/CD |
| 99 | 响应风格 | 最小的变化。生产代码。没有玩具实现。 |
9个文档模板
| 文档 | 它的定义 | 为什么重要 |
|---|---|---|
| PRD.md | 产品需求、用户、里程碑 | AI知道 什么 建造 |
| 建筑.md | 层次、数据流、关键决策 | AI知道 怎么 它是结构化的 |
| API规范.md | 端点、响应格式、模式 | AI写入 一致的API |
| DB_SCHEMA.md | 表、列、类型、索引 | AI写入 正确的查询 |
| 部署.md | 本地+云+CI/CD设置 | AI写入 部署就绪代码 |
| SKILLS.md | 可重复使用的自动化功能 | AI 重复使用 重建前 |
| 代理商.md | 子代理模式、模板 | AI 代表 复杂任务 |
| 输出.md | 项目清单模板 | AI获取 即时上下文 |
| MCP.md | 外部工具集成 | AI 连接 服务 |
运作原理
规则告诉AI 怎么 编码
"Use clean architecture"
"Never hardcode secrets"
"Use Pydantic for validation"文档告诉AI 什么 你在建
"We have 12 tables with multi-tenant isolation"
"API uses /api/v1/ prefix with JWT auth"
"Deploy to AWS ECS with GitHub Actions"技能告诉AI 什么 自动化
"Use the deploy skill to push to production"
"Use the scrape-leads skill for lead generation"这 00-global-architect 规则自动引用您的文档:
Before implementing, align with docs/PRD.md, docs/ARCHITECTURE.md,
docs/API_SPEC.md, docs/DB_SCHEMA.md, and docs/DEPLOYMENT.md if present.光标与克劳德代码
| 光标 | 克劳德代码 | |
|---|---|---|
| 格式 | .mdc 使用YAML frontmatter | .md 普通标记 |
| 地点 | .cursor/rules/ | CLAUDE.md 在项目根 |
| 多个文件 | 15个编号文件 | 1个合并或子目录拆分 |
| 触发器 | 始终应用、globs、手动 | 始终从当前目录加载 |
| 安装 | install.sh | 单个文件副本 |
在同一项目中同时使用这两种方法——零冲突:
your-project/
├── .cursor/rules/*.mdc # Cursor reads these
├── CLAUDE.md # Claude Code reads this
└── docs/ # Both reference these定制
交换框架
不使用Next.js?替换 20-frontend-nextjs:
- React+Vite、SvelteKit、Nuxt、Angular
不使用FastAPI?替换 10-backend-fastapi:
- Express、Django、Go、Rails
添加自定义规则
光标--创建 05-my-rule.mdc 在 .cursor/rules/ (间隙编号,适合00到10之间)。
Claude Code——添加一节 CLAUDE.md.
制定克劳德规则
只选择你需要的:
cd ai-coding-rules/claude
./compose.sh 00 10 30 70 80 99 > ~/project/CLAUDE.md # Backend only
./compose.sh 00 20 70 80 99 > ~/project/CLAUDE.md # Frontend only
./compose.sh 00 50 55 60 70 99 > ~/project/CLAUDE.md # AI/ML only
./compose.sh > ~/project/CLAUDE.md # Everything相关
- 技能 --38种可重用的AI代理技能(潜在客户开发、电子邮件、视频、部署)。安装:
npx skills add aiagentwithdhruv/skills
ai-coding-rules = 如何设置你的AI编码环境 skills = 使用AI代理实现自动化
学分
建造于 @艾维思·德鲁夫 克劳德代码。
在30多个项目中进行了生产测试——人工智能代理、RAG系统、SaaS产品和客户端工作。
许可证
麻省理工学院——使用它,分叉它,发布更好的代码。
