跳到正文
cccskills
免费在 GitHub 公开

clean-code

ALWAYS invoke this skill before writing, editing, generating, or refactoring ANY code. Do not write or modify code directly without first loading and following these Clean Code guidelines. Use when writing new functions/classes, refactoring existing code, reviewing code, fixing bugs, or any task that produces code output.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(11)

  • SKILL.md4.2 KB
  • references/api_dto_clean.md3.0 KB
  • references/classes.md6.9 KB
  • references/comments.md5.7 KB
  • references/dataToDomainFlow.md7.4 KB
  • references/error-handling.md8.8 KB
  • references/formatting.md4.9 KB
  • references/functions.md12.9 KB
  • references/naming.md4.0 KB
  • references/rules-card.md3.6 KB
  • references/testing.md7.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Clean Code — Mandatory Rules

These rules apply to ALL code you produce. No exceptions.

Step 0: Before Writing ANY Code

  1. naming.md and functions.md are already pre-loaded by the prehook — apply them directly
  2. If writing classes: read classes.md from the absolute path provided at the end of this prehook context
  3. If code has error paths: read error-handling.md from the same path
  4. Discover the domain language — before writing a single line, name the problem's nouns and verbs. Every entity, action, and predicate in your code should come from this vocabulary, not from generic programming terms

NOTE: The prehook injects the absolute path to the references directory at the end of its context. Use that path for any file reads — relative paths will NOT work.

Rules — Action Directives

Naming — for every name, ask these questions:

  1. "Does this name describe WHY or HOW?" If HOW (mechanism), rename to WHY (intent).
  2. "Is this word from the domain or from generic programming?" If generic, replace with domain.
  3. "Can a reader understand this without reading the implementation?" If no, rename.

Functions — for every function, check:

  1. "Does this do more than one thing?" Extract a non-restating helper if yes.
  2. "Are all lines at the same abstraction level?" If high mixed with low, extract.
  3. "Can I name each branch/direction?" If raw row-1, col+1 appear inline, extract exploreNorth(), exploreSouth(), etc.
  4. 5-20 lines, 0-2 params, no side effects, no boolean flags.

File-level stepdown: Entry point function FIRST → class definition → helpers → primitives. Reader hits "what" before "how".

Code speaks: No comments explaining WHAT. If you need a comment, rename or extract instead. Only comment WHY when non-obvious. No section-header comments (// --- Section ---, // ===== Setup =====) — use blank lines between concept groups. If headers are needed, the class has too many responsibilities.

Errors: Exceptions, not error codes. Never return null. Never pass null. Fail fast.

Classes: One reason to change. High cohesion. Law of Demeter — never chain a.getB().getC().

Organization: Stepdown rule for function ordering. Group related concepts. Blank lines between concepts. 80-120 char lines.

DRY: No duplication. But no premature abstraction for single use.

Workflow

  1. Read references (mandatory — not optional)
  2. Domain language — name the vocabulary before coding
  3. Write — functional first, using domain language
  4. Refactor — apply rules above ruthlessly
  5. Verify — every function does ONE thing, names reveal intent, no comments needed

Post-flight Check

  • Every name reveals intent without needing a comment
  • Every function does one thing, 5-20 lines, 0-2 params
  • Stepdown rule applied — entry point first, then class/helpers, read top-to-bottom like prose
  • Domain language used throughout, not generic terms
  • No null returns, no ignored exceptions
  • No dead code, no commented-out code
  • No section-header comments — blank lines separate concept groups

Pre-loaded Rules Card

The UserPromptSubmit hook injects ./references/rules-card.md — a condensed summary of ALL clean code rules (~50 lines). This is always available in your context. USE IT.

Deep Dive References (read when you need full examples)

  • ./references/functions.md — function design, stepdown rule, extraction patterns (includes Number of Islands canonical example)
  • ./references/naming.md — naming conventions with domain examples
  • ./references/classes.md — SOLID, cohesion, encapsulation
  • ./references/error-handling.md — exception patterns, null handling
  • ./references/comments.md — when to comment (almost never)
  • ./references/formatting.md — vertical/horizontal layout
  • ./references/testing.md — TDD, F.I.R.S.T. principles

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Shape reusable library APIs for Compose modules. Design public composables, split sample-app code from reusable library code, review naming and extensibility.

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

Build sample/demo screens that make library options explorable. Add controls, previews, presets, sample data, and QA surfaces in the app module.

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

Keep module structure, naming, and build configuration ready for future publishing. Handle new Gradle modules, library metadata, namespace and artifact readiness.

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

Implement Google's Material Design 3 (Material You) UI system. Primary: Jetpack Compose Material3 (MaterialTheme, components, adaptive layout). Also Flutter and limited web (@material/web, maintenance mode). Covers tokens, 30+ components, layout, theming, M3 Expressive (platform matrix), and accessibility. Use when: "material design", "MD3", "material you", "Jetpack Compose", "MaterialTheme", "material component", "md3 button".

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.

中文简介正在准备中。当前显示原文说明。

binayshaw7777/Leaflekt-Maps162026年8月8日 更新

查看 binayshaw7777 的全部技能

报告此技能的问题