Skip to main content
Glama
Kaifazad

Style DNA Ghostwriter

by Kaifazad

Style DNA Ghostwriter

コードベースの暗黙の慣習を学ぶ。属するコードをゴーストライトする。

ライセンス: MIT Python テスト


問題点

スタイルガイドやリンターは、チームがわざわざ書き留めたルールだけを強制します。 コードベースの本当の個性 — エラーの処理方法、コンポーネントの構成方法、 アロー関数と関数宣言のどちらが好まれるか、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

これにより、エージェントがセッション開始時にすでに読み取る規則ファイルにルールが直接書き込まれます:

ファイル

自動読み取り元

GEMINI.md

Google Antigravity & Gemini Code Assist

CLAUDE.md

Claude Code

AGENTS.md

Google Antigravity, Codex, OpenCode, および AGENTS 標準に従うツール

.cursorrules

Cursor

.windsurfrules

Windsurf

.github/copilot-instructions.md

GitHub Copilot

Model Context Protocol を話すエージェント (Claude Code、Cursor など) の場合、 style-dna init は貼り付け可能な MCP 設定も出力するため、エージェントは静的ファイルの代わりにライブでルールを取得できます:

{
  "mcpServers": {
    "style-dna": {
      "command": "style-dna",
      "args": ["mcp"]
    }
  }
}

公開される MCP ツール: analyze_repoget_style_rulesrefresh_style_profile


抽出される内容

スタック / カテゴリ

抽出されるシグナル

Python

関数/変数のケーススタイル、プライベートプレフィックス率 (_name)、ドキュメント文字列スタイル (Google/NumPy/reST/プレーン) とカバレッジ、型ヒント率、エラー処理 (広範 vs 特定 vs カスタム例外)、引用符スタイル、インポート順序、平均関数長、共通パターン (@dataclassProtocolasync など)

JavaScript / TypeScript

セミコロン (always vs never)、引用符スタイル (single / double)、アロー関数 vs 関数宣言、名前付きエクスポート vs デフォルトエクスポート、インポートパスエイリアス (@/...)、TypeScript interface vs type の優先、型付けカバレッジ、コメントスタイル (JSDoc/インライン/ブロック)

React / Next.js

App Router (app/) vs Pages Router (pages/)、サーバーコンポーネント vs クライアントコンポーネント ('use client' 率)、サーバーアクション ('use server')、コンポーネントスタイル、カスタムフックパターン (use*)、状態管理 (Zustand、Redux、Context、TanStack Query、SWR、Jotai、Recoil)、フレームワーク検出

CSS & スタイリング

Tailwind CSS vs CSS Modules (*.module.css) vs CSS-in-JS vs Vanilla CSS、クラス命名規則 (BEM / kebab-case / camelCase)、CSS カスタムプロパティデザイントークン (var(--token))、カラーフォーマット (HEX、HSL、RGB)

HTML

インデントスタイル (2 スペース / 4 スペース / タブ)、属性引用符スタイル (" vs ')、セマンティックマークアップ使用率 (<header><main><section> など)


仕組み

  1. analyze はコードベースを走査し、外部バイナリやコンパイラの依存関係なしにすべてのソースファイルを分析します。プラグイン可能な専用エクストラクタースイートが解析木とソーストークンに対して実行され、StyleProfile — 構造化されバージョン管理可能なフィンガープリント — を style_profile.json として保存します。

  2. initanalyze を実行し、そのプロファイルを更新用のクリーンマーカー (<!-- style-dna:start --> ... <!-- style-dna:end -->) で囲んで標準のエージェント規則ファイル (CLAUDE.mdAGENTS.md.cursorrules など) に注入します。

  3. 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.tsx

Python ライブラリとして:

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 ライセンス の下で公開されています。


作成者: Kaifazadkaifazad.in

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    D
    maintenance
    Code 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.
    55
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    Provides 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
    15
    Apache 2.0
  • A
    license
    -
    quality
    B
    maintenance
    Scans 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

View all related MCP servers

Related MCP Connectors

  • 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.

  • Hosted MCP server for structured code review passes on human- and AI-written code. Free tier.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kaifazad/Style-DNA-Ghostwriter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server