clean-code skill
✓ 検証済み実装コードの生成や修正時に、単一責任の原則、命名の明快さ、複雑性の管理といったコーディング規約を適用します。
- GitHubスター
- 211
- ファイル
- 2
- 最終コミット
- 2026年10月24日
- ライセンス
- MIT
- 許可されたツール
- —
clean-code skillは何をしますか
clean-codeはAgent Skillsです。 実装コードの生成や修正時に、単一責任の原則、命名の明快さ、複雑性の管理といったコーディング規約を適用します。.
skillのSKILL.mdから生成された要約。
clean-code skill について
コーディングプロセスにおいて、実装の品質を高く維持することがこのSKILLの主な機能です。個々のコードユニットが、命名の明快さ、単一責任、複雑性の管理に関する厳格な基準に従う必要がある開発者向けに設計されています。ユーザーがコード品質の向上や特定のコーディングガイドラインを要求すると、code-forge、refactor-safely、bug-fix といった特化型エージェントによって自動的にロードされます。
このツールは、広範なアーキテクチャやセキュリティに焦点を当てるのではなく、特定の関数や変数の記述という「職人技」を管理します。設定システムを通じて .lattice/config.yaml を読み込み、カスタム基準や、エラーハンドリングおよび型システムに関する言語固有の慣習を適用します。このSKILLは、自己検証チェックリストを使用して関数のサイズ、循環的複雑性、パラメータ数を監視し、コードが自己文書化されており、テストが容易な状態であることを保証します。また、深いネスト、不明瞭な命名、エラーの握りつぶしといったアンチパターンを能動的にスキャンし、技術的負債がコードベースに混入するのを防ぎます。
エージェントができること
- 1関数における単一責任の強制複数のタスクを実行している大きな関数を、より小さく集中したユニットにリファクタリングするようエージェントに依頼します。
- 2循環的複雑性の低減特定のコードブロック内にある複雑な条件ロジックを簡素化するようエージェントに依頼します。
- 3変数および関数の命名の改善追加のコメントがなくても意図が明確になるよう、変数や関数の名前を変更するようAIに指示します。
skill の SKILL.md から作成されています。すべてのユースケースは、その引用と照合されています。
clean-code skillのインストール方法
各コマンドはskillフォルダをクライアントのskillsディレクトリにコピーします。読み込むには、クライアントを再起動するか新しいセッションを開始してください。プラグインにclean-code skillをインストールする
/plugin marketplace add techygarg/lattice /plugin install lattice@lattice
Claude Codeにclean-code skillをインストールする
~/.claude/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.claude/skills/clean-codeClaude Code (project)にclean-code skillをインストールする
.claude/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code .claude/skills/clean-codeCodexにclean-code skillをインストールする
~/.agents/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.agents/skills/clean-codeGemini CLIにclean-code skillをインストールする
~/.gemini/skills/clean-code/SKILL.md
$ npx degit techygarg/lattice/skills/clean-code ~/.gemini/skills/clean-codeClaude.aiにclean-code skillをインストールする
npx degit techygarg/lattice/skills/clean-code clean-code && zip -r clean-code.zip clean-code # claude.ai → Customize → Skills → + → Create skill → Upload a skill → clean-code.zip
自動チェック
実行日 2026年11月15日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。エージェントに実行させる前にスクリプトを読んでください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能techygarg/lattice/skills/clean-code is public and reachablegithub.com/techygarg/lattice/tree/HEAD/skills/clean-code ↗合格
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit 2026-10-24github.com/techygarg/lattice/commits ↗合格
- スクリプトにダウンロード実行や認証情報の窃取がないNo scripts in the skill folder合格
- SKILL.md に隠れた指示がないNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/techygarg/lattice/blob/HEAD/skills/clean-code/SKI ↗合格
- 事前許可ツールが限定されているNo pre-approved tools; the agent asks before using onegithub.com/techygarg/lattice/blob/HEAD/skills/clean-code/SKI ↗合格
- SKILL.md が Agent Skills の形式に従っているValid name and description; says when to use it; 65 linesgithub.com/techygarg/lattice/blob/HEAD/skills/clean-code/SKI ↗合格
SKILL.md
GitHubで表示Clean Code
Config Resolution
Projects can customize this skill's standards. Resolution order:
- Read
.lattice/config.yamlin the repo root. - If found, check
paths.clean_codefor a custom document path. - If a custom document exists at that path, read it and check its YAML frontmatter for
mode:mode: override: the custom document has full precedence. Use it instead of the embedded defaults. It must be comprehensive -- treat it as the sole reference.mode: overlay(or no mode field): read the embedded./references/defaults.mdfirst, then apply the custom document's sections on top. A custom section replaces the matching default section (matched by exact heading); new sections append after the defaults.
- If a custom path is configured but no document exists at it → tell the user which configured path is missing, then fall back to
./references/defaults.md. - If there is no config file or no
paths.clean_codekey, read./references/defaults.md. - Language adaptation: if
paths.language_idiomsis set in the config and the document exists, read it and adapt the defaults using these sections:- "Error Handling" → adapt §8 (Error Handling) patterns to the language's idioms. Language idioms take precedence over the pseudocode defaults.
- "Type System & Object Model" → adapt §1 (Single Responsibility) cohesion guidance to the language's constructs (e.g., struct vs class).
- "Naming Conventions" → adapt §4 (Meaningful Naming) patterns to the language's conventions.
- "Parameter & Function Design" → adapt §2 (Small, Focused Functions) and §5 (Parameter Design) to the language's capabilities.
- "Dependency Management" → adapt §9 (Test-Friendly Code) dependency-injection patterns to the language's idioms.
Self-Validation Checklist
STOP after generating each component. Verify ALL checks. Fix every failed check before presenting. Judgment calls → present options (see Ambiguity Signals).
- SINGLE RESPONSIBILITY: Can you describe each function without "and"? If not → extract a separate function.
- SIZE: Is each function under the size threshold from the loaded doc (~20 lines default)? If not → extract a sub-operation into its own named function.
- COMPLEXITY: Is cyclomatic complexity under the threshold from the loaded doc (~10 default)? If not → flatten with a guard clause or extract a branch.
- ABSTRACTION LEVEL: Does each function operate at one level of abstraction? If high-level logic mixes with low-level detail → extract the detail.
- NAMING: Does each function/variable name reveal intent without needing surrounding context? If not → rename to be self-documenting.
- PARAMETERS: Is the parameter count under the threshold from the loaded doc (4 default)? If not → group parameters into an object.
- PRIMITIVE OBSESSION: Would a string/number/boolean be clearer as a named type? If so → introduce a parameter object or typed wrapper.
- ERROR HANDLING: Does every fail-able operation have explicit handling with an actionable message? Is it handled at the right level?
Project-specific checks: if the loaded doc (from Config Resolution) contains a Validation Checklist section (§10 from the clean-code-refiner template), apply those checks as additional project-specific validation after the checklist above.
All checks pass → state "Passes clean-code. [next step]."
Active Anti-Pattern Scan
After the checklist, scan for each of these. Any box you can check → fix before presenting.
- God Function: a function exceeds ~30 lines doing multiple things; describing it requires "and" → extract focused functions.
- Deep Nesting: three or more levels of indentation → flatten with early returns / guard clauses.
- Cryptic Naming: variables like
d,tmp2,processData→ rename to reveal intent. - Long Parameter Lists: five or more parameters → group into an object or split the function.
- Premature Abstraction: a utility extracted from only two similar blocks → inline it until the Rule of Three (third instance with the same reason to change).
- Swallowed Errors: empty catch blocks, generic "something went wrong" messages, silent null returns → handle explicitly.
- Comments as Deodorant: a comment explains convoluted code instead of the code being fixed → rename to self-document; keep only "why" comments, remove "what" comments.
- Hidden Side Effects: a function named
getXalso writes a cache or sends notifications → rename or separate the concern. - Dead Code: commented-out blocks, unused imports, unreachable branches → delete them (version control preserves history).
- Untestable Logic: side effects tangled with business logic; unit testing requires mocking I/O → push side effects to the boundary, extract pure functions, inject dependencies.
Ambiguity Signals
Multiple valid outcomes exist. Present the options rather than silently choosing. If framework:collaborative-judgment is loaded, use its presentation format. See ./references/defaults.md for resolution guidance on each signal below.
- Single Responsibility: two tightly-coupled sequential operations may be one responsibility (a pipeline), not two. The "and" test catches true violations AND false positives.
- Function Size: near-threshold size (20–30 lines) with one clear purpose -- extraction may create five unclear smaller functions. Present the tradeoff.
- DRY vs Premature Abstraction: two identical blocks may serve different purposes and diverge independently. Until a third instance with the same reason to change appears, this is genuinely ambiguous.
- Error Handling Strategy: exception vs Result type vs error codes depends on language idiom and team convention, not on universal rules.
このスキルのファイル
2clean-code skillに関する質問
Claude Codeにclean-code skillをインストールするには
npx degit techygarg/lattice/skills/clean-code ~/.claude/skills/clean-codeを実行してください。Claude Codeは~/.claude/skills(すべてのプロジェクト)または.claude/skills(単一プロジェクト)からskillsを読み込み、説明がタスクに一致する場合にskillを使用します。
clean-code skillはどのクライアントで使用できますか
Agent Skills形式を読み込むすべてのクライアントで使用できます: Claude Code、Codex、Gemini CLI、claude.ai(ZIPとしてアップロード)。skill内のスクリプトは、クライアントがコード実行を許可した場合にのみ実行されます。
関数のサイズと複雑性のデフォルトのしきい値は何ですか?
デフォルトでは、関数は約20行以内であり、循環的複雑性が約10未満に保たれている必要があります。
プロジェクトごとにクリーンコードの基準をカスタマイズできますか?
.lattice/config.yaml でカスタムドキュメントのパスを定義することでカスタマイズ可能です。完全に優先させる 'override' モード、またはデフォルトを補完する 'overlay' モードのいずれかを使用できます。