secret-sauce
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecret Sauce
核心开发秘籍
Best practices, rules, and templates extracted from real production projects.
从实际生产项目中提炼的最佳实践、规则和模板。
Quick Reference
快速参考
| Category | Reference File |
|---|---|
| Tech Stack | |
| Project Setup | |
| Project Tracking | |
| Coding Standards | |
| Centralization | |
| Tailwind v4 | |
| AI Development | |
| Data Fetching | |
| Git Workflow | |
| Testing | |
| Supabase | |
| Deployment | |
| Browser Tools | |
| Versioning | |
| 分类 | 参考文档 |
|---|---|
| 技术栈 | |
| 项目搭建 | |
| 项目追踪 | |
| 编码标准 | |
| 集中化模式 | |
| Tailwind v4 | |
| AI开发 | |
| 数据获取 | |
| Git工作流 | |
| 测试 | |
| Supabase | |
| 部署 | |
| 浏览器工具 | |
| 版本管理 | |
Framework Rules
框架规则
| Framework | Rule File |
|---|---|
| TypeScript | |
| Next.js | |
| React | |
| Supabase | |
| Security | |
| 框架 | 规则文档 |
|---|---|
| TypeScript | |
| Next.js | |
| React | |
| Supabase | |
| 安全 | |
Templates
模板
| Template | Purpose |
|---|---|
| Project configuration starter |
| Permission configuration |
| Project planning document |
| Technical implementation plan |
| Code review summary |
| Project changelog |
| 模板 | 用途 |
|---|---|
| 项目配置起始模板 |
| 权限配置模板 |
| 项目规划文档模板 |
| 技术实现方案模板 |
| 代码评审总结模板 |
| 项目变更日志模板 |
Usage
使用方法
Starting a New Project
启动新项目
- Copy to your project root as
templates/CLAUDE.md.templateCLAUDE.md - Customize sections for your stack
- Reference specific rules:
~/.claude/skills/secret-sauce/rules/typescript.md
- 将 复制到项目根目录并重命名为
templates/CLAUDE.md.templateCLAUDE.md - 根据你的技术栈自定义各章节内容
- 参考具体规则文档:
~/.claude/skills/secret-sauce/rules/typescript.md
Setting Up Permissions
权限设置
- Copy to
templates/settings.json.template.claude/settings.json - Adjust permissions for your workflow
- 将 复制到
templates/settings.json.template.claude/settings.json - 根据你的工作流调整权限配置
Project Documentation
项目文档
Use templates for consistent project documentation:
- for planning
project-plan.md.template - for technical specs
implementation-plan.md.template - for reviews
code-review.md.template
使用模板保持项目文档的一致性:
- 用于项目规划
project-plan.md.template - 用于技术规格说明
implementation-plan.md.template - 用于代码评审
code-review.md.template
Key Patterns
核心模式
CLAUDE.md Structure
CLAUDE.md 结构
Every project CLAUDE.md should include:
- YAML frontmatter (title, status, owner, tags)
- Quick Reference section with key commands
- Active/Pending/Completed projects
- Stack-specific guidelines
- Development patterns
每个项目的CLAUDE.md应包含以下内容:
- YAML前置元数据(标题、状态、负责人、标签)
- 包含关键命令的快速参考章节
- 进行中/待处理/已完成项目列表
- 技术栈专属指南
- 开发模式说明
Git Workflow
Git工作流
- Commit format:
<type>(<scope>): <description> - Never commit without confirmation
- Branch naming: ,
feature/<name>fix/<name> - PR template with summary and test plan
- 提交格式:
<type>(<scope>): <description> - 未经确认绝不要提交代码
- 分支命名规则:、
feature/<name>fix/<name> - 拉取请求(PR)模板需包含总结和测试计划
Centralization Pattern
集中化模式
All configuration in :
@/configtypescript
import { env, isProduction, getServiceUrl } from '@/config';所有配置统一存放于 :
@/configtypescript
import { env, isProduction, getServiceUrl } from '@/config';Configuration Hierarchy
配置层级
- Database configuration (system_configuration table)
- Environment variables (.env.local)
- Hardcoded defaults
Secrets (API keys) → only
Configs (models, URLs) → Database with fallback
.env.local- 数据库配置(system_configuration表)
- 环境变量(.env.local)
- 硬编码默认值
密钥(API密钥)→ 仅存于
配置项(模型、URL)→ 存储于数据库并设置回退值
.env.localTesting Standards
测试标准
- Target: >90% coverage
- Use Jest with 30s timeout for ML operations
- Add new test directories to test runners
- Security tests required for auth/validation
- 目标覆盖率:>90%
- 针对机器学习操作,使用Jest并设置30秒超时
- 将新测试目录添加到测试运行器中
- 认证/验证模块必须包含安全测试
AI Flow Pattern
AI流程模式
- Zod schemas for input/output
- Prompt builder functions
- OpenAI SDK v6 with
zodResponseFormat() - Error handling with Result types
- Server action wrapper
- 使用Zod schema定义输入/输出
- 提示词构建函数
- 搭配使用OpenAI SDK v6
zodResponseFormat() - 使用Result类型处理错误
- 服务器动作包装器
Data Fetching
数据获取
- Always pass to fetch calls
signal - Use to handle cancellation
isAbortError() - Memoize fetch options to prevent refetches
- Use for dashboards with visibility-aware intervals
usePolling
- 所有fetch调用必须传递参数
signal - 使用处理取消操作
isAbortError() - 对fetch选项进行 memoize 以避免重复请求
- 针对仪表盘,使用实现可见性感知的轮询间隔
usePolling
Security Checklist
安全检查清单
- Strict TypeScript (no )
any - Zod input validation
- Safe property access:
Object.prototype.hasOwnProperty.call() - XSS prevention on all user inputs
- Rate limiting in API routes
- 严格模式TypeScript(禁止使用类型)
any - Zod输入验证
- 安全属性访问:
Object.prototype.hasOwnProperty.call() - 对所有用户输入进行XSS防护
- API路由中添加速率限制