本文へ移動
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(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

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 のスキルをすべて見る

このスキルの問題を報告する