Style DNA Ghostwriter
Style DNA Ghostwriter
コードベースの暗黙の慣習を学ぶ。属するコードをゴーストライトする。
問題点
スタイルガイドやリンターは、チームがわざわざ書き留めたルールだけを強制します。 コードベースの本当の個性 — エラーの処理方法、コンポーネントの構成方法、 アロー関数と関数宣言のどちらが好まれるか、Tailwind ユーティリティや CSS モジュールの使用方法、 ドキュメント文字列の実際の冗長性 — はコード自体以外にはどこにも存在しません。 AI が生成したコードはこれらすべてを無視し、一般的な教科書的なスタイルにデフォルト設定されるため、 それがまさに「なじんでいない」と目立つ原因になります。
Style DNA Ghostwriter は、新しい上級エンジニアが学ぶのと同じ方法で慣習を学習することでこれを修正します。 つまり、誰も更新していない Wiki ページではなく、コードを読むのです。
$ style-dna analyze ./my_web_app
Analyzed 42 files from './my_web_app' (0 Python, 42 Web).
Style profile saved to: style_profile.json
## Web Conventions
- Detected frameworks/tools: Next.js, React, Tailwind CSS, TypeScript.
### JavaScript / TypeScript
- Use single quotes for JS/TS strings.
- Omit semicolons at end of statements.
- Prefer arrow functions (`const fn = () => {}`).
- Prefer named exports.
- Use path aliases (`@/...`) for imports instead of deep relative paths.
- Prefer `interface` over `type` for object shapes in TypeScript.
### React / Next.js
- Next.js routing: App Router (`app/`).
- Define React components as arrow functions (`const Button = () => ...`).
- Component file naming: PascalCase.
- ~40% of components use 'use client' directive.
- State management: zustand.
### CSS / Styling
- Styling approach: Tailwind CSS utility classes.
- Uses CSS custom properties (`var(--token-name)`) for design tokens.
- Preferred color format: HSL.Related MCP server: Coding Standards MCP Server
あらゆるコーディングエージェントと連携
抽出されたスタイルをチームが使用するすべてのエージェントに配線するコマンドは 1 つだけです — プラグインもツールごとの設定も不要です:
style-dna initこれにより、エージェントがセッション開始時にすでに読み取る規則ファイルにルールが直接書き込まれます:
ファイル | 自動読み取り元 |
| Google Antigravity & Gemini Code Assist |
| Claude Code |
| Google Antigravity, Codex, OpenCode, および AGENTS 標準に従うツール |
| Cursor |
| Windsurf |
| GitHub Copilot |
Model Context Protocol を話すエージェント (Claude Code、Cursor など) の場合、
style-dna init は貼り付け可能な MCP 設定も出力するため、エージェントは静的ファイルの代わりにライブでルールを取得できます:
{
"mcpServers": {
"style-dna": {
"command": "style-dna",
"args": ["mcp"]
}
}
}公開される MCP ツール: analyze_repo、get_style_rules、refresh_style_profile。
抽出される内容
スタック / カテゴリ | 抽出されるシグナル |
Python | 関数/変数のケーススタイル、プライベートプレフィックス率 ( |
JavaScript / TypeScript | セミコロン ( |
React / Next.js | App Router ( |
CSS & スタイリング | Tailwind CSS vs CSS Modules ( |
HTML | インデントスタイル (2 スペース / 4 スペース / タブ)、属性引用符スタイル ( |
仕組み
analyzeはコードベースを走査し、外部バイナリやコンパイラの依存関係なしにすべてのソースファイルを分析します。プラグイン可能な専用エクストラクタースイートが解析木とソーストークンに対して実行され、StyleProfile— 構造化されバージョン管理可能なフィンガープリント — をstyle_profile.jsonとして保存します。initはanalyzeを実行し、そのプロファイルを更新用のクリーンマーカー (<!-- style-dna:start -->...<!-- style-dna:end -->) で囲んで標準のエージェント規則ファイル (CLAUDE.md、AGENTS.md、.cursorrulesなど) に注入します。generate(オプション) はプロファイルをシステムプロンプトに変換し、直接 Claude API を呼び出します。これはターミナルからゴーストライトされたコードを必要とするチーム向けです。
style-dna-ghostwriter/
├── style_dna/
│ ├── analyzer.py # multi-language codebase scanner
│ ├── profile.py # StyleProfile data model + save/load + multi-stack rules
│ ├── generator.py # profile -> system prompt -> Claude API call
│ ├── mcp_server.py # MCP server exposing tools for agents
│ ├── conventions.py # upserts rules into CLAUDE.md/AGENTS.md/.cursorrules/etc.
│ ├── cli.py # `style-dna` CLI (init, analyze, show, generate, mcp)
│ └── extractors/ # Python, JS/TS, React/Next.js, CSS/Tailwind, HTML
├── examples/
│ ├── sample_repo/ # Python test fixture
│ └── sample_web_repo/ # Next.js 14 + React TSX + Tailwind test fixture
└── tests/ # Complete test suiteインストール
# Core only (zero external dependencies):
pip install -e .
# With MCP server support:
pip install -e ".[mcp]"
# With direct Claude code generation support:
pip install -e ".[generate]"
# All features:
pip install -e ".[all]"使用方法
# One-shot setup for any repo (Python, React, Next.js, etc.):
style-dna init
# Inspect codebase style rules:
style-dna analyze ./my_repo --out style_profile.json
style-dna show style_profile.json
style-dna show style_profile.json --format json
# Direct generation (requires ANTHROPIC_API_KEY):
export ANTHROPIC_API_KEY=sk-...
style-dna generate style_profile.json \
"Write a React component that displays a product card with add to cart button" \
--out ProductCard.tsxPython ライブラリとして:
from style_dna import analyze_codebase
from style_dna.generator import generate_code
profile = analyze_codebase("./my_repo")
code = generate_code(profile, "Add a custom hook to manage user favorites")テスト
pip install -e ".[dev]"
python -m pytest tests/ -vライセンス
MIT ライセンス の下で公開されています。
作成者: Kaifazad — kaifazad.in
This server cannot be deployed
Maintenance
Related MCP Connectors
Serves your design system and coding standards to coding agents, so they stop guessing.
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
Repo intel for AI coding agents: overview, PRs, contributors, hot files, CI, deps. Remote MCP.
Zero-install security baseline for AI coding agents — OWASP/CWE-cited rules over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceCode linting and style checking tools for AI agents, exposed as an MCP server. Supports style checks, naming conventions, complexity analysis, dead code detection, and import analysis.41 npmMIT
- FlicenseNot gradedqualityDmaintenanceAutomatically enforces team coding standards in AI-assisted development by providing an MCP server that AI assistants can query for language-specific standards, style guides, and best practices.-
- AlicenseNot gradedqualityDmaintenanceProvides a CLI and MCP server for scanning repositories to generate evidence-backed, project-specific instruction files for AI coding assistants, ensuring AI behavior aligns with existing codebase conventions.1 npm15Apache 2.0
- AlicenseNot gradedqualityDmaintenanceScans your source code using AST analysis to detect coding conventions, error handling, API patterns, and more, then generates a CONVENTIONS.md file to help AI agents follow your project's style.MIT