帮助AI继承遗留项目的既有代码风格与架构习惯,持续避免风格漂移。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "inherit-legacy-style" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/inherit-legacy-style/SKILL.md 2. 保存为 ~/.claude/skills/inherit-legacy-style/SKILL.md 3. 装好后重载技能,告诉我可以用了
请执行 /inherit-legacy-style。接下来你将参与一个多年演进的手写遗留项目,请先从现有目录结构、模块边界、命名习惯、错误处理、日志方式和测试组织中归纳项目风格,并在后续所有编码任务中严格继承这些模式,避免引入主流但不一致的新范式。
先输出项目风格约束摘要,并在后续代码中持续遵循既有架构与习惯。
我要重构这个旧模块,但不要把它改造成你熟悉的标准模板。请使用 /inherit-legacy-style,基于仓库现有写法完成重构,只改善可读性与稳定性,保留原有分层思路、依赖方向和接口风格。
得到风格一致的重构方案与代码,不会突然出现陌生框架化写法。
从现在开始请启用 /inherit-legacy-style 作为后续任务的长期行为约束。无论我让你新增功能、修复缺陷还是补测试,都优先模仿当前项目的元架构和协作约定,而不是套用通用最佳实践。
AI在后续多轮开发中持续保持与遗留项目一致的实现风格。
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.
/inherit-legacy-styleUse this skill when you need to preserve legacy project style and prevent AI-generated style drift. See When to Activate above for trigger conditions.
.ai-style-rules.md and optionally CLAUDE.md)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.
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
3. Apply signal-threshold noise reduction
Before interrupting the user, evaluate signal strength:
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:
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 |
.ai-style-rules.md; if it has a commit fingerprint, git diff <last_hash> HEAD --stat to pinpoint deltagit log -3 --stat → inspect suspect files on demand)--stat summary only + sample the largest changes…
为 Quarkus 项目执行发布前验证闭环,涵盖构建、测试、扫描与差异审查。
将 Code-Me 品牌语气与视觉规范即时注入模型上下文,统一生成内容风格。