Style DNA Ghostwriter
Style DNA Ghostwriter
学习代码库中未成文的约定。写出真正属于这里的代码。
问题
风格指南和代码检查工具只能强制团队写下来的规则。 而代码库真正的个性——错误如何处理、组件如何组织、偏好箭头函数还是函数声明、如何使用 Tailwind 工具类或 CSS 模块、文档字符串实际有多详细——只存在于代码本身。AI 生成的代码忽略了所有这些,默认采用通用的教科书式风格,这正是它显得格格不入的原因。
Style DNA Ghostwriter 通过像资深工程师那样学习约定来解决这个问题:阅读代码,而不是没人更新的维基页面。
$ 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
与任何编码代理兼容
一条命令即可将提取的风格注入团队使用的每个代理——无需插件,无需逐个工具配置:
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,然后将该配置文件注入标准的代理约定文件(CLAUDE.md、AGENTS.md、.cursorrules等),并用清晰的更新标记(<!-- style-dna:start -->...<!-- style-dna:end -->)包围。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 许可证 发布。
由 Kaifazad 创建 — kaifazad.in
This server cannot be installed
Maintenance
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
- Alicense-qualityDmaintenanceCode 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.55MIT
- Flicense-qualityDmaintenanceAutomatically 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.
- Alicense-qualityDmaintenanceProvides 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.115Apache 2.0
- Alicense-qualityBmaintenanceScans 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
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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