Communitygithub.com

inherit-legacy-style(レガシースタイル継承)

AIコーディングエージェントを手書きのレガシープロジェクトにオンボーディングする際に、コードベースの暗黙的な規則をスキャンし、ユーザーと合意形成しながら`.ai-style-rules.md`に結晶化することで、AIによるコードスタイルの逸脱を防止します。言語やフレームワークに依存しません。

inherit-legacy-style(レガシースタイル継承) とは?

このスキルは、AIエージェントがレガシープロジェクトに参加する際に、既存のコードスタイルからAIが無意識に逸脱してしまう問題(スタイルドリフト)を防止するためのものです。プロジェクトルートに `.ai-style-rules.md` が存在するかどうかを自動判定し、初回時(Branch A)はコードベース全体を4つのメタアーキテクチャ次元(ファイル構造、状態・制御フロー、インフラ、エラーハンドリング)でスキャンします。弱いシグナルは自動抑制し、強い競合(例:命名規則の分裂)だけをユーザーに1問ずつ尋ねて解決します。解決後は「黄金ファイル」「命名規則」「禁止事項(DONTs)」を含む `.ai-style-rules.md` を生成し、オプションで `CLAUDE.md` に自動参照を仕込みます。2回目以降(Branch B)は増分スキャンを行い、新しいコードと既存ルールの差分のみを比較して進化ログを追記します。これにより、開発者は手動でルールを管理することなく、AIにプロジェクトの一貫性を維持させることができます。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/inherit-legacy-style

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

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

ドキュメント

レガシースタイル継承

AIによるコードスタイルの逸脱を防止します。コードベースをスキャンして暗黙的な規則を4つのメタアーキテクチャ次元にわたって抽出し、ユーザーと1件ずつ合意を形成し、合意内容を強制力のある .ai-style-rules.md に結晶化します。言語・フレームワークに依存しません。

アクティベート条件

  • ユーザーが /inherit-legacy-style と入力した
  • ユーザーがAIを手書きのレガシープロジェクトにオンボーディングする話をした
  • ユーザーがAI生成コードの「既存プロジェクトの規則からの逸脱」を懸念している
  • ユーザーがプロジェクトの暗黙的なコーディング規則を抽出・文書化したい

使用すべき場面

レガシープロジェクトのスタイルを維持し、AIによるスタイル逸脱を防止したいときにこのスキルを使用します。トリガー条件については上記 アクティベート条件 を参照してください。

前提条件

  • Git(推奨。Gitがないプロジェクトでは、増分モードでファイルのタイムスタンプにフォールバックします)
  • プロジェクトルートへの読み書き権限(.ai-style-rules.md およびオプションで CLAUDE.md を生成します)

ワークフロー

ステップ 0 — 自動検出モード

プロジェクトルートに .ai-style-rules.md が存在するかを静かに確認します:

ファイルの有無モード
なしブランチ A — 初回フルスキャン
ありブランチ B — 増分スニフ

モードを一行で告知し、そのまま進みます。ユーザーに選択させることはありません。

ブランチ A — 初回フルスキャン

1. 規模を測定し、スキャンティアを選択

git ls-files | grep -cE '\.(js|ts|jsx|tsx|vue|py|go|rs|java|kt|rb|php|cs|swift|c|cpp|h)$'
ティアソースファイル数戦略
小≲ 50すべてのソースを完全に精読
中50–500インフラ層は全読、ビジネス層は次元ごとに2~3ファイルをサンプリング
大≳ 500厳密なサンプリング+予算制限。まず --stat で概要を確認し、その後対象を絞って読み取り

2. 4つの次元でスキャン

  1. ファイル構造 — ファイル内の宣言順序(import → 型 → メインロジック → ヘルパー → export)
  2. 状態と制御フロー — 非同期状態、ページネーション、フラグの命名規則
  3. インフラ — 横断的なユーティリティ(インターセプター、フォーマッター、ミドルウェア)の配置場所
  4. エラーハンドリング — try/catch かグローバルインターセプターか Result 戻り値か。nullチェックの習慣

3. シグナル閾値によるノイズ低減を適用

ユーザーに割り込む前に、シグナルの強さを評価します:

  • 弱いシグナル → 自動抑制:マイノリティが5%未満 かつ 件数が10未満 → マジョリティが勝ち、マイノリティはDONTsに
  • 強いシグナル → グリル(詳細確認):ほぼ半々の割合、またはコア次元での意味論的な分岐がある
  • 小規模プロジェクトの例外:ソース≲50で「3対2」はマジョリティと見なさない → グリルする

4. 競合を1件ずつ解決(グリリングプロトコル)

強いシグナルの競合ごとに、正確に1つの質問を4つの選択肢付きで提示します:

証拠: pathA はスタイルXを使用、pathB はスタイルYを使用 警告: リスク: 両方を混在させるとプロジェクトスタイルが崩れる 選択: 1 Xに従う 2 Yに従う 3 これは進化だ、ルールを更新する 4 新しいルールを提示する

ユーザーが回答するまで保留し、その後次の競合に進みます。質問を重ねてはいけません。

5. .ai-style-rules.md を生成 — 必須3セクション:

  • [黄金ファイル] — 実際の模範ファイルのパスと、それらが示している内容の注釈
  • [命名規則と状態制御のルール] — 具体的でチェック可能な規則
  • [DONTs] — 絶対に広まってはいけないアンチパターン

6. 永続フックをインストール

強制力のレベルをユーザーに尋ねます(AskUserQuestion を使用):

オプションメカニズム
1 ソフトフック(推奨)@.ai-style-rules.md への参照をプロジェクトの CLAUDE.md に書き込む
2 ハードフックソフトフック + settings.json の `PreToolUse[Write
3 フックなしルールファイルはそのまま。ユーザーが手動で参照

ブランチ B — 増分スニフ

  1. 既存の .ai-style-rules.md を読み取ります。コミットフィンガープリントがあれば、git diff <last_hash> HEAD --stat でデルタを特定します
  2. 最近のGit変更を読み取ります(git log -3 --stat → 疑わしいファイルをオンデマンドで検査)
  3. 巨大な差分(数百ファイル)の場合:--stat の概要のみ + 最大の変更をサンプリング
  4. 新しいコードを記録済みルールと比較 → 競合があればグリリングプロトコルを実行
  5. .ai-style-rules.md の末尾に進化ログを追記します(古いルールは上書きしない)

ターンごとの強制

.ai-style-rules.md がコンテキストにある場合(CLAUDE.md 経由でロード)、すべてのコード記述タスクは推論チェーンの中で コンプライアンス宣言 で始まり、従っている模範ファイルと回避しているDONTsを明示します。

仕組み

このスキルは、.ai-style-rules.md の有無によって初回実行か増分実行かを自動検出します:

  • 初回(ブランチ A) — プロジェクト規模を測定し、コードベースを4つのメタアーキテクチャ次元(ファイル構造、状態・制御フロー、インフラ、エラーハンドリング)でスキャンし、シグナル閾値によるノイズ低減で弱い競合を抑制し、強いシグナルの競合をユーザーと1件ずつ解決し、黄金ファイル・命名規則・DONTsを含む .ai-style-rules.md を生成し、オプションの強制フックを提供します。
  • 増分(ブランチ B) — 既存のルールを読み取り、最近のGit差分をチェックして新しいパターンや競合パターンを探し、見つかった競合に対して同じ1件ずつのグリリングプロトコルを実行し、既存ルールを上書きせずに進化ログを追記します。
  • ターンごとの強制 — CLAUDE.md を介してフックされている場合、すべてのコード記述タスクは、従っている模範ファイルと回避しているDONTsを明示するコンプライアンス宣言で始まります。

出力仕様

  • プロジェクトルートに .ai-style-rules.md(ヘッダーにコミットフィンガープリントとスケールティアを含む)
  • オプションで CLAUDE.md(@.ai-style-rules.md 参照を含む)
  • 進化ログは ### [YYYY-MM-DD] Style Evolution Log エントリとして追記

アンチパターン

  • 失敗: 規模測定ステップをスキップしてはいけません — 30ファイルのプロジェクトをサンプリングすると「情報不足」になり、5,000ファイルのリポジトリをフルスキャンすると爆発します
  • 失敗: 複数の競合質問を一度に重ねてはいけません — グリリングは厳密に1件ずつです
  • 失敗: 増分モードで古いルールを上書きしてはいけません — 常に進化ログを追記します
  • 失敗: 確認なしに「ハードフック」をデフォルトにしてはいけません — 強制力のレベルはユーザーが決めることです
  • 失敗: 構文や技術スタックの品質を判断してはいけません — このスキルはメタアーキテクチャのみを調整します
  • 失敗: 模範ファイルからバグをコピーしてはいけません — 構造を再利用し、欠陥は報告します

ベストプラクティス

  • スキャン前に検出したモード(初回か増分か)とスケールティアを一行で告知します
  • 大規模プロジェクトでは、まず --stat の概要を読み、その後対象を絞って Read を実行します
  • シグナル閾値にノイズ処理を任せます — 843対8の命名規則の分裂は、ユーザーに割り込まず自動解決させるべきです
  • シグナルの強さに迷ったときは、質問する方向に倒します
  • CLAUDE.md のソフトフック(@.ai-style-rules.md)で通常は十分です。ハードフックはユーザーが機械的な強制を望む場合のみにします。

関連スキル

  • init — コードベースのドキュメントとともに新しい CLAUDE.md を初期化する
  • code-review — 差分を正確性とスタイルの問題についてレビューする
  • simplify — コードを再利用と簡素化の機会についてレビューする

例

  1. 初回オンボーディング

    • ユーザー: 「この古いコードベースにAIをオンボーディングするのを手伝って。スタイルは変えないで。」
    • アクション: ブランチAのフルスキャンを実行 → 規模測定 → 4次元スキャン → 競合グリル → .ai-style-rules.md 生成 → フック強度(ソフト/ハード/なし)を提供。
  2. チーム変更後の増分更新

    • ユーザー: 「新しいモジュールを追加したんだ。既存のスタイルルールはそのままにしてほしい。」
    • アクション: ブランチBの増分スニフを実行 → Git差分を記録済みルールと比較 → 新たな競合をグリル → 上書きせずに進化ログを追記。
  3. CLAUDE.md を介したDONTsの強制

    • ユーザー: 「新しいコードがすべてプロジェクトのルールと一貫していることを確認して。」
    • アクション: ソフトフックがインストールされる → .ai-style-rules.md がセッションごとに自動ロード → すべてのコード記述タスクがコンプライアンス宣言で始まり、模範ファイルのパターンを再利用しDONTsを回避する。

Individual skills in this repo

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

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

関連スキル