Skip to content

feat: add inherit-legacy-style — prevent AI code style drift in legac… - #2098

Merged
affaan-m merged 2 commits into
affaan-m:mainfrom
linsywu:add-inherit-legacy-style
Jun 7, 2026
Merged

affaan-m merged 2 commits into
affaan-m:mainfrom
linsywu:add-inherit-legacy-style

Conversation

@linsywu

@linsywu linsywu commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

…y projects

  • 4-dimension meta-architecture scan (File Anatomy, State & Control Flow, Infrastructure, Error Handling)
  • Scale-adaptive (small=full read, large=smart sampling)
  • Signal-threshold noise reduction with one-at-a-time grilling protocol
  • Generates .ai-style-rules.md with persistent CLAUDE.md hook
  • Language- and framework-agnostic

What Changed

Why This Change

Testing Done

  • Manual testing completed
  • Automated tests pass locally (node tests/run-all.js)
  • Edge cases considered and tested

Type of Change

  • fix: Bug fix
  • feat: New feature
  • refactor: Code refactoring
  • docs: Documentation
  • test: Tests
  • chore: Maintenance/tooling
  • ci: CI/CD changes

Security & Quality Checklist

  • No secrets or API keys committed (ghp_, sk-, AKIA, xoxb, xoxp patterns checked)
  • JSON files validate cleanly
  • Shell scripts pass shellcheck (if applicable)
  • Pre-commit hooks pass locally (if configured)
  • No sensitive data exposed in logs or output
  • Follows conventional commits format

Documentation

  • Updated relevant documentation
  • Added comments for complex logic
  • README updated (if needed)

Summary by cubic

Adds inherit-legacy-style, a skill that learns a legacy project's conventions and turns them into enforceable rules to prevent style drift. It scans the repo, resolves conflicts one at a time with the user, and writes .ai-style-rules.md with an optional CLAUDE.md hook.

  • New Features

    • Scale-adaptive scan across four dimensions: File Anatomy, State & Control Flow, Infrastructure, Error Handling.
    • Noise filtering with thresholding; near-even splits resolved via single, focused prompts.
    • Generates .ai-style-rules.md; optionally referenced from CLAUDE.md for persistent enforcement.
    • First-time full scan and incremental mode using recent diffs; appends evolution logs without overwriting.
  • Bug Fixes

    • Added AskUserQuestion to allowed-tools to enable interactive conflict resolution.

Written for commit 1f05d38. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation
    • Added docs for a new "inherit-legacy-style" skill describing metadata, activation triggers, an auto-detect workflow (first-time full scan vs incremental sniff), rule generation and evolution logging, one-at-a-time conflict resolution, optional enforcement modes (soft/hard/none), anti-patterns, best practices, related skills, and usage examples.

…y projects

- 4-dimension meta-architecture scan (File Anatomy, State & Control Flow, Infrastructure, Error Handling)
- Scale-adaptive (small=full read, large=smart sampling)
- Signal-threshold noise reduction with one-at-a-time grilling protocol
- Generates .ai-style-rules.md with persistent CLAUDE.md hook
- Language- and framework-agnostic
@linsywu
linsywu requested a review from affaan-m as a code owner May 31, 2026 07:06
@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f771be70-ae73-419e-b4de-14b208f4e901

📥 Commits

Reviewing files that changed from the base of the PR and between 3690eba and 1f05d38.

📒 Files selected for processing (1)
  • skills/inherit-legacy-style/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/inherit-legacy-style/SKILL.md

📝 Walkthrough

Walkthrough

Adds a new skill documentation file skills/inherit-legacy-style/SKILL.md describing activation triggers, auto-detect branching (first-time full scan vs. incremental sniff), the Grilling Protocol for conflict resolution, generated artifacts (.ai-style-rules.md, optional CLAUDE.md, evolution logs), enforcement modes, anti-patterns, best practices, and examples.

Changes

inherit-legacy-style Skill Definition

Layer / File(s) Summary
Skill metadata and activation
skills/inherit-legacy-style/SKILL.md
Skill metadata block, top-level overview, When to Activate/Use, and prerequisites.
Full-scan and incremental workflows, enforcement
skills/inherit-legacy-style/SKILL.md
Auto-detect mode selection, Branch A full-scan steps (scale/tiering, four meta-architecture dimensions, signal-threshold noise reduction, Grilling Protocol), enforcement hook options (soft/hard/no) and Branch B incremental sniff behavior (load rules, git diff/log detection, conflict resolution, append evolution logs).
Best practices and examples
skills/inherit-legacy-style/SKILL.md
Output specification (rules file, optional CLAUDE.md, dated evolution logs), anti-patterns, related skills, best practices, and example scenarios for onboarding and enforcement.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rulebook unearthed, for code in decline,
I sniff and I grill for each naming sign,
I log every change with a careful paw,
Gentle hooks, firm hooks—I'll keep legacy law. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a new 'inherit-legacy-style' feature to prevent AI code style drift in legacy projects, which matches the PR's core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/inherit-legacy-style/SKILL.md (1)

12-131: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add explicit When to Use, How It Works, and Examples sections for skills docs consistency.

This file is structurally strong, but it misses the exact section headings required for skills/**/*.md. To avoid breaking auto-activation conventions, keep ## When to Activate and add ## When to Use as a short alias/cross-reference, then add explicit ## How It Works and ## Examples.

Suggested structure adjustment
 ## When to Activate
 ...
+## When to Use
+
+Use this skill when you need to preserve legacy project style and prevent AI-generated style drift.  
+See **When to Activate** for trigger conditions.
+
+## How It Works
+
+This skill auto-detects first-time vs incremental mode, scans style signals across four dimensions, resolves strong-signal conflicts one at a time, and persists decisions into `.ai-style-rules.md` with optional enforcement hooks.
+
 ...
 ## Related Skills
 ...
+
+## Examples
+
+1. **First-time onboarding**
+   - User: “Help me onboard AI to this older codebase without changing its style.”
+   - Action: Run full-scan branch, generate `.ai-style-rules.md`, offer hook strength.
+
+2. **Incremental update**
+   - User: “We added a new module; keep existing style rules intact.”
+   - Action: Run incremental sniff, compare deltas to rules, append evolution log.

As per coding guidelines: "skills/**/*.md: Skills should be formatted as Markdown with clear sections for When to Use, How It Works, and Examples."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/inherit-legacy-style/SKILL.md` around lines 12 - 131, The doc is
missing required headings; update SKILL.md to keep the existing "## When to
Activate" then add a short alias "## When to Use" that cross-references that
section, add a new "## How It Works" summarizing the Auto-Detect/Branch A/Branch
B workflow in 3–5 bullets (referencing Auto-Detect Mode, Branch A — First-time
Full-Scan, Branch B — Incremental Sniff), and add a concise "## Examples"
section with 2–3 concrete usage examples (e.g., first-time onboarding of a
legacy repo, incremental rule evolution after recent commits, and enforcing
DONTs via CLAUDE.md); ensure the new headings are exact strings "## When to
Use", "## How It Works", and "## Examples" so the auto-activation parser
recognizes them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/inherit-legacy-style/SKILL.md`:
- Line 5: The allowed-tools list at the top of SKILL.md is missing
AskUserQuestion while the workflow (the “Install the persistent hook” step and
the requirement referenced as AskUserQuestion) needs it; update the
allowed-tools entry (the line currently listing Read, Glob, Grep, Bash, Edit,
Write) to include AskUserQuestion so the skill runtime permits that tool during
the Install the persistent hook step.

---

Outside diff comments:
In `@skills/inherit-legacy-style/SKILL.md`:
- Around line 12-131: The doc is missing required headings; update SKILL.md to
keep the existing "## When to Activate" then add a short alias "## When to Use"
that cross-references that section, add a new "## How It Works" summarizing the
Auto-Detect/Branch A/Branch B workflow in 3–5 bullets (referencing Auto-Detect
Mode, Branch A — First-time Full-Scan, Branch B — Incremental Sniff), and add a
concise "## Examples" section with 2–3 concrete usage examples (e.g., first-time
onboarding of a legacy repo, incremental rule evolution after recent commits,
and enforcing DONTs via CLAUDE.md); ensure the new headings are exact strings
"## When to Use", "## How It Works", and "## Examples" so the auto-activation
parser recognizes them.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8823dea-0d2b-4463-9b29-4881a7bc3b43

📥 Commits

Reviewing files that changed from the base of the PR and between 64cd1ba and 3690eba.

📒 Files selected for processing (1)
  • skills/inherit-legacy-style/SKILL.md

Comment thread skills/inherit-legacy-style/SKILL.md Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread skills/inherit-legacy-style/SKILL.md Outdated
@affaan-m
affaan-m merged commit 28b78dd into affaan-m:main Jun 7, 2026
3 checks passed
syarfandi pushed a commit to syarfandi/ECC that referenced this pull request Jun 9, 2026
affaan-m#2098)

* feat: add inherit-legacy-style — prevent AI code style drift in legacy projects

- 4-dimension meta-architecture scan (File Anatomy, State & Control Flow, Infrastructure, Error Handling)
- Scale-adaptive (small=full read, large=smart sampling)
- Signal-threshold noise reduction with one-at-a-time grilling protocol
- Generates .ai-style-rules.md with persistent CLAUDE.md hook
- Language- and framework-agnostic

* fix: add AskUserQuestion to allowed-tools, add When to Use/How It Works/Examples sections per bot review

---------

Co-authored-by: wulinzai <linsywu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants