Langsung ke konten
Skillpedia
Pemrograman umum280k ยท #189

inherit-legacy-style

Fungsinya

Alat ini membantu menjaga gaya penulisan kode yang konsisten pada proyek lama. Alat ini menganalisis kode yang ada untuk menemukan aturan pemrograman yang belum pernah ditulis secara resmi, menyelesaikan konflik bersama Anda, lalu membuat file berisi aturan tersebut untuk diikuti oleh AI.

Kapan dipakai

  • โœ“Saat memperkenalkan AI ke proyek lama yang ditulis oleh manusia.
  • โœ“Saat Anda ingin memastikan kode yang dihasilkan AI tidak menyimpang dari gaya proyek saat ini.
  • โœ“Untuk mengubah aturan penulisan kode yang tidak tertulis dari sebuah proyek menjadi dokumen resmi.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/inherit-legacy-style/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œSaya ingin AI mempelajari gaya proyek lama ini agar kode yang dihasilkannya konsisten.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Alat ini pertama-tama memeriksa apakah file aturan sudah ada. Jika belum, alat akan memindai kode untuk mencari pola-pola umum di berbagai area (seperti pengaturan file, penamaan variabel, dan penanganan error). Konflik ditampilkan satu per satu agar Anda dapat memutuskannya, lalu aturan final disimpan dalam sebuah file.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

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

โ€ฆ

Pertanyaan umum

Apa itu 'implicit conventions'?

Ini adalah konvensi dan gaya penulisan kode yang secara alami digunakan oleh para pengembang dalam sebuah proyek, tetapi tidak pernah didokumentasikan secara resmi.

Apa itu file `.ai-style-rules.md`?

Ini adalah dokumen yang dibuat oleh alat ini, berisi aturan gaya proyek, contoh kode yang baik ('Golden Files'), dan hal-hal yang harus dihindari ('DONTs').

Apakah alat ini bisa digunakan untuk bahasa pemrograman apa pun?

Bisa. Alat ini tidak terikat pada bahasa atau framework tertentu dan berfokus pada pola-pola kode itu sendiri.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
280k
Peringkat
#189
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa