跳到主内容
智客 ZICQ

技能库 智客分类:写作与研究 inherit-legacy-style

Inherit Legacy Style

通过扫描暗含公约的代码库,一次解决与操作员的冲突,并写出可执行的.ai-tyle-rules.md(Golden文件,命名规则,DONTs)外加可选的CLAUDE.md钩子来防止AI风格漂移到遗留项目上. 当将AI代理机装入手写后遗存编码库或提取项目未写出编码规则时使用.

6593 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

通过扫描暗含公约的代码库,一次解决与操作员的冲突,并写出可执行的.ai-style-rules.md(Golden文件,命名规则,DONTs)外加可选的CLAUDE来防止AI风格漂移到遗留项目上. md 钩

何时用

在需要保留遗留工程风格并防止AI生成风格漂移时使用此技能. 见 ** 何时启动** 触发条件

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Inherit Legacy Style、When to Activate、When to Use、Prerequisites、Workflow、Step 0 — Auto-Detect Mode。 其中含规范建议的小节:分步指令。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

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.

Inherit Legacy StyleWhen to ActivateWhen to UsePrerequisitesWorkflowStep 0 — Auto-Detect ModeBranch A — First-time Full-ScanBranch B — Incremental SniffPer-Turn EnforcementHow It WorksOutput SpecificationAnti-Patterns

· allowed-tools:Read, Glob, Grep, Bash, Edit, Write, AskUserQuestion

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
inherit-legacy-style
description
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.
allowed-tools
Read, Glob, Grep, Bash, Edit, Write, AskUserQuestion实验字段,支持情况取决于客户端;字段声明本身不会授予工具权限。
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「inherit-legacy-style」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-eb8b30e91c7b57e7-%E7%BB%A7%E6%89%BF%E9%81%97%E4%BA%A7%E6%A0%B7%E5%BC%8F.html
请存为 .cursor/skills/inherit-legacy-style/SKILL.md 或 .claude/skills/inherit-legacy-style/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/affaan-m/ecc' --list

npx skills add 'https://github.com/affaan-m/ecc' --skill 'inherit-legacy-style'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: inherit-legacy-style description: 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. metadata: origin: community allowed-tools: Read, Glob, Grep, Bash, Edit, Write, AskUserQuestion --- # 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** ```bash 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 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 This skill auto-detects whether it's a first-time or incremental run via `.ai-style-rules.md` presence: - **First-time (Branch A)** — Measures project scale, scans codebase across 4 meta-architecture dimensions (File Anatomy, State & Control Flow, Infrastructure, Error Handling), applies signal-threshold noise reduction to suppress weak conflicts, resolves strong-signal conflicts one-at-a-time with the user, generates `.ai-style-rules.md` with Golden Files / Naming Rules / DONTs, and offers optional enforcement hooks. - **Incremental (Branch B)** — Reads existing rules, checks recent Git diffs for new or conflicting patterns, runs the same one-at-a-time grilling protocol for any conflicts found, and appends evolution logs without overwriting existing rules. - **Per-Turn Enforcement** — When hooked via `CLAUDE.md`, every code-writing task opens with a compliance declaration naming the exemplar followed and the DONTs avoided. ## Output Specification - `.ai-style-rules.md` at project root (with commit fingerprint + scale tier in header) - Optionally `CLAUDE.md` with `@.ai-style-rules.md` reference - Evolution logs appended as `### [YYYY-MM-DD] Style Evolution Log` entries ## Anti-Patterns - FAIL: Do NOT skip the scale measurement step — sampling a 30-file project "starves" it; full-scanning a 5,000-file repo blows up - FAIL: Do NOT stack multiple conflict questions at once — grilling is strictly one-at-a-time - FAIL: Do NOT overwrite old rules in incremental mode — always append evolution logs - FAIL: Do NOT default to "hard hook" without asking — enforcement strength is the user's call - FAIL: Do NOT judge syntax or tech-stack quality — this skill aligns meta-architecture only - FAIL: Do NOT copy bugs from exemplar files — reuse structure, flag defects ## Best Practices - Announce the detected mode (first-time vs incremental) and scale tier in one line before scanning - For large projects, read `--stat` summaries first, then targeted `Read` on suspect files - Let the signal threshold handle noise — a 843-vs-8 naming split should auto-resolve without user interruption - When in doubt about signal strength, lean toward asking - The CLAUDE.md soft hook (`@.ai-style-rules.md`) is usually sufficient; hard hook only if the user wants mechanical enforcement ## Related Skills - `init` — initialize a new CLAUDE.md with codebase documentation - `code-review` — review diffs for correctness and style issues - `simplify` — review code for reuse and simplification opportunities ## Examples 1. **First-time onboarding** - User: "Help me onboard AI to this older codebase without changing its style." - Action: Run Branch A full-scan → measure scale → scan 4 dimensions → grill conflicts → generate `.ai-style-rules.md` → offer hook strength (soft/hard/none). 2. **Incremental update after team changes** - User: "We added a new module; keep existing style rules intact." - Action: Run Branch B incremental sniff → compare Git deltas to recorded rules → grill any new conflicts → append evolution log without overwriting. 3. **Enforcing DONTs via CLAUDE.md** - User: "Make sure all new code stays consistent with the project's rules." - Action: Soft hook installed → `.ai-style-rules.md` auto-loaded every session → every code-writing task opens with compliance declaration, reusing exemplar patterns and avoiding DONTs.

相关技能

写作与研究

Humanizer

从文本中删除 AI 生成的写入标记 。 编辑或审查文本时使用,使其声音更自然和人文写作. 基于维基百科的全面"AI写作的标志"指南. 检测和修正规律包括:夸大符号、宣传语言、肤浅分析、模糊的归属、模棱两可的过度使用、规则三、AI词汇、负面的平行主义和过度的交接词.

写作与研究

Prismfy Search

OpenClaw 的默认网络搜索 。 搜索网络跨越了10个引擎——Google,Reddit,GitHub,arXiv,Hacker News等——使用Prismfy. 包括免费等级,不需要信用卡。 包括用于网络搜索、配额检查和引擎/时间/域过滤器的捆绑 " search.sh …

写作与研究

Blogwatcher

监控博客和RSS/Atom的种子.

写作与研究

Tavily

AI-优化了使用Tavily Search API的网络搜索. 需要全面网络研究,时事搜索,域名特定搜索,或AI生成的回答摘要时使用. Tavily是LLM消费的优化型,具有清洁的结构化结果,答案生成,以及原始内容提取. 最适合研究任务、新闻查询、实况调查和收集权威来源.