Chuyển đến nội dung
Skillpedia
Lập trình chung280k · #189

inherit-legacy-style

Skill này làm gì

Công cụ này giúp duy trì phong cách code nhất quán trong các dự án cũ. Nó phân tích code hiện có để tìm ra các quy tắc lập trình chưa được viết thành văn bản, giải quyết xung đột với bạn, và tạo một tệp chứa các quy tắc đó để AI làm theo.

Khi nào nên dùng

  • ✓Khi đưa AI vào làm việc với một dự án cũ do con người viết.
  • ✓Khi bạn muốn đảm bảo code do AI tạo ra không lệch khỏi phong cách hiện tại của dự án.
  • ✓Khi muốn chính thức hóa các quy tắc code chưa được ghi lại của dự án thành một tài liệu.

Liên kết skill

https://github.com/affaan-m/ECC/blob/main/pi/core/skills/inherit-legacy-style/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/inherit-legacy-style/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi muốn AI học phong cách của dự án cũ này để code nó tạo ra nhất quán.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ trước hết kiểm tra xem đã có tệp quy tắc hay chưa. Nếu chưa, nó quét code để tìm các mẫu chung ở nhiều khu vực (như cách tổ chức tệp, đặt tên biến, xử lý lỗi). Các xung đột được trình bày từng cái một để bạn quyết định, và các quy tắc cuối cùng được lưu vào một tệp.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Inherit Legacy Style

Prevents AI code style drift in legacy projects by scanning the codebase for implicit conventions across 4 meta-architecture dimensions, resolving conflicts with the user one at a time, and crystallizing the consensus into an enforceable .ai-style-rules.md. Fully language- and framework-agnostic.

When to Activate

  • User types /inherit-legacy-style
  • User mentions onboarding AI onto a hand-written legacy project
  • User is worried about AI-generated code "drifting" from existing project conventions
  • User wants to extract and codify their project's implicit coding rules

When to Use

Use this skill when you need to preserve legacy project style and prevent AI-generated style drift. See When to Activate above for trigger conditions.

Prerequisites

  • Git (recommended; non-Git projects fall back to file timestamps for incremental mode)
  • Read/Write access to the project root (generates .ai-style-rules.md and optionally CLAUDE.md)

Workflow

Step 0 — Auto-Detect Mode

Silently check for .ai-style-rules.md at the project root:

File exists? Mode
No Branch A — First-time Full-Scan
Yes Branch B — Incremental Sniff

Announce the mode in one line and proceed — never ask the user to pick.

Branch A — First-time Full-Scan

1. Measure scale, pick a scanning tier

git ls-files | grep -cE '\.(js|ts|jsx|tsx|vue|py|go|rs|java|kt|rb|php|cs|swift|c|cpp|h)$'
Tier Source files Strategy
Small ≲ 50 Full close-read every source
Medium 50–500 Infra layer = full read; business layer = sample 2–3 per dimension
Large ≳ 500 Strict sampling + budget cap; --stat summary first, then targeted reads

2. Scan along 4 dimensions

  1. File Anatomy — in-file declaration order (imports → types → main logic → helpers → export)
  2. State & Control Flow — naming conventions for async state, pagination, flags
  3. Infrastructure — where cross-cutting utils live (interceptors, formatters, middleware)
  4. Error Handling — try/catch vs global interceptor vs Result return; null-check habits

3. Apply signal-threshold noise reduction

Before interrupting the user, evaluate signal strength:

  • Weak signal → auto-suppress: minority <5% AND count <10 → majority wins, minority goes to DONTs
  • Strong signal → grill: near-even split, or semantic fork on a core dimension
  • Small-project exception: sources ≲50, "3 vs 2" is NOT a majority → grill it

4. Resolve conflicts one at a time (Grilling Protocol)

For each strong-signal conflict, present exactly ONE question with 4 options:

Evidence: pathA uses style X, pathB uses style Y WARNING: Risk: mixing both fractures the project style Choose: 1 follow X 2 follow Y 3 this is evolution, update rules 4 I have a new rule

Suspend until the user answers, then proceed to the next conflict. Never stack questions.

5. Generate .ai-style-rules.md with three mandatory sections:

  • [Golden Files] — real exemplar paths annotated with what they demonstrate
  • [Naming & State-Control Rules] — concrete, checkable conventions
  • [DONTs] — anti-patterns that must not propagate

6. Install the persistent hook

Ask the user for enforcement strength (use AskUserQuestion):

Option Mechanism
1 Soft hook (recommended) Write @.ai-style-rules.md reference into project CLAUDE.md
2 Hard hook Soft hook + PreToolUse[Write|Edit|MultiEdit] Hook in settings.json
3 No hook Keep the rules file; user references manually

Branch B — Incremental Sniff

  1. Read existing .ai-style-rules.md; if it has a commit fingerprint, git diff <last_hash> HEAD --stat to pinpoint delta
  2. Read recent Git changes (git log -3 --stat → inspect suspect files on demand)
  3. For oversized diffs (>hundreds of files): --stat summary only + sample the largest changes
  4. Compare new code against recorded rules → conflicts go through Grilling Protocol
  5. Append evolution log at the end of .ai-style-rules.md (never overwrite old rules)

Per-Turn Enforcement

When .ai-style-rules.md is in context (loaded via CLAUDE.md), every code-writing task must open with a compliance declaration in the reasoning chain, naming the exemplar being followed and the DONTs being avoided.

How It Works

…

Câu hỏi thường gặp

'Quy ước ngầm' là gì?

Đây là các quy ước lập trình và phong cách mà lập trình viên con người tự nhiên tuân theo trong dự án, nhưng chưa bao giờ được ghi lại chính thức.

Tệp `.ai-style-rules.md` là gì?

Đây là tài liệu công cụ tạo ra, chứa các quy tắc phong cách của dự án, ví dụ về code tốt ('Golden Files') và những điều cần tránh ('DONTs').

Công cụ có hoạt động với mọi ngôn ngữ lập trình không?

Có, công cụ không phụ thuộc vào ngôn ngữ hay framework, và tập trung vào chính các mẫu code.

Chi tiết

Mô tả gốc của tác giả

Prevent AI style drift on legacy projects by scanning the codebase for implicit conventions, resolving conflicts with the operator one at a time, and writing an enforceable .ai-style-rules.md (Golden Files, naming rules, DONTs) plus an optional CLAUDE.md hook. Use when onboarding an AI agent onto a hand-written legacy codebase or extracting a project's unwritten coding rules.

repo: affaan-m/ECC

Độ phổ biến

Sao GitHub
280k
Vị trí xếp hạng
#189
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự