agentleFS
xu-xiangxu-xiang/everything-claude-code-zh/.cursor/rules/common-coding-style.md

everything-claude-code-zh / rules

Cursor rule2k starsChanged 9 months agoMITView on GitHub

ECC 编码规范:不可变性(Immutability)、文件组织、错误处理、验证

Trending

More talk lately.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the xu-xiang/everything-claude-code-zh repository that our weekly crawl found: only 1 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about xu-xiang/everything-claude-code-zh

The biggest 1 of 1 mention linking to the repository that our crawl found. Each line is their own headline.

The file

Files
common-coding-style.md

编码规范(Coding Style)

不可变性(Immutability)(至关重要)

始终(ALWAYS)创建新对象,绝不(NEVER)修改(mutate)现有对象:

// 伪代码(Pseudocode)
错误(WRONG): modify(original, field, value) → 原地修改原对象
正确(CORRECT):update(original, field, value) → 返回包含变更的新副本

原理(Rationale):不可变数据可防止隐藏的副作用,使调试更容易,并实现安全的并发(Concurrency)。

文件组织(File Organization)

多而小的文件 > 少而大的文件:

  • 高内聚,低耦合(High cohesion, low coupling)
  • 通常 200-400 行,最大 800 行
  • 从大型模块中提取工具函数(Utilities)
  • 按功能/领域(Feature/Domain)组织,而不是按类型(Type)组织

错误处理(Error Handling)

始终(ALWAYS)全面处理错误:

  • 在每个层级显式(Explicitly)处理错误
  • 在面向 UI 的代码中提供用户友好的错误消息
  • 在服务端记录详细的错误上下文(Context)
  • 绝不静默吞掉(Swallow)错误

输入验证(Input Validation)

始终(ALWAYS)在系统边界进行验证:

  • 在处理之前验证所有用户输入
  • 尽可能使用基于模式(Schema)的验证
  • 快速失败(Fail fast)并提供清晰的错误消息
  • 绝不信任外部数据(API 响应、用户输入、文件内容)

代码质量自查表(Code Quality Checklist)

在标记工作完成之前:

  • 代码易读且命名良好
  • 函数简短(<50 行)
  • 文件职责集中(<800 行)
  • 无深层嵌套(>4 层)
  • 正确的错误处理
  • 无硬编码值(使用常量或配置)
  • 无修改/变异(使用不可变模式)

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.