code-style-enforcer
コードのスタイルがプロジェクトの規則に沿っているかをチェックし、自動整形ツールでは対応できない細かな部分も修正することで、コード全体の品質と一貫性を高めるSkill。
📜 元の英語説明(参考)
Analyzes code for style consistency and applies project-specific formatting conventions beyond what linters catch. Use when reviewing code, ensuring style consistency, or when user requests code style improvements.
🇯🇵 日本人クリエイター向け解説
コードのスタイルがプロジェクトの規則に沿っているかをチェックし、自動整形ツールでは対応できない細かな部分も修正することで、コード全体の品質と一貫性を高めるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o code-style-enforcer.zip https://jpskill.com/download/18102.zip && unzip -o code-style-enforcer.zip && rm code-style-enforcer.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18102.zip -OutFile "$d\code-style-enforcer.zip"; Expand-Archive "$d\code-style-enforcer.zip" -DestinationPath $d -Force; ri "$d\code-style-enforcer.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
code-style-enforcer.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
code-style-enforcerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Code Style Enforcer
このスキルは、自動化されたリンターが見落とす可能性のある、プロジェクト固有のスタイル規約とパターンにコードが準拠していることを保証します。
このスキルを使用する場面
- ユーザーがコードスタイルのレビューまたは改善を要求した場合
- コードベース全体の一貫性を確保する場合
- 新しいコードまたはコントリビューターをオンボーディングする場合
- プリコミットコードレビュー
- ユーザーが "style"、"consistency"、"formatting"、または "conventions" に言及した場合
指示
1. プロジェクトのスタイルガイドを検出する
スタイルの設定ファイルを探します。
JavaScript/TypeScript:
.eslintrc.*- ESLint の設定.prettierrc.*- Prettier の設定tsconfig.json- TypeScript コンパイラーのオプション.editorconfig- エディターの設定
Python:
.pylintrc,pylint.cfg- Pylintpyproject.toml- Black, isort の設定.flake8- Flake8 の設定setup.cfg- さまざまなツールの設定
Ruby:
.rubocop.yml- RuboCop の設定
Go:
go.fmtが強制されます (標準).golangci.yml- GolangCI-Lint
Java:
checkstyle.xml- Checkstyle.editorconfig
一般:
CONTRIBUTING.md- 貢献のガイドラインSTYLE_GUIDE.md- プロジェクトのスタイルガイド.editorconfig- クロスエディターの設定
Glob を使用してこれらのファイルを見つけ、Read を使用してプロジェクトのスタイルの好みを理解します。
2. 既存のコードパターンを分析する
既存のコードをサンプリングして、暗黙の規約を理解します。
ファイルの構成:
- ディレクトリ構造のパターン
- ファイルの命名規則 (camelCase, kebab-case, snake_case)
- インポート/エクスポートの構成
コードの構造:
- クラス/関数の順序
- public と private メソッドの配置
- 定数/変数の宣言場所
フォーマット:
- インデント (スペース vs タブ、サイズ)
- 行の長さの制限
- 空行の使用
- コメントのスタイル
命名:
- 変数の命名 (camelCase, snake_case)
- クラスの命名 (PascalCase, 大文字化)
- 定数の命名 (UPPER_CASE, など)
- ファイルの命名パターン
Grep を使用して、類似のファイル全体で共通のパターンを見つけます。
3. リンターを超えて: パターンをチェックする
自動化されたツールが見落としがちなスタイルの問題に焦点を当てます。
命名の一貫性:
- ブール変数:
is,has,shouldプレフィックス - イベントハンドラー:
handle*,on*パターン - ゲッター/セッター:
get*,set*の一貫性 - コレクションの命名: 複数形 vs 単数形
- 頭字語: 一貫した大文字化
コードの構成:
- 関連する関数をグループ化する
- モジュール全体で一貫したファイル構造
- 論理的な順序 (public が private の前など)
- 関心の分離
コメントとドキュメント:
- JSDoc/docstring の完全性
- コメントスタイルの整合性
- TODO/FIXME の形式
- インライン vs ブロックコメント
インポート/エクスポートのパターン:
- インポートの順序 (外部、内部、相対)
- 名前付き vs デフォルトのエクスポート
- 分割代入の一貫性
- エイリアスのパターン
エラー処理:
- 一貫したエラーメッセージの形式
- エラークラスの使用
- Try/catch のパターン
- ログの形式
型の使用 (TypeScript/型付き言語):
- 明示的な型 vs 推論された型
interfacevstypeの好み- ジェネリックの命名 (T, K, V vs 説明的)
- Null/undefined の処理
4. 一般的なアンチパターンを特定する
コードの臭いとアンチパターンにフラグを立てます。
マジックナンバー:
// 悪い例
if (status === 200) { }
// 良い例
const HTTP_OK = 200;
if (status === HTTP_OK) { }
一貫性のない null チェック:
// 一貫性がない
if (user === null) { }
if (!data) { }
if (typeof result === 'undefined') { }
// 一貫性がある
if (user === null) { }
if (data === null) { }
if (result === undefined) { }
ネストされた三項演算子:
// 読みにくい
const value = a ? b ? c : d : e;
// より良い
let value;
if (a) {
value = b ? c : d;
} else {
value = e;
}
長いパラメーターリスト:
# メンテナンスが難しい
def create_user(name, email, age, address, phone, ...):
# より良い
def create_user(user_data: UserData):
5. プロジェクト固有の規約を確認する
このプロジェクトに固有のパターンを探します。
- 特定のドメインのカスタム命名 (例: "repo" vs "repository")
- 一般的なタスクに推奨されるライブラリ
- アーキテクチャパターン (MVC、サービス層など)
- テストファイルの命名と構造
- 設定パターン
CONTRIBUTING.md、README.md、または同様のドキュメントを読んで、明示的なガイドラインを確認してください。
6. スタイルの推奨事項を生成する
各問題について、以下を提供します。
現在のコード:
function getData(id) {
const d = fetch('/api/users/' + id);
return d;
}
問題:
- 一貫性のない命名 (
getDatavs 他の関数はfetch*を使用) - 一文字の変数名 (
d) - テンプレートリテラルではなく文字列連結
推奨:
function fetchUser(id) {
const userData = fetch(`/api/users/${id}`);
return userData;
}
7. 問題に優先順位を付ける
影響によって順序付けします。
優先度高 (一貫性):
- 類似の関数間での命名の不整合
- 混在したインデントまたはフォーマット
- 一貫性のないエラー処理
優先度中 (可読性):
- マジックナンバー/文字列
- 不明瞭な変数名
- ドキュメントの欠落
優先度低 (あると良い):
- コメントのフォーマット
- インポートの順序
- 余分な空行
8. 自動化されたツールを提案する
スタイルを強制するためのツールを推奨します。
JavaScript/TypeScript:
npm install --save-dev prettier eslint
npx prettier --write .
npx eslint --fix .
Python:
pip install black isort flake8
black .
isort .
Go:
go fmt ./...
golangci-lint run
Ruby:
gem install rubocop
rubocop -a
9. EditorConfig を作成または更新する
.editorconfig がない場合は提案します。
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,ts,jsx,tsx}]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
[*.go]
indent_style = tab
10. スタイルレビューチェックリスト
コードのスタイルをレビューするとき:
- [ ] 命名はプロジェクトの規約に従っている
- [ ] インデントとフォーマットは一貫している
- [ ] インポートは適切に整理されている
- [ ] コメントは必要な場所にあり、過剰ではない
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Code Style Enforcer
This skill ensures code follows project-specific style conventions and patterns that automated linters may miss.
When to Use This Skill
- User requests code style review or improvements
- Ensuring consistency across the codebase
- Onboarding new code or contributors
- Pre-commit code review
- User mentions "style", "consistency", "formatting", or "conventions"
Instructions
1. Detect Project Style Guides
Look for style configuration files:
JavaScript/TypeScript:
.eslintrc.*- ESLint configuration.prettierrc.*- Prettier configurationtsconfig.json- TypeScript compiler options.editorconfig- Editor configuration
Python:
.pylintrc,pylint.cfg- Pylintpyproject.toml- Black, isort configuration.flake8- Flake8 configurationsetup.cfg- Various tool configs
Ruby:
.rubocop.yml- RuboCop configuration
Go:
go.fmtenforced (standard).golangci.yml- GolangCI-Lint
Java:
checkstyle.xml- Checkstyle.editorconfig
General:
CONTRIBUTING.md- Contribution guidelinesSTYLE_GUIDE.md- Project style guide.editorconfig- Cross-editor settings
Use Glob to find these files and Read to understand the project's style preferences.
2. Analyze Existing Code Patterns
Sample existing code to understand implicit conventions:
File organization:
- Directory structure patterns
- File naming conventions (camelCase, kebab-case, snake_case)
- Import/export organization
Code structure:
- Class/function ordering
- Public vs private method placement
- Constant/variable declaration location
Formatting:
- Indentation (spaces vs tabs, size)
- Line length limits
- Blank line usage
- Comment styles
Naming:
- Variable naming (camelCase, snake_case)
- Class naming (PascalCase, capitalization)
- Constant naming (UPPER_CASE, etc.)
- File naming patterns
Use Grep to find common patterns across similar files.
3. Beyond Linters: Check for Patterns
Focus on style issues that automated tools often miss:
Naming Consistency:
- Boolean variables:
is,has,shouldprefixes - Event handlers:
handle*,on*patterns - Getters/setters:
get*,set*consistency - Collection naming: plural vs singular
- Acronyms: consistent capitalization
Code Organization:
- Related functions grouped together
- Consistent file structure across modules
- Logical ordering (public before private, etc.)
- Separation of concerns
Comments and Documentation:
- JSDoc/docstring completeness
- Comment style consistency
- TODO/FIXME format
- Inline vs block comments
Import/Export Patterns:
- Import ordering (external, internal, relative)
- Named vs default exports
- Destructuring consistency
- Aliasing patterns
Error Handling:
- Consistent error message format
- Error class usage
- Try/catch patterns
- Logging format
Type Usage (TypeScript/typed languages):
- Explicit vs inferred types
interfacevstypepreference- Generic naming (T, K, V vs descriptive)
- Null/undefined handling
4. Identify Common Anti-Patterns
Flag code smells and anti-patterns:
Magic Numbers:
// Bad
if (status === 200) { }
// Good
const HTTP_OK = 200;
if (status === HTTP_OK) { }
Inconsistent null checks:
// Inconsistent
if (user === null) { }
if (!data) { }
if (typeof result === 'undefined') { }
// Consistent
if (user === null) { }
if (data === null) { }
if (result === undefined) { }
Nested ternaries:
// Hard to read
const value = a ? b ? c : d : e;
// Better
let value;
if (a) {
value = b ? c : d;
} else {
value = e;
}
Long parameter lists:
# Hard to maintain
def create_user(name, email, age, address, phone, ...):
# Better
def create_user(user_data: UserData):
5. Check Project-Specific Conventions
Look for patterns unique to this project:
- Custom naming for specific domains (e.g., "repo" vs "repository")
- Preferred libraries for common tasks
- Architectural patterns (MVC, service layer, etc.)
- Test file naming and structure
- Configuration patterns
Read CONTRIBUTING.md, README.md, or similar docs for explicit guidelines.
6. Generate Style Recommendations
For each issue, provide:
Current code:
function getData(id) {
const d = fetch('/api/users/' + id);
return d;
}
Issue:
- Inconsistent naming (
getDatavs other functions usefetch*) - Single-letter variable name (
d) - String concatenation instead of template literals
Recommended:
function fetchUser(id) {
const userData = fetch(`/api/users/${id}`);
return userData;
}
7. Prioritize Issues
Order by impact:
High Priority (Consistency):
- Naming inconsistencies across similar functions
- Mixed indentation or formatting
- Inconsistent error handling
Medium Priority (Readability):
- Magic numbers/strings
- Unclear variable names
- Missing documentation
Low Priority (Nice-to-have):
- Comment formatting
- Import ordering
- Extra blank lines
8. Suggest Automated Tools
Recommend tools to enforce styles:
JavaScript/TypeScript:
npm install --save-dev prettier eslint
npx prettier --write .
npx eslint --fix .
Python:
pip install black isort flake8
black .
isort .
Go:
go fmt ./...
golangci-lint run
Ruby:
gem install rubocop
rubocop -a
9. Create or Update EditorConfig
Suggest .editorconfig if missing:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,ts,jsx,tsx}]
indent_style = space
indent_size = 2
[*.py]
indent_style = space
indent_size = 4
[*.go]
indent_style = tab
10. Style Review Checklist
When reviewing code for style:
- [ ] Naming follows project conventions
- [ ] Indentation and formatting consistent
- [ ] Imports organized properly
- [ ] Comments where needed, not excessive
- [ ] No magic numbers or strings
- [ ] Error handling consistent
- [ ] File organization matches project structure
- [ ] No obvious code smells
- [ ] Type annotations consistent (if applicable)
- [ ] Tests follow testing conventions
Best Practices
- Consistency over perfection: Follow existing patterns even if not ideal
- Document decisions: Add style guides for ambiguous cases
- Automate where possible: Use Prettier, Black, gofmt, etc.
- Be pragmatic: Don't refactor working code just for style
- Team agreement: Align on styles that matter
- Incremental improvement: Fix styles in touched files, not all at once
- Readability first: Style serves readability, not vice versa
Common Style Conflicts
Tabs vs Spaces
- Check
.editorconfigor existing files - When in doubt, use project majority
Quote Style (Single vs Double)
- JavaScript: Single (
') common - Python: Either, be consistent
- Go: Always double (
") - Follow linter config if present
Semicolons (JavaScript)
- Check existing code majority
- If mixed, suggest Prettier to enforce
Line Length
- Common limits: 80, 100, 120 characters
- Check linter config or
.editorconfig
Import Ordering
- Usually: stdlib, external, internal, relative
- Use automated tools (isort, organize imports)
Supporting Files
reference/style-guides.md: Links to popular style guidesexamples/before-after.md: Code examples showing improvements