Communitygithub.com

コードスタイル・エンフォーサー

リンターでは検出できない、プロジェクト固有の書式規則やスタイルの一貫性をコード解析でチェックします。コードレビュー時やスタイル統一の依頼があった際に使用します。

コードスタイル・エンフォーサー とは?

このスキルは、自動リンターでは見落とされがちなプロジェクト固有のスタイル規則やパターンを強制するために設計されています。JavaScript、TypeScript、Python、Ruby、Go、Java など複数の言語に対応し、.editorconfig や ESLint、Black などの設定ファイルからスタイルガイドを検出します。既存コードを分析して暗黙の命名規則やファイル構成、エラーハンドリングなどのパターンを把握し、マジックナンバーやネストされた三項演算子といったアンチパターンを特定します。優先度に基づいた修正提案を生成し、Prettier や isort などの自動ツール導入も推奨します。コードレビュー時の一貫性確保や新規コードのオンボーディングに特に有用で、「スタイル」「一貫性」「書式」などのキーワードに反応します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/code-style-enforcer

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

コードスタイル・エンフォーサー は何をしますか?

このスキルは、自動リンターでは見逃されがちなプロジェクト固有のスタイル規則やパターンに従ってコードをチェックします。

このスキルを使うタイミング

  • ユーザーがコードスタイルのレビューや改善を依頼したとき
  • コードベース全体の一貫性を確保するとき
  • 新しいコードやコントリビューターをオンボーディングするとき
  • コミット前のコードレビュー時
  • ユーザーが「スタイル」「一貫性」「書式」「規約」に言及したとき

手順

1. プロジェクトのスタイルガイドを検出する

スタイル設定ファイルを探します。

JavaScript/TypeScript:

  • .eslintrc.* - ESLint 設定
  • .prettierrc.* - Prettier 設定
  • tsconfig.json - TypeScript コンパイラオプション
  • .editorconfig - エディタ設定

Python:

  • .pylintrc, pylint.cfg - Pylint
  • pyproject.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)
  • インポート/エクスポートの構成

コード構造:

  • クラス/関数の順序
  • パブリックメソッドとプライベートメソッドの配置
  • 定数/変数の宣言場所

書式:

  • インデント(スペース 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 推論された型
  • interface vs type の優先順位
  • ジェネリックの命名(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;
}

問題点:

  • 一貫性のない命名(getData と他の関数は fetch* を使用)
  • 1文字の変数名(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. スタイルレビューのチェックリスト

コードのスタイルをレビューする際のチェックリストです。

  • 命名がプロジェクトの規則に従っている
  • インデントと書式が一貫している
  • インポートが適切に整理されている
  • 必要な場所にコメントがあり、過剰ではない
  • マジックナンバーや文字列がない
  • エラーハンドリングが一貫している
  • ファイル構成がプロジェクト構造と一致している
  • 明らかなコードの臭いがない
  • 型アノテーションが一貫している(該当する場合)
  • テストがテスト規則に従っている

ベストプラクティス

  1. 完璧よりも一貫性: たとえ理想でなくても既存のパターンに従う
  2. 決定を文書化する: 曖昧なケースにはスタイルガイドを追加する
  3. 可能な限り自動化する: Prettier、Black、gofmt などを使用する
  4. 実用的であれ: スタイルだけのために動作するコードをリファクタリングしない
  5. チームの合意: 重要なスタイルについてチームで調整する
  6. 段階的な改善: 一度にすべてのファイルではなく、変更したファイルのスタイルを修正する
  7. 可読性を最優先: スタイルは可読性のためにあり、その逆ではない

よくあるスタイルの衝突

タブ vs スペース

  • .editorconfig または既存のファイルを確認する
  • 迷ったら、プロジェクトの多数派に従う

引用符スタイル(シングル vs ダブル)

  • JavaScript: シングルクォート (') が一般的
  • Python: どちらでもよいが、一貫させる
  • Go: 常にダブルクォート (")
  • リンター設定があればそれに従う

セミコロン(JavaScript)

  • 既存コードの多数派を確認する
  • 混在している場合は、Prettier で統一することを提案する

行の長さ

  • 一般的な制限: 80、100、120 文字
  • リンター設定または .editorconfig を確認する

インポート順序

  • 通常: 標準ライブラリ、外部、内部、相対
  • 自動ツール(isort、organize imports)を使用する

付属ファイル

  • reference/style-guides.md: 有名なスタイルガイドへのリンク
  • examples/before-after.md: 改善を示すコード例

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル