inherit-legacy-style
What it does
This tool helps maintain a consistent coding style in older projects. It analyzes existing code to find programming rules that haven't been formally written, resolves conflicts with you, and creates a file with these rules for the AI to follow.
When to use it
- βWhen onboarding an AI onto an old, human-written project.
- βWhen you want to ensure AI-generated code doesn't drift from the project's current style.
- βTo formalize a project's unwritten coding rules into a document.
Skill link
https://github.com/affaan-m/ECC/blob/main/pi/core/skills/inherit-legacy-style/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want the AI to learn this old project's style so generated code is consistent.β
5 new skills a week. 1 minute to read.
How it works
The tool first checks if a rules file already exists. If not, it scans the code for common patterns across different areas (like file organization, variable naming, error handling). Conflicts are presented one by one for you to decide, and the final rules are saved in a file.
Technical content (original SKILL.md)
Original text by the author, straight from 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.mdand optionallyCLAUDE.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
- File Anatomy β in-file declaration order (imports β types β main logic β helpers β export)
- State & Control Flow β naming conventions for async state, pagination, flags
- Infrastructure β where cross-cutting utils live (interceptors, formatters, middleware)
- 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:
pathAuses style X,pathBuses style Y WARNING: Risk: mixing both fractures the project style Choose:1follow X2follow Y3this is evolution, update rules4I 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
- Read existing
.ai-style-rules.md; if it has a commit fingerprint,git diff <last_hash> HEAD --statto pinpoint delta - Read recent Git changes (
git log -3 --statβ inspect suspect files on demand) - For oversized diffs (>hundreds of files):
--statsummary only + sample the largest changes - Compare new code against recorded rules β conflicts go through Grilling Protocol
- 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
β¦
FAQ
What are 'implicit conventions'?
These are the coding conventions and style that human developers naturally use in a project but were never formally documented.
What is the `.ai-style-rules.md` file?
It's a document the tool creates containing the project's style rules, examples of good code ('Golden Files'), and what to avoid ('DONTs').
Does the tool work for any programming language?
Yes, the tool is language and framework agnostic, focusing on the code patterns themselves.
Details
Original description by the author
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
Popularity
- GitHub stars
- 280k
- Ranking position
- #189
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
accessibility
280kHelps your agent create interfaces that everyone can use. Ensures websites and apps work well for people with disabilities, like those who are blind or have reduced mobility.
agent-architecture-audit
280kMakes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
agent-eval
280kHelps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
agent-harness-construction
280kMakes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.